alias my3306='export MYSQL_HOME=/data/mysql3306/' alias my3307='export MYSQL_HOME=/data/mysql3307/' alias my3308='export MYSQL_HOME=/data/mysql3308/' alias my3309='export MYSQL_HOME=/data/mysql3309/' alias dbasql='mysql -uroot -proot' alias nsql='mysql ' alias alert='tail -100f $MYSQL_HOME/log/alert.log'
ruiayLinSunny at ruiayLinSunnydeMacBook-Pro-2 in ~ $ mysqlrplcheck --master=root:root@127.0.0.1:3306 --slave=root:root@127.0.0.1:3307 -s # master on 127.0.0.1: ... connected. # slave on 127.0.0.1: ... connected. Test Description Status --------------------------------------------------------------------------- Checking for binary logging on master [pass] Are there binlog exceptions? [pass] Replication user exists? [pass] Checking server_id values [pass] Checking server_uuid values [pass] Is slave connected to master? [pass] Check master information file [pass] Checking InnoDB compatibility [pass] Checking storage engines compatibility [pass] Checking lower_case_table_names settings [pass] Checking slave delay (seconds behind master) [pass]
检查复制健康状态:
1
mysqlrpladmin --master=root:root@127.0.0.1:3306 --slave=root:root@127.0.0.1:3307 health
—>: 检查日志
1 2 3 4 5 6 7 8 9 10
$ mysqlrpladmin --master=root:root@127.0.0.1:3306 --slave=root:root@127.0.0.1:3307 health # Checking privileges. # # Replication Topology Health: +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | 127.0.0.1 | 3306 | MASTER | UP | ON | OK | | 127.0.0.1 | 3307 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+
MySQL Replication Failover Utility Failover Mode = auto Next Interval = Sat May 31 16:05:59 2014
Master Information ------------------ Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB binlog.000009 191
GTID Executed Set dd1f65aa-e2d0-11e3-89e3-7f8d49c2f173:1-14
Replication Health Status +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | 127.0.0.1 | 3306 | MASTER | UP | ON | OK | | localhost | 3307 | SLAVE | UP | ON | OK | | localhost | 3308 | SLAVE | UP | ON | OK | | localhost | 3309 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+
### mysqlfailover --master=root:root@127.0.0.1:3306 --candidates=root:root@127.0.0.1:3307 --discover-slaves-login=root:root Master Information ------------------ Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB binlog.000008 191
GTID Executed Set dd1f65aa-e2d0-11e3-89e3-7f8d49c2f173:1-14
Master GTID Executed Set +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | 127.0.0.1 | 3306 | MASTER | UP | ON | OK | | localhost | 3307 | SLAVE | UP | ON | OK | | localhost | 3308 | SLAVE | UP | ON | OK | | localhost | 3309 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+
Q-quit R-refresh H-health G-GTID Lists U-UUIDs Failed to reconnect to the master after 3 attemps.
Failover starting in 'auto' mode... # Candidate slave 127.0.0.1:3307 will become the new master. # Checking slaves status (before failover). # Preparing candidate for failover. # Creating replication user if it does not exist. # Stopping slaves. # Performing STOP on all slaves. # Switching slaves to new master. # Disconnecting new master as slave. # Starting slaves. # Performing START on all slaves. # Checking slaves for errors. # Failover complete. # Discovering slaves for master at 127.0.0.1:3307 Failover console will restart in 5 seconds.
Q-quit R-refresh H-health G-GTID Lists U-UUIDs # Discovering slaves for master at 127.0.0.1:3307 MySQL Replication Failover Utility Failover Mode = auto Next Interval = Sat May 31 15:01:00 2014 Master Information ------------------ Binary Log File Position Binlog_Do_DB Binlog_Ignore_DB binlog.000005 191
GTID Executed Set dd1f65aa-e2d0-11e3-89e3-7f8d49c2f173:1-14
Master GTID Executed Set +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | 127.0.0.1 | 3307 | MASTER | UP | ON | OK | | localhost | 3308 | SLAVE | UP | ON | OK | | localhost | 3309 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+
GTID Executed Set dd1f65aa-e2d0-11e3-89e3-7f8d49c2f173:1-14 Master GTID Executed Set +------------+-------+---------+--------+------------+---------+ | host | port | role | state | gtid_mode | health | +------------+-------+---------+--------+------------+---------+ | 127.0.0.1 | 3307 | MASTER | UP | ON | OK | | localhost | 3306 | SLAVE | UP | ON | OK | | localhost | 3308 | SLAVE | UP | ON | OK | | localhost | 3309 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+
ruiayLinSunnydeMacBook-Pro-2:~ root# mysqlrpladmin --master=root:root@127.0.0.1:3307 --new-master=root:root@127.0.0.1:3306 --discover-slaves-login=root:root --demote-master switchover # Discovering slaves for master at 127.0.0.1:3307 # Discovering slave at localhost:3306 # Found slave: localhost:3306 # Discovering slave at localhost:3308 # Found slave: localhost:3308 # Discovering slave at localhost:3309 # Found slave: localhost:3309 # Checking privileges. # WARNING: You may be mixing host names and IP addresses. This may result in negative status reporting if your DNS services do not support reverse name lookup. # Performing switchover from master at 127.0.0.1:3307 to slave at 127.0.0.1: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 | +------------+-------+---------+--------+------------+---------+ | 127.0.0.1 | 3306 | MASTER | UP | ON | OK | | 127.0.0.1 | 3307 | SLAVE | UP | ON | OK | | localhost | 3308 | SLAVE | UP | ON | OK | | localhost | 3309 | SLAVE | UP | ON | OK | +------------+-------+---------+--------+------------+---------+ # ...done.