1.主库授权同步账户
mysql> grant all on *.* to 'rep'@'10.8.118.0/255.255.255.0' identified by '123456';
2.备份主库
mysqldump -uroot -p'trt_19970222' -B rainbow -x --master-data=2 > /opt/alldb.sql
3.过滤binlog位置点和pos位置点
grep -i 'change master' /opt/alldb.sql
CHANGE MASTER TO MASTER_LOG_FILE='binlog.000002', MASTER_LOG_POS=676493741;
4.从库恢复主库相关数据
mysql -uroot -p123456 < /opt/alldb.sql
5.从库配置主库binlog以及pos位置点
CHANGE MASTER TO MASTER_HOST='10.8.118.49', MASTER_USER='rep',MASTER_PASSWORD='123456', MASTER_LOG_FILE='binlog.000002', MASTER_LOG_POS=676493741;
6.启动从库
start slave;