sys@172.99.0.32:(none) 17:54:52>show processlist; +-------+------------+-------------------+------+-------------+--------+-----------------------------------------------------------------------+------------------+----------+ | Id | User | Host | db | Command | Time | State | Info | Progress | +-------+------------+-------------------+------+-------------+--------+-----------------------------------------------------------------------+------------------+----------+ | 11679 | rep | 172.99.0.31:8609 | NULL | Binlog Dump | 279575 | Master has sent all binlog to slave; waiting for binlog to be updated | NULL | 0.000 | +-------+------------+-------------------+------+-------------+--------+-----------------------------------------------------------------------+------------------+----------+ 3 rows in set (0.00 sec)
查看从库是否可以做主库
主要是查看bin-log是否打开,结论:31服务器可以作为主库
1 2 3 4 5 6 7
sys@172.99.0.31:(none) 17:57:01>show master status; +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000153 | 2786181 | | | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec)
BEGIN /*!*/; # at 132131716 # at 132131807 #220317 15:00:00 server id 533307 end_log_pos 132131807 Table_map: `db`.`job_log` mapped to number 54116 #220317 15:00:00 server id 533307 end_log_pos 132132243 Update_rows: table id 54116 flags: STMT_END_F ### UPDATE `db`.`job_log` ### WHERE ### @1=14424 ### @2='detail_NoticeJob' ### @3='0 0 1,10,15,21 * * ?' ### @4='com.hello.lease.job.NoticeJob' ### @5='通知-每日1、10、15、21点' ### @6='start' ### @7=0 ### @8='系统操作' ### @9=2022-03-17 15:00:00 ### @10=1647500400 ### SET ### @1=14424 ### @2='detail_NoticeJob' ### @3='0 0 1,10,15,21 * * ?' ### @4='com.hello.lease.job.NoticeJob' ### @5='通知-每日1、10、15、21点' ### @6='end' ### @7=0 ### @8='系统操作' ### @9=2022-03-17 15:00:00 ### @10=1647500400 # at 132132243 #220317 15:00:00 server id 533307 end_log_pos 132132270 Xid = 49158632 COMMIT/*!*/; # at 132132270
进行主从切换
验证31上是否有主从复制的用户
如果没有需要新建
1 2 3 4 5 6 7
sys@172.99.0.31:mysql 16:07:25>select user,host from user where user='rep'; +----------+------+ | user | host | +----------+------+ | rep | % | +----------+------+ 1 row in set (0.00 sec)
停掉31的主从复制
1 2 3 4 5 6
# 停止同步 stop slave; # 重置同步:https://mariadb.com/kb/en/reset-replica/ RESET SLAVE; # 验证同步状态 show slave status \G