I am going to migrate a site from one server to another. The site has a good bit of realtime transaction activity reading/writing to a backend database.

I believe I should ratchet down the TTL in the DNS on the domain so that once I am ready to make the switch all I need to do is update the nameservers assigned to the domain name and traffic will begin to move to the new server.

If my understanding of the process is correct, what should I set the TTL to on my current server?

Do I also need to set the "refresh", "retry", and "expire" values on my old server? If so, what should they be set too?



www.blah.com is hosted at hosting service provider "hoster

www.blah.com has its ns1 record as ns1.myFirstNameServer.net and its ns2 record as ns2.myFirstNameServer.net

I setup a new name server with ns records as ns1.aNewNameServerIdecidedToBuy.net and ns2.aNewNameServerIdecidedToBuy.net -- its IPs point to my current server at current "hoster"

Both my name server domains (myFirstNameServer.net and aNewNameServerIdecidedToBuy.net) are setup and reside with my registrar in their dns setup -- its IPs point to my new server at new "hoster"

Once I am ready to make the switch, I will logon to my registrar and change the nameserver setting on www.blah.com as follows:

  • from ns1.myFirstNameServer.net to ns1.aNewNameServerIdecidedToBuy.net
  • from ns2.myFirstNameServer.net to ns2.aNewNameServerIdecidedToBuy.net
  • Are you moving the domain from one registrar to another? Are you moving the name servers to another DNS provider? Or are you simply moving the web site to a new web hoster? – joeqwerty May 16 '12 at 20:41
  • Simply moving web site to new hoster @joeqwerty. The registrar remains the same. NS1 and NS2 are set to current name servers (current hoster). I have a new ns1 and ns2 nameservers set and tested (at new hoster). So all I want to do is change the name server settings at my registrar when I am ready to switch. But I first want to make sure all the DNS servers "out there" will grab the new nameserver when I switch. So I believe all I need to do for this process is to lower my TTL on the domain name. Is that correct? – H. Ferrence May 16 '12 at 20:47
  • If you're simply moving the web site then you don't have to make any changes to the NS records, unless the current web hoster requires that you move your name servers when you move your web site (if the web hoster is also hosting the DNS zone). There's no requirement that the web hoster also host the DNS. My recommendation would be to move the name servers to the registrar and leave them there, avoiding any need to change them in the future. – joeqwerty May 16 '12 at 20:55
  • You might be mis-understanding my objective. My site gets traffic that writes records to a database. I do not want "part of the world" writing to the DB on the old server while the remaining part of the world simultaneously writes to the DB on the new server (my data is now out of sync). Thus I want everyone to hit the new server when I make my cutover. Is DNS TTL the way to handle this? – H. Ferrence May 16 '12 at 20:59
  • I'm misunderstanding what you're asking. Are you moving the web site (www.blah.com) to a new web hoster or are you moving the name servers (in effect moving the entrie DNS domain/zone) to another DNS hoster? If you're only moving the web site to a new web hoster then lower the TTL on the DNS records that are relevant to the web site...only. There's no need to make any changes to the NS or SOA records... at all. – joeqwerty May 16 '12 at 21:03

To keep things simple and do one thing at a time, you should not change your domain's NS records during this migration. If you want to migrate the web site and also migrate the authoritative DNS server, do it in 2 separate steps. To migrate the web site, change only the A and AAAA records.

A conventional "low value" TTL to set on the A and AAAA records is 300 (5 minutes).

If you can operate both servers at the same time for a short period, then you can do even better than a DNS-based migration. You can set the old server to proxy requests to the new server, so that clients which still contact the old server get their requests forwarded to the new server. This is easy to achieve with Apache with ProxyPass.

Later, if you want to move the DNS hosting, change the NS records and change the delegation in the parent zone (i.e. make the change at your domain's registrar). It is ideal if you can deploy the zone in the new servers ahead of time and leave both sets of nameservers serving the domain for a period of time.

EDIT: Details about ProxyPass

This Apache config snippet, placed in the <VirtualHost> section for your server, or directly in server config if there is no <VirtualHost>, will allow the old server to forward all requests to the new server:

<Location />
    ProxyPass http://www.example.org/

You normally should have ProxyPassReverse with ProxyPass but in this case it can be omitted since it would have no effect because the old site and new site have identical ServerName.

You probably want to remove any other <Location>, Alias, RewriteRule, or other URL-mapping directives from the old server config at the same time to be certain that the proxy rule and only the proxy rule gets processed. (Keep a backup around, of course, in case you need to back out of your migration!)

Make sure the old server knows the correct new IP address for the web site's domain, otherwise it will proxy the request back to itself!

| improve this answer | |
  • +1 for mentioning proxy - seems to be the best way to achieve zero downtime during transfer in a read/write environment. – Sandman4 May 16 '12 at 21:25
  • So @Celada, the directives I need to put into .htaccess on my current (source) server is: ProxyPass /full/document/root/path/of/my/current/site http://migratedDomain.com/ and ProxyPassReverse /full/document/root/path/of/my/current/site http://migratedDomain.com/ – H. Ferrence May 17 '12 at 1:58
  • I added more information about proxying to my answer – Celada May 17 '12 at 2:17
  • Thanks @Celada -- it's getting a little clearer. Quote Make sure the old server knows the correct new IP address for the web site's domain, otherwise it will proxy the request back to itself! How do you do that? Change the A records in the DNS on the old server to use the new server IP? – H. Ferrence May 17 '12 at 10:26
  • You could put the hostname with the new IP address into /etc/hosts on the old server so that the old server will resolve the name to the new IP address regardless of what DNS thinks. – Celada May 17 '12 at 16:01

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.