Difference between revisions of "Modified Rsync Migration"

(Created page with "Zimbra Hardware Migration '''Goal:''' Migrate single server Zimbra to new hardware with the minimal amount of downtime. '''Case Study:''' Migration of ZCS 7.14 P1 on RHEL5 (...")
(No difference)

Revision as of 17:15, 3 January 2013

Zimbra Hardware Migration

Goal: Migrate single server Zimbra to new hardware with the minimal amount of downtime.

Case Study: Migration of ZCS 7.14 P1 on RHEL5 (EXISTING) to ZCS 7.14 P1 on RHEL6 (NEW). Zimbra stored under directory /opt/zimbra. EXISTING mail store was 570 GB. Migration required ~45 minutes of downtime.

1. Install Zimbra on NEW using values from EXISTING installation including passwords, admin username, ham username, spam username, virus username. Existing values can be retrieved by running the following command as zimbra:

/opt/zimbra/bin/zmlocalconfig -c /backup/localconfig.xml -s > /backup/OLD-localconfig.xml

The IP address of the new server may be different for setup, install and testing of the migration and then changed. The important parts are that the /etc/hosts file is setup correctly and that DNS resolves properly. For testing, Split DNS was used

See http://wiki.zimbra.com/wiki/Split_DNS for more information.

2.Dump LDAP config and data, as zimbra user, on EXISTING.

/opt/zimbra/libexec/zmslapcat -c /backup  

This creates /backup/ldap-config.bak

/opt/zimbra/libexec/zmslapcat /backup This creates /backup/ldap.bak

3. Copy the LDAP data to the NEW server – scp, rsync over ssh

4. Stop Zimbra on NEW server, as zimbra

zmcontrol stop

5. Delete the ldap config directory:

rm /opt/zimbra/data/ldap/config

6. Move the ldap hdb directory:

mv /opt/zimbra/data/ldap/hdb /opt/zimbra/data/ldap/hdb.old

7. Create the hdb directory structure:

mkdir –p /opt/zimbra/data/ldap/hdb/db /opt/zimbra/data/ldap/hdb/logs

8. Copy the DB_CONFIG from hdb.old to hdb:

cp /opt/zimbra/data/ldap/hdb.old/db/DB_CONFIG /opt/zimbra/data/ldap/hdb/db/DB_CONFIG

9. Fix permissions for newly created directories:

chown -R zimbra:zimbra /opt/zimbra/data/ldap

10. Import the ldap config :

/opt/zimbra/openldap/sbin/slapadd -q -n 0 -F /opt/zimbra/data/ldap/config -cv -l /backup/ldap-config.bak

11. Import the ldap data:

/opt/zimbra/openldap/sbin/slapadd -q -b "" -F /opt/zimbra/data/ldap/config -cv -l /backup/ldap.bak

12. Edit /opt/zimbra/conf/localconfig.xml to update/check the following with the values from the localconfig.xml file on the EXISTING server:

a. zimbra_mysql_password

b. mysql_root_password

c. zimbra_logger_mysql_password (Note: Transfer/copy this value to the new 64-bit server only if available from the old 32-bit server.)


d. mailboxd_keystore_password (Note: Transfer/copy this value to the new 64-bit server only if available from the old 32-bit server.)

e. mailboxd_truststore_password

f. mailboxd_keystore_base_password

g. zimbra_ldap_password

h. ldap_root_password

i. ldap_postfix_password

j. ldap_amavis_password

k. ldap_nginx_password

l. ldap_replication_password

At this point, the NEW server is provisioned with the EXISTING server’s information but no data.

13. We start an rsync from EXISTING to NEW in order to minimize downtime:

rsync -avzHS /opt/zimbra/store/ NEW:/opt/zimbra/store 
rsync -avzHS /opt/zimbra/index/ NEW:/opt/zimbra/index 

Commercial Certificates and Custom Configurations should be copied as well, e.g. slapd.crt, slapd.key, salocal.conf.in etc.

