King0770-Notes-YAMM
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
Section I - Export ldap and mysql data from the production machine
It might help to create a directory to store the exported data.
mkdir /tmp/migration
Export LDAP
~/libexec/zmslapcat /tmp/migration
Export MYSQL
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
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
<zcs_install_directory>./install.sh
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 root@production.domain.com:/tmp/migtration /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 root@production.domain.com:/opt/zimbra/store/ /opt/zimbra/store/
rsync -av -e ssh root@production.domain.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. You should sync over the blobs again, and play the redo log.
rsync -av -e ssh --delete root@production.domain.com:/opt/zimbra/store/ /opt/zimbra/store
rsync -av -e ssh root@production.domain.com:/opt/zimbra/redolog /opt/zimbra/redolog/
cd /opt/zimbra/redolog
zmmailboxctld stop
zmplayredo --logfiles redo.log
zmmailboxctld start