Scenario:
Server hardware is old. We want to shift to a new server keeping the IP's the same.
Both machines have WHM / Cpanel latest version. Both have identical configurations and config files updated for both.
Issue:
After the Accounts are all pulled to the new server through WHM, the Datacenter has to be informed about the IP Switch from old to new server.
This may take from 15 minutes upto a few hours for them to respond to the support ticket and actually do the switch. Or we could also schedule this for a fixed date / time in future.
The Question:
I wanted to know if there is an effective way of keeping the servers "synced" uptil the last few minutes before the switch.
Mainly to ensure that MySQL, Email and Website data is updated and latest on the new server.
- - - Updated - - -
I read an interesting article at http://bobcares.com/blog/?p=97 which has exactly what I want.
However, I was wondering whether rsyncing had any drawbacks.
I was especially concerned about whether rsyncing, and repairing the databases was foolproof.
I ask this, since I have seen a lot of threads with cpanel techs being apprehensive about using rsync.
Server hardware is old. We want to shift to a new server keeping the IP's the same.
Both machines have WHM / Cpanel latest version. Both have identical configurations and config files updated for both.
Issue:
After the Accounts are all pulled to the new server through WHM, the Datacenter has to be informed about the IP Switch from old to new server.
This may take from 15 minutes upto a few hours for them to respond to the support ticket and actually do the switch. Or we could also schedule this for a fixed date / time in future.
The Question:
I wanted to know if there is an effective way of keeping the servers "synced" uptil the last few minutes before the switch.
Mainly to ensure that MySQL, Email and Website data is updated and latest on the new server.
- - - Updated - - -
I read an interesting article at http://bobcares.com/blog/?p=97 which has exactly what I want.
However, I was wondering whether rsyncing had any drawbacks.
I was especially concerned about whether rsyncing, and repairing the databases was foolproof.
I ask this, since I have seen a lot of threads with cpanel techs being apprehensive about using rsync.
Rsync
Once the account moves are done, the next thing would be that till the ip changes, nameserver changes are done for the accesses to be directed to the accounts on the new server, we would need to ensure that they are synchronized and no data is lost.
To rsync, follow these steps:
a) Setup ssh-key
b) rsync the folders /home , /var/cpanel , /var/lib/mysql , /usr/local/cpanel/3rdparty/mailman , /usr/local/cpanel/base/frontend , /etc/valiases , /etc/vdomainaliases , /etc/vfilters using the commands
for user in `cat /home/tomove`;
do rsync -avuz -e ssh [email protected]:/home/$user/ /home/$user; done
rsync -avuz -e ssh [email protected]:/var/cpanel /var/cpanel
rsync -avuz -e ssh [email protected]:/var/lib/mysql /var/lib/mysql
rsync -avuz -e ssh [email protected]:/usr/local/cpanel/3rdparty/mailman /usr/local/cpanel/3rdparty/mailman
rsync -avuz -e ssh [email protected]:/usr/local/cpanel/base/frontend /usr/local/cpanel/base/frontend
rsync -avuz -e ssh [email protected]:/etc/valiases /etc/valiases
rsync -avuz -e ssh [email protected]:/etc/vdomainaliases /etc/vdomainaliases
rsync -avuz -e ssh [email protected]:/etc/vfilters /etc/vfilters
Fixing Databases
Once rsync is completed, you need to repair the mysql databases since they get corrupted.
By running /scripts/fixmysql on the new server and verifying if the databases are showing to be ok, you can ensure that there is no corruption in databases. Just run the following commands after going to /var/lib/mysql on the new server
/scripts/fixmysql;/usr/bin/mysql_fix_privilege_tables;/usr/bin/mysqlcheck -A --auto-repair;myisamchk -r -e ./*
Setting up Cron
You can setup Cron scheduler to repeat the rsync every couple of hours till the IP’s on the old server are changed to that of new servers. This ensures minimum loss of data.