[root@mysql56-master home]# mysqlfailover --master=root:root@192.168.1.131:3306 --discover-slaves-login=root:root
# Discovering slaves for master at 192.168.1.131:3306
# Discovering slave at 192.168.1.132:3306
# Found slave: 192.168.1.132:3306
# Discovering slave at 192.168.1.133:3306
# Found slave: 192.168.1.133:3306
# Checking privileges.
MySQL Replication Failover Utility
Failover Mode = auto Next Interval = Tue May 14 12:27:56 2013
Master Information
------------------
Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB
mysql56-master-bin.0 151 mysql
GTID Executed Set
None
Replication Health Status
+----------------+-------+---------+--------+------------+-------------------------------------------+
| host | port | role | state | gtid_mode | health |
+----------------+-------+---------+--------+------------+-------------------------------------------+
| 192.168.1.131 | 3306 | MASTER | UP | ON | OK |
| 192.168.1.132 | 3306 | SLAVE | UP | ON | OK |
| 192.168.1.133 | 3306 | SLAVE | UP | ON | Binary log and Relay log filters differ. |
+----------------+-------+---------+--------+------------+-------------------------------------------+
Q-quit R-refresh H-health G-GTID Lists U-UUIDs
[root@mysql56-master home]#
5. mysqlrpladmin. 对主从进行管理。
停止从机服务:
[root@mysql56-master home]# mysqlrpladmin --master=root:root@192.168.1.131:3306 --slaves=root:root@192.168.1.132:3306,root:root@192.168.1.133:3306 stop
# Checking privileges.
# Performing STOP on all slaves.
# Executing stop on slave 192.168.1.132:3306 Ok
# Executing stop on slave 192.168.1.133:3306 Ok
# ...done.
[root@mysql56-master home]#
开启从机服务:
[root@mysql56-master home]# mysqlrpladmin --master=root:root@192.168.1.131:3306 --slaves=root:root@192.168.1.132:3306,root:root@192.168.1.133:3306 stop
# Checking privileges.
# Performing STOP on all slaves.
# Executing stop on slave 192.168.1.132:3306 Ok
# Executing stop on slave 192.168.1.133:3306 Ok
# ...done.
[root@mysql56-master home]#
选择最好的备机准备以后切换用.
[root@mysql56-master home]# mysqlrpladmin --master=root:root@192.168.1.131:3306 --slaves=root:root@192.168.1.132:3306,root:root@192.168.1.133:3306 elect
# Checking privileges.
# Electing candidate slave from known slaves.
# Best slave found is located on 192.168.1.132:3306.
# ...done.
[root@mysql56-master home]#
进行主从切换。
[root@mysql56-master home]# mysqlrpladmin --master=root:root@192.168.1.131:3306 --slaves=root:root@192.168.1.132:3306,root:root@192.168.1.133:3306 --new-master=root:root@192.168.1.132:3306 --demote-master switchover
# Checking privileges.
# Performing switchover from master at 192.168.1.131:3306 to slave at 192.168.1.132:3306.
# Checking candidate slave prerequisites.
# Checking slaves configuration to master.
# Waiting for slaves to catch up to old master.
# Stopping slaves.
# Performing STOP on all slaves.
# Demoting old master to be a slave to the new master.
# Switching slaves to new master.
# Starting all slaves.
# Performing START on all slaves.
# Checking slaves for errors.
# Switchover complete.
#
# Replication Topology Health:
+----------------+-------+---------+--------+------------+-----------------------------+
| host | port | role | state | gtid_mode | health |
+----------------+-------+---------+--------+------------+-----------------------------+
| 192.168.1.132 | 3306 | MASTER | UP | ON | OK |
| 192.168.1.131 | 3306 | SLAVE | UP | ON | OK |
| 192.168.1.133 | 3306 | SLAVE | UP | ON | OK |
+----------------+-------+---------+--------+------------+-----------------------------+
# ...done.
[root@mysql56-master home]#