Wednesday, May 20, 2009

Dealing With Upgrade

Just had a conversation with someone about the problems she has almost everytime she does her operating system version upgrades. So it's inspired me to want to explain how I do mine.

I run my system with the /home folder running on a seperate partition, this is a little tricky to do but with a little Google research it's perfectly do-able. Then I have a few small partitions - 10gb is enough but i prefer a little more - and these little partitions are where i host everything else, i.e. the operation system and installed programs.

By running this way I have more than one version of ubuntu to boot into with them all using the same /home folder. This is most useful at upgrade time, when upgrading I isntall a fresh install into an empty partition, this way I can still opt to boot into the old OS if I can't yet get all things working on the latest OS upgrade.

Friday, May 1, 2009

Moving A Website Between Servers While Avoiding DNS Caching Problem

I have the familiar task of moving a website from one dedicated server to another, the ip addresses are locked to the servers so no moving it that way. I have already done the trick of shortening the TTL (time to live) of the DNS zone file entry, but I find this has little effect, it still takes many hours for every request to the domain to always lead to the new server, several hours (upto 72hrs) for the changed DNS zone file to propergate through the internet.

So the question is how does one ensure that all web traffic gets to the new server?

The answer is pretty simple, we use the hostname prefix part of the domain name. Add an entry to the DNS zone file with a new hostname with a prefix that you have never used before, i.e. if your site is domain-name.com you most likley use www.domain-name.com and the prefixless version domain-name.com, so in this case we will add w3.domain-name.com, this needs at least an hour to propergate on your DNS server so do this a little in advance of switchover time. Then when you are ready to switch over simply change the DNS zone file record for the usual hostnames you use, then add a redirect instruction in you Apache .conf files on your old server, or you could add it to a .htaccess file in the root folder of the site:

Redirect / http://w3.domain-name.com/

This line will forward all http requests sent to the old server to be forwarded seemlessly to the new server, even if its a long url with specific detail, i.e. www.domain-name.com/help.html this would be forwarded to w3.domain-name.com/help.html.

This only need be in place for a few days after switchover.

As yet i have not tested weather all requests work, form posts etc, but I see no reason why they would not work.

Good Luck.

Matt