I’m working EC2 instances and RDS for my MySQL databases.
I’m wanting to have all scripting refer to localhost for the MySQL Database connection, and then route 3306 I would assume, through to a specific RDS DNS host address. How is this possible?
The reason I’m doing it is because there’s no load balancing for RDS yet, and I want to just have a central place for controlling which RDS host is on.
Is this something for iptables?
It sounds like the important thing is that you want to create an alias for your database server so that you can change the IP address later without having to change any of your code. For that purpose, you can use the
/etc/hostsfile. But if you use this technique, do not use or change thelocalhostsetting.localhostis special and changing the definition oflocalhostin your /etc/hosts file can have bad side effects.Instead, create a separate entry in
/etc/hostsfor your database server. The format of the file is IP_ADDRESS NAME. For example:All of your code can then refer to
dbserverfor the hostname of your database server. Later, you can change the IP address in the/etc/hostsfile to something else when you move your database.