首页 > 技术文章 > mysql 案例~ 主从复制转化为级联复制

danhuangpai 2017-12-27 13:54 原文

一 需求 mysql 主从复制切换成级联复制
二 核心思想 1 开启级联复制 2 确定postion点
场景 A->B A-C
三 切换步骤
  1 先确定好B为级联复制库
  2 B添加log_update_slave=1
  3 查看从库B上的Exec_Master_Log_Pos是否已经大于从库C上的Exec_Master_Log_Pos,如果大于,则执行stop slave停掉从库B的复制
    show slave status 记录
   1 Relay_Master_Log_File
   2 Exec_Master_Log_Pos
   show master status 记录
   1 File
   2 Position
 5 B 执行 start slave
 6 C 执行 start slave UNTIL MASTER_LOG_FILE ='Relay_Master_Log_File', MASTER_LOG_POS =Exec_Master_Log_Pos;
 7 C 执行 stop slave
 8 C 执行 CHANGE MASTER TO MASTER_HOST='B',MASTER_USER='repl', MASTER_PASSWORD='repl',MASTER_LOG_FILE=File,MASTER_LOG_POS=Position
 9 C 执行 start slave
10 C 执行 show slave status查看状态,切换完成
四 总结 核心就是 B和C 要在某一点取得一致性,也可以通过主库制造同步错误完成

就是这样,纠结了很久终于弄明白了

推荐阅读