mysql 5.7+keepalived主從切換步驟簡述

chenfeng發表於2018-03-23
登陸從庫:
mysql>stop slave;
mysql>show slave status;
mysql> reset slave all;

mysql>show master status;  記錄此時從庫的log_file和log_pos值


登陸主庫:
修改/etc/keepalived/keepalived.conf檔案
把priority 101改為priority 99,確認主庫的priority值比從庫小
#/etc/init.d/keepalived stop
在從庫上確認虛擬IP是否漂移過去,用ip address命令確認
然後
mysql>change master to master_host='從庫ip',master_user='slave',master_password='123456',master_log_file='從庫當時記錄的log_file',master_log_pos=從庫當時記錄的log_pos值,master_connect_retry=10;
start slave;
show slave status;

啟動keepalived:
#/etc/init.d/keepalived start

至此切換完畢,在新主庫上寫入一條記錄,看看是否同步到從從庫。

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/15498/viewspace-2152147/,如需轉載,請註明出處,否則將追究法律責任。

相關文章