Linux – Using /etc/hosts to redirect traffic during DNS switch

hosts-fileiplinuxmigrationnetworking

I'm migrating a rather busy site to another server cluster.

The site with a MySQL master and two slave servers. I'd like to have as little downtime as possible during the switch, and my biggest concern is the time it takes for the DNS change to propogate.

The master database server operates under mysql.domain.com.

My thought was to copy the master database to our new server, and then switch DNS for mysql.domain.com to the IP of the new master. However, this will mean that I'll have requests coming to both master servers until DNS has propogated world-wide, causing havoc with my data.

My plan is to alter the /etc/hosts file on the old master server, so that any requests for mysql.domain.com go to the IP of the new server.

Does anyone see potential hazards with this?

Best Answer

If both servers are located next to each other, why not transfer the IP address of the old server to the new one. You can have two (or more) IP addresses per server. Having your new server answer to both will mitigate all your problems.

If possible, I'd vote:

  • Shut down old server
  • Activate new server with new IP AND the IP of the old server
  • If necessary: Provide a different IP to the old server and bring it back on.

Alternatively set up whatever IP-failover mechanism you feel comfortable with. Make sure that your new master has all the data from the old one.

Regarding your question:

Does that mean that you're providing "international" mysql-service or are you talking about a webserver farm or similar that just happens to use a clustered mysql installation in the background? Do you control the computers that connect to the database? This would open up even more possibilities

Related Topic