Its always annoying to move accounts around between servers because you have to coordinate lots of changes for example :
1- dns changes
2- minimizing downtime so you wont get users screaming at your face
3- notifying your users early enough (beware you will never be early enough)
In this tutorial we will guide you in step by step in how to perform a flawless migration.
Please note this tutorial is for migrating some accounts on the server not all the server, it will work well if you use the steps we mention on all accounts as well .
Now lets rock and roll.
First step has to be done 48-72 hours prior to migration (this used to be 24-48 hours back in the good old days when root nameservers acted correctly ) :
First we create a file named accounts which have the domains we need to transfer one domain in each line like this
Now in the day designated for the migration
First we stop all services on the old server other than apache and MySQL ( to avoid loosing any emails or other stuff)
1- Click on copy multiple accounts
2- Fill out the old server data
3- Select accounts to transfer
4- Initiate the transfer process
Once the transfer has finished ssh to the old server and run this commands :
Transfer completed. Sites are functioning on new server, now transfer the nameservers! Here we go:
Be sure to set up your NEW nameservers on the NEW server. (WHM will only add an A record for the oldips) until you transfer the nameservers with the registrar) so you need to edit the DNS zones to reflect the new ips.
Submit the ip changes to your registrar and give it 48 hours to update. Within 48 hours your DNS will be served off your new server, thus you can cancel that old server with that host you couldn’t wait to leave.
If you have resellers, we have to copy all the files in /var/cpanel that reference resellers and anything ending in .accts to the new server.
Still one problem persists, some nameservers doesn’t respect TTL changes and work on their own schedule (usually 48 hours)
What can we do to overcome this , if we use iptables to route all traffic to the new ip we will face a problem cuz of the shared ip on the old server , we may have other domains still using it.
The solution to this problem is using Apache mod_proxy , here is how to do so:
Edit /usr/local/apache/conf/httpd.conf and inside each transferred site virtualhost directive and add this :
Then mod_proxy will direct traffic to the new server.
Once the lagged nameservers have updated their cache – usually in 48 hours as I mentioned before – you will be good to go.
Migrating a server as a whole is a different story which strangely is easier but that’s a different article , hope this helps anyone out there .
1- dns changes
2- minimizing downtime so you wont get users screaming at your face
3- notifying your users early enough (beware you will never be early enough)
In this tutorial we will guide you in step by step in how to perform a flawless migration.
Please note this tutorial is for migrating some accounts on the server not all the server, it will work well if you use the steps we mention on all accounts as well .
Now lets rock and roll.
First step has to be done 48-72 hours prior to migration (this used to be 24-48 hours back in the good old days when root nameservers acted correctly ) :
First we create a file named accounts which have the domains we need to transfer one domain in each line like this
domain1.comThen run this command
domain2.com
for account in ` cat accounts `;do perl -pi.bak -e "s/14400/300/g if /^\s*\$TTL/" /var/named/$account.db;done /etc/init.d/named restartHere we have edited all DNS zones listed in our accounts file and created a .bak of each (remember always backup). Changing the TTL (time To Live) from 14400 (4 hours) to 300 (5 minutes) means that as soon as we make a change to a DNS zone, it will take affect everywhere within 5 minutes as opposed to 4 hours, personally I find that this doesn’t work perfectly anymore but I will tell you how to overcome it ;)
Now in the day designated for the migration
First we stop all services on the old server other than apache and MySQL ( to avoid loosing any emails or other stuff)
/etc/init.d/cpanel stop /etc/init.d/exim stop /etc/init.d/pure-ftpd stop;/scripts/ckillall -9 pure-ftpd;/scripts/ckillall -9 pure-authd /etc/init.d/proftpd stopAfter that login to WHM on the new server as root then :
1- Click on copy multiple accounts
2- Fill out the old server data
3- Select accounts to transfer
4- Initiate the transfer process
Once the transfer has finished ssh to the old server and run this commands :
for account in ` cat accounts `;do perl -pi -e "s/[oldip]/[newip]/g" /var/named/$account.db;done /etc/init.d/named restartThis will point all the sites to the newip. Hopefully most of your sites are on a shared ip. For all the accounts that are NOT on a shared ip we will need to edit that domain dns zone manually to reflect the new IP.
Transfer completed. Sites are functioning on new server, now transfer the nameservers! Here we go:
Be sure to set up your NEW nameservers on the NEW server. (WHM will only add an A record for the oldips) until you transfer the nameservers with the registrar) so you need to edit the DNS zones to reflect the new ips.
Submit the ip changes to your registrar and give it 48 hours to update. Within 48 hours your DNS will be served off your new server, thus you can cancel that old server with that host you couldn’t wait to leave.
If you have resellers, we have to copy all the files in /var/cpanel that reference resellers and anything ending in .accts to the new server.
Still one problem persists, some nameservers doesn’t respect TTL changes and work on their own schedule (usually 48 hours)
What can we do to overcome this , if we use iptables to route all traffic to the new ip we will face a problem cuz of the shared ip on the old server , we may have other domains still using it.
The solution to this problem is using Apache mod_proxy , here is how to do so:
Edit /usr/local/apache/conf/httpd.conf and inside each transferred site virtualhost directive and add this :
ProxyRequests Off ProxyPass / http://domain.com/ ProxyPassReverse / http://domain.com/If one of the domains has SSL certificate use this :
SSLProxyEngine On ProxyRequests Off ProxyPass / https://domain.com/ ProxyPassReverse / https://domain.com/To assure that this domains resolves to the new ips you can edit /etc/hosts and add this domains with their new ips
Then mod_proxy will direct traffic to the new server.
Once the lagged nameservers have updated their cache – usually in 48 hours as I mentioned before – you will be good to go.
Migrating a server as a whole is a different story which strangely is easier but that’s a different article , hope this helps anyone out there .
Aucun commentaire :
Enregistrer un commentaire