Jephe Wu - http://linuxtechres.blogspot.com
Objective: use Xtrabackup from Percona server 5.5 to online create slave database from master.
Environment: CentOS 6.4 64bit, Percona server 5.5 for both master(192.168.0.1) and slave(192.168.0.2), almost same hardware specs for master and slave
Steps:
1. Backup from master
# innobackupex --user=root --password=password /data/cloneforslave/ --no-timestamp
(innobackupex will create /data/cloneforslave folder automatically)
# xtrabackup --prepare --target-dir=/data/cloneforslave/
# cd /data/cloneforslave
# more xtrabackup_binlog_info
mysql-bin.129290 14072915
2. transfer to slave
#rsync --progress -avz /data/cloneforslave/ slaveserver:/data/cloneforslave --delete
(create /data/cloneforslave directory first on slaveserver)
3. Prepareing slave
cd /var/lib/mysql/
mv data data.old
cp /data/cloneforhmspzdb05 /var/lib/mysql/data -va
chown mysql:mysql -R data
vi /etc/my.cnf # to change server_id from 1 to 2, optional you can add read-only parameter
/etc/init.d/mysql start
4. setting up slave
mysql -uroot -ppassword zabbix
mysql> stop slave;
mysql> reset slave;
mysql> change master to master_host='192.168.0.1', master_user='replication', master_password='replication_password', master_log_file='mysql-bin.129290', master_log_pos=14072915;
mysql> start slave
mysql> show slave status\G
5.References
http://www.percona.com/doc/percona-xtrabackup/2.1/howtos/setting_up_replication.html
mysql tuning tool: tuning-primer.sh
Preparing mysql slave database by online cloning Percona master database server
Labels: mysql, percona, xtrabackup