现在的位置: 首页 > 综合 > 正文

丛库切换主库

2017年12月26日 ⁄ 综合 ⁄ 共 458字 ⁄ 字号 评论关闭

主库:A

A 的丛库(要切换成主库):B

A 的丛库:C

切换过程:

A操作:

flush tables with read lock 锁表

B操作:

stop slave; 停止主丛

reset master; 初使化binlog

mv /data0/mysql/3306/data/master.info /tmp

show master status; 记住binglog和POS值(假设为binlog.000001,106)

C操作:

stop slave;

reset slave;

change master to master_host = 'B(IP)',master_port = 3306,master_user = '用户名',master_password = '密码',master_log_file = 'binlog.000001',master_log_pos = 106;

start slave;启动丛库

show slave status\G;查看是否主丛同步

  Slave_IO_Running: Yes
  Slave_SQL_Running: Yes

A操作:

unlock tables 解锁

抱歉!评论已关闭.