1、创建完整备份
[mysql@mysql1 ~]$ /data/mysqldata/scripts/mysql_full_backup_by_xtra.sh
2、复制和准备备份集
[mysql@mysql1 mysql_full]$ scp xtra_fullbak_2014-07-10.tar.gz 192.168.1.202:`pwd`
[mysql@mysql2 3307]$ mkdir binlog tmp data
[mysql@mysql2 mysql_full]$ tar xivfz xtra_fullbak_2014-07-10.tar.gz -C /data/mysqldata/3307/data
准备数据,执行innobackupex命令附加--apply-log参数
[mysql@mysql2 ~]$ innobackupex --apply-log /data/mysqldata/3307/data
3、创建复制环境专用账户
(system@localhost) [(none)]> grant replication slave on *.* to 'rep1'@'192.168.1.%' identified by 'rep1';
4、配置Slave节点初始化参数文件
[mysql@mysql1 3306]$ scp my.cnf 192.168.1.202:/data/mysqldata/3307/
修改server_id选项值
[mysql@mysql2 3307]$ sed -i 's/3306/3307/g' my.cnf
[mysql@mysql2 ~]$ mysql_db_startup.sh 3307
5、配置Slave节点复制环境
[mysql@mysql2 data]$ more /data/mysqldata/3307/data/xtrabackup_binlog_info
mysql-bin.000008 2713 查看Master节点二进制日志文件的序号和LSN
[mysql@mysql2 ~]$ mysql_db_startup.sh 3307
[mysql@mysql2 ~]$ mysql -usystem -p123456 -S /data/mysqldata/3307/mysql.sock
(system@localhost) [(none)]> prompt Slave >
Slave > change master to
-> master_host='192.168.1.201',
-> master_port=3306,
-> master_user='rep1',
-> master_password='rep1',
-> master_log_file='mysql-bin.000008',
-> master_log_pos=2713;
innobackupex命令支持一个叫名—slave-info的参数,指定该参数创建的备份集中,会包含一个名为xtrabackup_slave_info的文件,这个文件中直接提供好了CHANGE MASTER TO … 语句
启动Slave服务
Slave > start slave;
6、检查
注意关闭两端的防火墙
Slave > show slave status\G