天天看點

replication監控及自動故障切換

replication監控及自動故障切換

automatic replication health monitoring and failover

 先下載下傳安裝包:

http://dev.mysql.com/downloads/

MySQL Utilities (GPL)

MySQL Connectors   中間件

yum  install Utilities  Connectors

實驗環境:

step1:配置好兩台replication環境,一台master 兩台slave、

step2:在所有被監控機器為監控機授權:

grant create,insert,drop,select,super,replication slave,reload on *.*  to 'repl'@'192.168.1.211'(monitior server) identified by  '123456' with grant option;

grant create,insert,drop,select,super,replication slave,reload on *.*  to 'repl'@'192.168.1.211' identified by  '123456' with grant option;

step3: 修改三台機器的配置檔案,并啟用配置

[mysqld]

log-bin

gtid-mode=on

binlog-format=row

log-slave-updates=1

enforce-gtid-consistency

server-id=3

report-host=192.168.1.211 (本機的ip)   

master-info-repository=TABLE   将replication緩存檔案儲存到table中

relay-log-info-repository=TABLE

/etc/init.d/mysqld restart

step4:

啟動監控端:

--master=使用者名:密碼

mysqlfailover --master=repl:[email protected](master機器) --discover-slaves-login=repl:123456

模拟故障:

1,假如master挂了,slave會自動切換到master,另一個slave也會自動指向新的master

2,資料還可以正常同步

3,如果原先的master啟動,failover 是不能自動發現,并且想要回到到原來的狀态,需要手動操作。

在原master啟動後,

重新change master  to 

  change master to

  master_host='192.168.20.238',

  master_user='repl',

  master_password='123456',

  master_auto_position=1;

in 237(新的master 授權舊的master作為slave連接配接,并授權另一個也可以連接配接過來)

grant replication slave on *.* to [email protected] identified by '123456';

grant replication slave on *.* to [email protected] identified by '123456';     無論誰是master 都可以取二進制日志

flush privileges;

      本文轉自crazy_charles 51CTO部落格,原文連結http://blog.51cto.com/douya/1607395:,如需轉載請自行聯系原作者

繼續閱讀