|This article applies to the following ZCS versions.|
YAMM = Yet Another Migration Method
Scenario: You need to do a ZCS to ZCS migration to another new machine. Most likely, when you install ZCS onto the new machine, it will be an independent machine with it's own IP; be sure to pay special attention to this step http://wiki.zimbra.com/wiki/King0770-Notes-YAMM#Import_ldap_data_from_the_new_machine.
Summary of steps
- Export ldap and mysql data from the production server
- Prepare the new server
- Import ldap and mysql data into the new server
- Bring new server up to current
- 1 Section I - Export ldap and mysql data from the production machine
- 2 Section II - Prepare the new server
- 3 Section III - Import ldap and mysql data into the new server
- 4 Section IV - Bring the new server up to current
- 5 Section V - Other YAMM's
Section I - Export ldap and mysql data from the production machine
It might help to create a directory to store the exported data.
source ~/bin/zmshutil; zmsetvars ~/mysql/bin/mysqldump -u root --password=$mysql_root_password --socket=$mysql_socket --all-databases --single-transaction >> /tmp/migration/mysqlinfo.sql mysql --batch --skip-column-names -e "show databases" | grep -e mbox -e zimbra > /tmp/migration/mysql.db.list
Observe the redolog sequence numbers
For NE machines, pay special attention to the redo log sequence numbers in the /opt/zimbra/redolog directory. This will become apparent in Section IV.
Example: -rw-r----- 1 zimbra zimbra 3642053 Jul 21 01:00 redo-20100721.070012.453-seq369.log -rw-r----- 1 zimbra zimbra 3895609 Jul 21 13:02 redo-20100721.190239.483-seq370.log -rw-r----- 1 zimbra zimbra 35389 Jul 21 13:09 redo-20100721.190935.884-seq371.log -rw-r----- 1 zimbra zimbra 30367 Jul 21 13:22 redo-20100721.192247.964-seq372.log
Section II - Prepare the new server
Highly recommend that the new machine use the same ZCS version as the production machine.
Install ZCS onto the new machine
Make sure to install the same ZCS packages.
After the install, make sure you use the same ldap and mysql passwords from the production machine. To view the passwords from the production machine, run the following command:
zmlocalconfig -s | grep pass | grep -e ldap -e mysql
Use the following tools on the new machine to change the ldap & mysql passwords:
zmldappasswd zmmypasswd **After the password changes, restart ZCS services on the new machine.**
Don't forget to install the same zimlets, and don't forget your custom changes.
Section III - Import ldap and mysql data into the new server
Copy the ldap & mysql data from the production server
rsync -av -e ssh email@example.com:/tmp/migration /tmp/
Drop mysql DB's
source ~/bin/zmshutil; zmsetvars for db in `mysql --batch --skip-column-names -e "show databases" | grep -e ^mbox -e zimbra`; do mysql -u root --password=$mysql_root_password -e \ "drop database $db"; echo -e "Dropped $db"; done
Create the necessary DB's
for db in `cat /tmp/migration/mysql.db.list`; do mysql -e "create database $db character set utf8"; echo "created $db"; done
Import production mysql data into the new machine
mysql < /tmp/migration/mysqlinfo.sql
Import ldap data from the new machine
ldap stop cd /opt/zimbra/data/ldap mv hdb OLD.hdb mkdir -p hdb/db; mkdir hdb/logs ~/openldap/sbin/slapadd -q -b "" -F /opt/zimbra/data/ldap/config -cv -l /tmp/migration/ldap.bak **Most likely, you will need to edit the ldap.bak file and replace the production server name with the new server name**
Copy store and index files from the production machine to the new machine
rm -rf /opt/zimbra/store/* rsync -av -e ssh firstname.lastname@example.org:/opt/zimbra/store/ /opt/zimbra/store/ rm -rf /opt/zimbra/index/* rsync -av -e ssh email@example.com:/opt/zimbra/index/ /opt/zimbra/index/
Section IV - Bring the new server up to current
As a last minute effort before going live, do the following to bring the new machine up to current. If the production server is busy during the migration, we'll need to play the redo logs after the initial syncing of the data between the production machine, and the new machine.
For an example, before the migration, look in the redolog/archive directory in the production server. Should look something like this, as noted in step 1.3.
-rw-r----- 1 zimbra zimbra 3642053 Jul 21 01:00 redo-20100721.070012.453-seq369.log -rw-r----- 1 zimbra zimbra 3895609 Jul 21 13:02 redo-20100721.190239.483-seq370.log -rw-r----- 1 zimbra zimbra 35389 Jul 21 13:09 redo-20100721.190935.884-seq371.log -rw-r----- 1 zimbra zimbra 30367 Jul 21 13:22 redo-20100721.192247.964-seq372.log
After rsync'ing the store and index directories, you will want to play the redo logs that are higher than redo-20100721.192247.964-seq372.log. Basically you are playing the redo logs from the production machine that were generated after the initial sync, which means you would need to play the redo logs that are numerically higher in sequence.
zmmailboxdctl stop rsync -av -e ssh firstname.lastname@example.org:/opt/zimbra/redolog /opt/zimbra/redolog/ cd /opt/zimbra/redolog/archive zmplayredo --logfiles redo-20100721.214014.840-seq373.log cd /opt/zimbra/redolog zmplayredo --logfiles redo.log zmmailboxctld start
Section V - Other YAMM's
Other migration articles that maybe of interest to you.
Note: These are ZCS to ZCS migrations.