修改my.cnf ,开启二进制日志功能
sync_binlog=1
binlog_format=row
grant replication slave on *.* to repl@‘10.0.0.%‘ identified by ‘123456‘;
select user,host from mysql.user;
mkdir /data/backup/
mysqldump -S /tmp/mysql.sock -A --master-data=2 --single-transaction -R -E --triggers > /data/backup/full.sql
#从库恢复
db02 [(none)]>source full.sql;
[root@linux-node1 ~]# grep -e ‘-- CHANGE MASTER‘ /data/backup/full.sql
-- CHANGE MASTER TO MASTER_LOG_FILE=‘mysql-bin.000007‘, MASTER_LOG_POS=967;
CHANGE MASTER TO
MASTER_HOST=‘10.0.0.12‘,
MASTER_USER=‘repl‘,
MASTER_PASSWORD=‘123456‘,
MASTER_PORT=3306,
MASTER_LOG_FILE=‘mysql-bin.000007‘,
MASTER_LOG_POS=967,
MASTER_CONNECT_RETRY=10;
db02 [test01]>start slave;
db02 [test01]>show slave status\G;
Slave_IO_Running: Yes
Slave_SQL_Running: Yes
原文:https://www.cnblogs.com/wangxiang135/p/13321483.html