0

I need to create a shorter name for my Mysql database endpoint to be accessed from linux box. Clearly said, my mysql end point is rdsbench.c2wfqsdsqd.us-east-1.rds.amazonaws.com and I would like to create a shorter name, let's say mybenchdb, so I could use:

mysql -hmybenchdb 

instead of:

mysql -hrdsbench.c2wfqsdsqd.us-east-1.rds.amazonaws.com.

EDIT: actually I'm using percona toolkit to benchmark rds and compare it to mysql hosted on ec2. The command line is as follows:

pt-upgrade mysql-slow.log.1 h=host1 h=rdsbench.c2wffzqsdsqs.us-east-1.rds.amazonaws.com

so what I would like to do is shorten the rds endpoint I'm passing as parameter for this command.

PapelPincel
  • 325
  • 6
  • 18

2 Answers2

2

You can setup a local DNS server to resolve it to a shorter name. If you are connecting from a bash shell, you could also do,

$ export mybenchdb="rdsbench.c2wfqsdsqd.us-east-1.rds.amazonaws.com"
$ mysql -h$mybenchdb

Add the export to .profile or .bash_profile and it should be permanent.

mgorven
  • 30,615
  • 7
  • 79
  • 122
Chida
  • 2,491
  • 1
  • 17
  • 29
  • It should work with this: `export mybenchdb="rdsbench.c2wfqsdsqd.us-east-1.rds.amazonaws.com"` `pt-upgrade mysql-slow.log.1 h=host1 h=$mybenchdb` – Frederik Aug 10 '12 at 11:19
  • that's exactly what I did, but the problem is that the mysql endpoint is showing in pt-upgrade results – PapelPincel Aug 10 '12 at 11:37
  • 2
    Adding an entry to the hosts file or setting a search base in the hosts.conf is probably more sensible than trying to modify the DNS server - you'll break other stuff if you claim to have authoritative records for a domain you don't really control. – symcbean Aug 10 '12 at 11:39
  • @symcbean Except on AWS RDS, the IP of your RDS can change on its own. – ceejayoz Dec 15 '12 at 03:25
2

This is how I solved this problem:

  1. Get the public IP address of RDS endpoint

    $ nslookup rdsbench.c2dddddddx.us-east-1.rds.amazonaws.com
    Address: 10.271.12.X
    
  2. Add this IP address along with your favourite alias name to /etc/hosts file

    10.271.12.X  mybenchdb
    
gertvdijk
  • 3,504
  • 4
  • 30
  • 46
PapelPincel
  • 325
  • 6
  • 18