1.在master服务器上在线备份数据库:
innobackupex --defaults-file=/etc/mysql/my.cnf --user=root --password=dbpswd.com /mnt/
innobackupex --defaults-file=/etc/mysql/my.cnf --user=root --password=dbpswd.com --databases="qs_admin" /mnt/
2.
copy 到 slave 服务器(tar包压缩下)
/opt/lib/mysql 清空所有mysql数据
2.1
恢复日志文件
innobackupex --defaults-file=/etc/mysql/my.cnf --user=root --password=dbpswd.com --apply-log /mnt/mysql20161206/2016-12-06_15-00-43
2.2
恢复数据文件
innobackupex --defaults-file=/etc/mysql/my.cnf --user=root --password=dbpswd.com --copy-back /mnt/mysql20161206/2016-12-06_15-00-43
2.3
修改权限
chown -R mysql.mysql /opt/lib/mysql/
2.4
mysqld_safe --defaults-file=/etc/mysql/my.cnf #模式启动 并查看无明显error日志
2.4
从库配置
change master to master_host='10.165.102.104',master_user='repl',master_password='qb_iqusong_com_1',master_log_file='mysql-bin.000001',master_log_pos=379096883;
start slave;
# stop slave;
show slave status\G
---备份后的文件说明
...
161206 15:23:07 Executing FLUSH NO_WRITE_TO_BINLOG ENGINE LOGS...
xtrabackup: The latest check point (for incremental): '43166555577'
xtrabackup: Stopping log copying thread.
.161206 15:23:07 >> log scanned up to (43166557200)
161206 15:23:08 Executing UNLOCK TABLES
161206 15:23:08 All tables unlocked
161206 15:23:08 Backup created in directory '/opt/backup/mysql20161206/2016-12-06_15-00-43'
MySQL binlog position: filename 'mysql-bin.000001', position '379096883'
161206 15:23:08 [00] Writing backup-my.cnf
161206 15:23:08 [00] ...done
161206 15:23:08 [00] Writing xtrabackup_info
161206 15:23:08 [00] ...done
xtrabackup: Transaction log of lsn (43164896387) to (43166557200) was copied.
161206 15:23:08 completed OK!
----