I have a webserver in production. Its IP is 18.104.22.168 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 22.214.171.124 and also set up to support wildcards.
I will need to change webservers to a new server with IP 126.96.36.199 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.
- Post notice on ServerA that the system will be down for maintenance.
- Setup Apache on ServerB similar to the setup on ServerA and also add another virtual host on ServerB with ServerName 188.8.131.52, (more on this later).
- Set up Apache on ServerA to display a down for maintenance page instead of accessing the application script.
- Copy script files, uploaded user files, and the database from ServerA to ServerB.
- Change domain registrar to point to IP 184.108.40.206.
- Setup Apache on ServerA to redirect all requests to IP 220.127.116.11. How will this work with the subdomain requirements?
- Wait for domain name changes to propagate. Will I be down during this time?
- After ServerB is fully tested, cancel service plan for ServerA.
How about a zero downtime migration?
This is my general plan for such migrations:
- Set up an ad hoc VPN between the old server and the new server (e.g. with OpenVPN).
- Copy the entire application from the old server to the new server.
- 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.
- Wait for all databases to be replicated. This may take a while.
- 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.
- 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.
- 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.
- When the TTL expires and the old server is no longer receiving traffic, decommission it. Take down the temporary VPN.
This work is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.