EmergencyEMERGENCY? Get 24/7 Help Now!

High availability for MySQL on Amazon EC2 – Part 6 – Publishing server location

 | February 16, 2011 |  Posted In: Cloud and MySQL, Cloud and NoSQL, MySQL


This post is the sixth of a series that started here.

From the previous posts of this series, we now have an HA MySQL service running on EC2. We now need to find a way to point the web servers or application servers to the HA MySQL service. Normally, in an HA setup, this is achieved using virtual IP addresses but EC2 does not support virtual IPs. In addition, we can use neither broadcast nor multicast. So, we will need to reconfigure the web/application servers but that raises a first challenge, how to locate them.

The listing of the web/applications servers if easily done if they are all members (and the only members) of the same security group. A security group is an easy and convenient way to group similar servers. Once in the same group, we can list the instances in the security group and get their IP addresses. Finally, with the IP addresses and pre-configured ssh keys, we can remotely act on the web/application servers through ssh from the monitoring instance. Here is the part of the resource script (monitoring instance) that publishes the IP address of a newly created MySQL server.

There are many ways to configure web/application servers, I chose to have the applications connect to on port 3306 and then redirect the connection to MySQL using xinetd redirect type of services. The update_xinetd.sh script just updates the xinetd and send a kill -HUP to the process. Another equally valid option would be to change the IP address in a php configuration file.

Yves Trudeau

Yves is a Principal Consultant at Percona, specializing in distributed technologies such as MySQL Cluster, Pacemaker and XtraDB cluster. He was previously a senior consultant for MySQL and Sun Microsystems. He holds a Ph.D. in Experimental Physics.

Leave a Reply