Repeat steps a-c a few times until just before you are ready to shutdown zimbra services and do the final migration.

NOTE: The rsync of the store and index can (and should) be done in multiple sessions, with Zimbra still running on the EXISTING server, to limit downtime, e.g. first rsync takes 18 hours, second rsync takes 4 hours, third rsync takes 1 hour, and FINAL rsync takes 15 minutes.

14. When it is time for migration: stop Zimbra on EXISTING server – as zimbra:

zmcontrol stop

15. Start FINAL rsync from EXISTING to NEW:

rsync -avzHS /opt/zimbra/store/ NEW:/opt/zimbra/store &
rsync -avzHS /opt/zimbra/index/ NEW:/opt/zimbra/index &


Commercial Certificates and Custom Configurations should be copied as well, e.g. slapd.crt, slapd.key, salocal.conf.in etc.

16. As root, on NEW:

/opt/zimbra/libexec/zmfixperms –extended

We now have the mail store of the EXISTING server on the NEW server but no association to the data.

17. The databases MUST be dumped after the store is rsynced so that the blob pointers exist properly. Dump MySQL databases on EXISTING

mysql.server start
source ~/bin/zmshutil ; zmsetvars
mkdir /tmp/sql-dump/
mysql --batch --skip-column-names -e "show databases" | grep -e mbox -e zimbra > /tmp/sql-  dump/mysql.db.list
for db in `cat /tmp/sql-dump/mysql.db.list`; do
~/mysql/bin/mysqldump $db -S $mysql_socket -u root --password=$mysql_root_password > /tmp/sql- dump/$db.sql
    echo "Dumped $db"
done

18. Move sql files to NEW From EXISTING:

scp –R /tmp/sql-dump/ NEW:/tmp/

19. Stop Zimbra on NEW – as zimbra:

zmcontrol stop

20. Drop databases on NEW as zimbra:

mysql.server start
Source ~/bin/zmshutil ; zmsetvars
mysql --batch --skip-column-names -e "show databases" | grep -e mbox -e zimbra > /tmp/mysql.db.list
for db in `cat /tmp/mysql.db.list |grep mbox`
do
   mysql -u root --password=$mysql_root_password -e "drop database $db"
   echo -e "Dropped $db"
done

mysql -u root --password=$mysql_root_password -e "drop database zimbra"

Remove existing InnoDB tablespace and log files

rm -rf /opt/zimbra/db/data/ib*

21. Recreate all databases from EXISTING in NEW


mysql.server restart
for db in `cat /tmp/sql-dump/mysql.db.list`
do
   mysql -e "create database $db character set utf8"
   echo "Created $db"
done

22. Repopulate NEW Databases with EXISTING data

mysql zimbra < /tmp/sql-dump/zimbra.sql
for sql in /tmp/sql-dump/mbox*
do
   mysql `basename $sql .sql` < $sql
   echo -e "Updated `basename $sql .sql` \n"
done

We now have the NEW server running as the EXISTING but without its IP addresses.

If DNS is being updated or firewall rules will open ports to the server the next steps are NOT needed. 

1. Set appropriate Firewall rules / Make DNS change

If the NEW server is replacing the EXISTING server without any changes to DNS or Firewall rules:

23. Change IP address on EXISTING to a different address: Edit /etc/sysconfig/network-scripts/ifcfg-ethx and /etc/sysconfig/network with the new IP address and Gateway

24. Change IP address on NEW: Edit /etc/sysconfig/network-scripts/ifcfg-ethx and /etc/sysconfig/network with the new IP address and Gateway

25. Restart networking on EXISTING and NEW or reboot –

/etc/init.d/network restart 

or reboot

26. Reset /etc/hosts to new IP on EXISTING and NEW.

27. Set appropriate Firewall rules, if applicable, e.g. hosts.allow / iptables

28. On NEW, as zimbra:

zmcontrol start. 

Watch log files for any errors - /opt/zimbra/log/mailbox.log /var/log/zimbra.log

Jump to: navigation, search