1.查看slave数据库是否有数据更新
1)在master执行:show processlist;
显示Master has sent all binlog to slave; waiting for binlog to be updated
2)在slave执行:show processlist;
显示Slave has read all relay log; waiting for the slave I/O thread to update it
mysql> show slave status \G;
检查IO及SQL线程是否正常,如果为NO表明同步不一致,需要重新将slave同步保持主从数据一致。
SLAVE:
stop slave;
show slave status\G ----->no,no
reset slave all;
systemctl stop mysql --在主停止之後
查看slave是否只读模式:show variables like 'read_only';
只读模式需要修改my.cnf文件,注释read-only=1并重启mysql服务。
備份當前my.cnf并從主庫複製my.cnf,複製當前配置文件至主庫
mv /etc/my.cnf /etc/my.cnf.slave.old
scp root@xxx:/etc/my.cnf /etc/my.cnf --注意server-id、binlog、relay-log、read-only參數
systemctl start mysql
grant replication slave on *.* to 'repl'@'xxx.xxx.xxx.xxx' identified by 'xxx'
show master status\G; --查看binlog日誌位置和pos
MASTER:
reset master;
systemctl stop mysql
mv /etc/my.cnf /etc/my.cnf.master.old
scp /etc/my.cnf root@10.67.38.91:/etc/my.cnf
systemctl start mysql
change master to master_host='xxx.xxx.xxx.xxx',master_port=3306,master_user='repl',master_password='repl123',master_log_file='ostjombidb02-bin.000001',master_log_pos=000001;
start slave;
show slave status\G;
网友评论