0

I have a webserver in production. Its IP is 111.111.111.111 and it is referred to as ServerA. In addition to storing script files, the server also stores user uploaded files and has a database. The application uses wildcard subdomains where foo.example.com, bar.example.com, etc go to a common virtual host, and the server code responds as appropriate given the subdomain name. I have my domain registrar pointing to IP 111.111.111.111 and also set up to support wildcards.

I will need to change webservers to a new server with IP 222.222.222.222 which it is referred to as ServerB.

What steps should be taken to migrate the servers with minimum downtime?

Below is my initial thoughts. Please comment if incorrect or if I am missing steps.

  1. Post notice on ServerA that the system will be down for maintenance.
  2. Setup Apache on ServerB similar to the setup on ServerA and also add another virtual host on ServerB with ServerName 222.222.222.222, (more on this later).
  3. Set up Apache on ServerA to display a down for maintenance page instead of accessing the application script.
  4. Copy script files, uploaded user files, and the database from ServerA to ServerB.
  5. Change domain registrar to point to IP 222.222.222.222.
  6. Setup Apache on ServerA to redirect all requests to IP 222.222.222.222. How will this work with the subdomain requirements?
  7. Wait for domain name changes to propagate. Will I be down during this time?
  8. After ServerB is fully tested, cancel service plan for ServerA.
user1032531
  • 568
  • 2
  • 11
  • 26

1 Answers1

6

How about a zero downtime migration?

This is my general plan for such migrations:

  1. Set up an ad hoc VPN between the old server and the new server (e.g. with OpenVPN).
  2. Copy the entire application from the old server to the new server.
  3. Set up database replication between the old server and the new server, with the old server as master and the new server as slave, via the VPN.
  4. Wait for all databases to be replicated. This may take a while.
  5. Once replication is complete, connect directly to the new server (use the /etc/hosts trick) and verify that the application seems to work, that the web server is configured correctly, etc.
  6. Break the master/slave relationship and configure the application on the old server to talk to the database on the new server via the VPN.
  7. Change the DNS records. While waiting for the TTL to expire, some users will hit the old server and some will hit the new server, but both will use the database on the new server.
  8. When the TTL expires and the old server is no longer receiving traffic, decommission it. Take down the temporary VPN.
Michael Hampton
  • 244,070
  • 43
  • 506
  • 972
  • Zero downtime is good! I've never done database replication. Is this available with MySQL community edition (EDIT. Looks like it is: http://dev.mysql.com/doc/refman/5.0/en/replication.html)? Could you give me some key words to google regarding the /etc/hosts trick? Thank you – user1032531 Feb 02 '15 at 20:26
  • Yes, you can do replication with MySQL; it's all in their documentation. And modifying /etc/hosts is just putting the IP address of a site in the hosts file to override where your computer tries to load it from. Pretty common development trick. – Michael Hampton Feb 02 '15 at 20:27
  • Thanks Michael, After asking about replication, I did a little research and found it. Very nice answer! – user1032531 Feb 02 '15 at 20:30