mysqlfailover 是mysql utilities工具包中包含的一个重要的高可用命令,用于对主从复制架构进行健康检测以及实现故障自动转移。它会定期按指定的时间间隔探测各节点的健康状态,一旦在捕获到主节点不可用时,将触发故障转移相关动作,自动执行故障切换到当前最佳的从服务器上。同时整个主从架构内的其他从节点将指向新的主节点,自动完成主从拓扑结构更新。

相关知识点热身
基于mysqldump搭建gtid主从
MySQL GTID 错误处理汇总
配置MySQL GTID 主从复制
使用mysqldump导出数据库

一、mysqlfailover特点

    持续监控主从主从拓扑结构健康状况,当主节点不可用时,触发自动故障转移支持GTID全局事务标识符,传统主从模式不支持支持设置故障转移首选及备选节点,支持投票选举方式选择新的主节点以及仅监测模式(不切换主从)支持自定义时间监测间隔支持交互模式以及守护进程的模式开启mysqlfailover支持在切换前或切换后执行指定的脚本支持操作记录到日志不同的粒度以及日志老化

二、mysqlfailover需求

    主从需要开启GTID模式(mysql 应使用5.6.5以上版本)    所有的slave端需要配置以下参数,建议主库也添加(切换后主从模式变化)report-hostreport-portmaster-info-repository=TABLErelay-log-info-repository=TABLE权限(mysqlfailover工具检测及切换期间需要,主从都需要)SHOW SLAVE STATUSSHOW MASTER STATUSSTOP SLAVE, START SLAVE, WAIT_UNTIL_SQL_THREAD_AFTER_GTIDS, CHANGE MASTER TOREPLICATE SLAVESUPER, GRANT OPTION, RELOAD, DROP, CREATE, INSERT ,SELECT权限

三、一些重要参数

    --failover-mode(转移模式)auto:执行故障自动转移到第一候选人。如果没有从可行的,继续从从列表中找到一个可行的候选者。如果没有从被认为是一个可行的候选者,该程序将生成错误并退出。一旦候选者被发现,该程序将进行故障切换到最佳从上。该命令测试每个候选从的先决条件。一旦候选从被选中,其他从作为它的从,收集其他从的任何事务交易。该方式,确保候选者是最新的从elect:这种模式与aoto一样的,除了如果在指定的候选从列表中没有可行的,不检测剩余的从和产生错误并退出。fail: 这种模式会产生一个错误,当主失败后不会进行故障转移。这种模式被用来只进行定期健康监测不进行故障切换。--interval选项来定义检测主状态和产生健康报告的时间间隔,缺省为15s,最小间隔为5s--master=MASTER主服务器连接配置--slaves=SLAVES从服务器连接配置--candidates=CANDIDATES候选服务器连接配置以上3个连接配置值支持是使用下列方式,多个值以逗号分割<user>[:<password>]@<host>[:<port>][:<socket>] <login-path>[:<port>][:<socket>]<config-path>[<[group]>]    --discover-slaves-login=DISCOVER基于主服务器用户密码查询当前所有注册到主服务器的从库端使用<user>[:<password>] or <login-path>--ping=PING  Number of ping attempts for detecting downed server.     侦测服务器宕机检测,缺省为3s--force   override the registration check on master for multipleinstances of the console monitoring the same master.当控制台启动时,主的主机名和端口将被插入一个特殊的表来跟踪记录哪些实例与主联系 在启动时,如果行匹配这些值,控制台无法启动。如果使用--force选项,该行将被删除                                  --daemon(使用守护进程方式,如未指定,则为交互方式)start    启动守护进程。需要--log选项。stop     停止守护进程。如果有指定--pidfile选项,该值需要与start指定的一致。restart  重新启动守护进程。如果有指定--pidfile选项,该值需要与start指定的一致。nodetach 启动守护进程,但是不会从控制台分离进程。需要--log选项。--log=<log_file> 指定日志文件--log-age 选项用于指定日志存放天数,默认是7天。旧的日志自动轮滚掉--exec-before故障转移命令之前执行外部脚本脚本的返回码来确定是否成功执行,0表示成功,非0表示失败并返回错误信息--exec-after故障转移命令之后执行外部脚本脚本的返回码来确定是否成功执行,0表示成功,非0表示失败并返回错误信息-p, --pedantic        fail if some inconsistencies are found (e.g. erranttransactions on slaves).            在检查期间如果发现有不一致的情况(从错误的事务或SQL线程错误)阻止故障转移。

四、搭建GTID主从

1、演示环境

# more /etc/redhat-release
CentOS release 6.7 (Final)# more /etc/hosts
192.168.1.233 node233.edq.com node233  ###用作主节点
192.168.1.245 node245.edq.com node245  ###用作从节点Slave1
192.168.1.247 node247.edq.com node247  ###用作从节点Slave2# mysql -V
mysql  Ver 14.14 Distrib 5.6.30, for linux-glibc2.5 (x86_64) using  EditLine wrapper# mysqlfailover --version
MySQL Utilities mysqlfailover version 1.6.4
License type: GPLv2

2、主从节点参数配置

======================192.168.1.233 Master========================
[mysql]
#prompt= (\u@\h)[\d]>
prompt= (\u@192.168.1.233)[\d]>
user=root
password=pass[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLESbasedir = /usr/local/mysql
datadir = /dataserver_id=233
gtid_mode=on
enforce_gtid_consistency=on#binlog
log_bin=node233-binlog
log-slave-updates=1
binlog_format=row
report_host=192.168.1.233
report_port=3306
master-info-repository = TABLE
relay-log-info-repository = TABLE
#relay log
skip_slave_start=1======================192.168.1.245 Slave1========================
[mysql]
prompt= (\u@192.168.1.245)[\d]>
user=root
password=pass[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
basedir = /usr/local/mysql
datadir = /dataserver_id=245
gtid_mode=on
enforce_gtid_consistency=on  log_bin=node245-binlog
log-slave-updates=1
binlog_format=row
report_host=192.168.1.245
report_port=3306
master-info-repository = TABLE
relay-log-info-repository = TABLE
skip_slave_start=1     ======================192.168.1.247 Slave2========================
[mysql]
prompt= (\u@192.168.1.247)[\d]>
user=root
password=pass[mysqld]
sql_mode=NO_ENGINE_SUBSTITUTION,STRICT_TRANS_TABLES
basedir = /usr/local/mysql
datadir = /data
user = mysql #Author : Leshami
#Blog   : http://blog.csdn.net/leshamiserver_id=247
gtid_mode=on
enforce_gtid_consistency=onlog_bin=node247-binlog
log-slave-updates=1
binlog_format=row
report_host=192.168.1.247
report_port=3306
master-info-repository = TABLE
relay-log-info-repository = TABLE
skip_slave_start=1 

3、开启主从节点

--创建主从复制(repl)及切换账户(failover)
--以下mysql提示符下Master即代表1.233节点执行,Slave1代表1.245上执行,Slave2代表1.247上执行
(root@Master)[mysql]>grant all privileges on *.* to 'failover'@'%' identified by 'pass' with grant option;(root@Master)[mysql]>grant replication slave on *.* to 'repl'@'%' identified by '123456';(root@Slave1)[(none)]>grant all privileges on *.* to 'failover'@'%' identified by 'pass' with grant option;(root@Slave1)[(none)]>grant replication slave on *.* to 'repl'@'%' identified by '123456';(root@Slave2)[(none)]>grant all privileges on *.* to 'failover'@'%' identified by 'pass' with grant option;(root@Slave2)[(none)]>grant replication slave on *.* to 'repl'@'%' identified by '123456';--主节点上执行相应的操作
[root@node233 ~]# mysql -uroot -ppass -e "create database testdb;create database tempdb"
[root@node233 ~]# mysql -uroot -ppass -e "create table testdb.repl(id int,ename varchar(50))"
[root@node233 ~]# mysql -uroot -ppass -e "insert into testdb.repl values(1,'leshami')"
[root@node233 ~]# mysql -uroot -ppass -e "select * from testdb.repl"
+------+---------+
| id   | ename   |
+------+---------+
|    1 | leshami |
+------+---------+

4、将数据同步到从节点并开启同步

[root@node233 ~]# mysqldump --all-databases --single-transaction --triggers --routines --events \
> --host=localhost --port=3306 --user=root --password=pass >/tmp/alldb.sql [root@node233 ~]# scp /tmp/alldb.sql 192.168.1.245:/tmp
[root@node233 ~]# scp /tmp/alldb.sql 192.168.1.247:/tmp(root@Slave1)[testdb]>reset master;(root@Slave1)[(none)]>source /tmp/alldb.sql(root@Slave1)[testdb]>CHANGE MASTER TO
    -> MASTER_HOST='192.168.1.233',
    -> MASTER_USER='rpl',
    -> MASTER_PASSWORD='rpl',
    -> MASTER_PORT=3306,
    -> MASTER_AUTO_POSITION = 1;
Query OK, 0 rows affected, 2 warnings (0.06 sec)(root@Slave1)[testdb]>start slave;(root@Slave2)[(none)]>reset master;(root@Slave2)[(none)]>source /tmp/alldb.sql(root@Slave2)[testdb]>CHANGE MASTER TO
    -> MASTER_HOST='192.168.1.233',
    -> MASTER_USER='rpl',
    -> MASTER_PASSWORD='rpl',
    -> MASTER_PORT=3306,
    -> MASTER_AUTO_POSITION = 1;
Query OK, 0 rows affected, 2 warnings (0.02 sec)(root@Slave2)[testdb]>start slave;--分别在245及247节点上验证
[root@node245 mysql]# mysql -uroot -p -e "select * from testdb.repl"
Enter password:
+------+---------+
| id   | ename   |
+------+---------+
|    1 | leshami |
+------+---------+[root@node247 mysql]# mysql -uroot -p -e "select * from testdb.repl"
Enter password:
+------+---------+
| id   | ename   |
+------+---------+
|    1 | leshami |
+------+---------+--使用mysqlrplshow查看主从结构
[root@node233 ~]# mysqlrplshow --master=failover:pass@'192.168.1.233':3306 --discover-slaves-login=failover:pass --verbose
WARNING: Using a password on the command line interface can be insecure.
# master on 192.168.1.233: ... connected.
# Finding slaves for master: 192.168.1.233:3306# Replication Topology Graph
192.168.1.233:3306 (MASTER)
   |
   +--- 192.168.1.245:3306 [IO: Yes, SQL: Yes] - (SLAVE)
   |
   +--- 192.168.1.247:3306 [IO: Yes, SQL: Yes] - (SLAVE)

五、mysqlfailover切换

1、非守护进程方式启动mysqlfailover查看主从

[root@node233 ~]# mysqlfailover --master=failover:pass@'192.168.1.233':3306 --discover-slaves-login=failover:pass
WARNING: Using a password on the command line interface can be insecure.
# Discovering slaves for master at 192.168.1.233:3306
# Discovering slave at 192.168.1.245:3306
# Found slave: 192.168.1.245:3306
# Discovering slave at 192.168.1.247:3306
# Found slave: 192.168.1.247:3306
# Checking privileges.MySQL Replication Failover Utility
Failover Mode = auto     Next Interval = Mon Oct 17 17:42:36 2016
--如上行,此时failover模式为autoMaster Information
------------------
Binary Log File       Position  Binlog_Do_DB  Binlog_Ignore_DB
node233-binlog.00000  191                                       GTID Executed Set     --已经执行的GTID
8dc97c98-9439-11e6-9968-000c29b82d0d:1-403Replication Health Status   --主从复制的健康状态
+----------------+-------+---------+--------+------------+---------+
| host           | port  | role    | state  | gtid_mode  | health  |
+----------------+-------+---------+--------+------------+---------+
| 192.168.1.233  | 3306  | MASTER  | UP     | ON         | OK      |
| 192.168.1.245  | 3306  | SLAVE   | UP     | ON         | OK      |
| 192.168.1.247  | 3306  | SLAVE   | UP     | ON         | OK      |
+----------------+-------+---------+--------+------------+---------+--输入大写G,查看GTID
Master GTID Executed Set
+---------------------------------------------+
| gtid                                        |
+---------------------------------------------+
| 8dc97c98-9439-11e6-9968-000c29b82d0d:1-403  |
+---------------------------------------------+--大写U,查看UUID
UUIDs
+----------------+-------+---------+---------------------------------------+
| host           | port  | role    | uuid                                  |
+----------------+-------+---------+---------------------------------------+
| 192.168.1.233  | 3306  | MASTER  | 8dc97c98-9439-11e6-9968-000c29b82d0d  |
| 192.168.1.245  | 3306  | SLAVE   | 5dacc005-943a-11e6-996d-000c29328504  |
| 192.168.1.247  | 3306  | SLAVE   | eca3bd57-943a-11e6-9971-000c292e1642  |
+----------------+-------+---------+---------------------------------------+--输入大写Q,退出mysqlfailover

2、守护进程方式启动failover

###主库端创建对象并不停插入记录实现初步模拟真实环境
[root@node233 ~]# mysql -uroot -ppass -e "create table testdb.tb(userId int)"
[root@node233 ~]# mysql -uroot -ppass -e "create table tempdb.tb(userId int)"  ###使用下面的脚本分别将记录插入到tempdb以及testdb对应得表中
# more insert_id.sh
#/bin/sh
cnt=1while [ $cnt -le 10000 ]
domysql -uroot -ppass -e "insert into tempdb.tb(userId) values($cnt);insert into testdb.tb(userId) values($cnt)"        let cnt=$cnt+1sleep 1 echo "Insert $cnt"
done###执行shell脚本,初步模拟真实环境
[root@node233 ~]# ./insert_id.sh
Warning: Using a password on the command line interface can be insecure.
Insert 2
Warning: Using a password on the command line interface can be insecure.
Insert 3
Warning: Using a password on the command line interface can be insecure.
Insert 4.........###一下错误部分为主节点挂掉后抛出的错误
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)
Insert 164
Warning: Using a password on the command line interface can be insecure.
ERROR 2002 (HY000): Can't connect to local MySQL server through socket '/tmp/mysql.sock' (2)###以守护进程方式启动mysalfailover
[root@node233 ~]# mysqlfailover --master=failover:pass@'192.168.1.233':3306 \
> --discover-slaves-login=failover:pass --log=/tmp/failover.log --daemon=start
WARNING: Using a password on the command line interface can be insecure.
NOTE: Log file '/tmp/failover.log' does not exist. Will be created.
Starting failover daemon...[root@node233 ~]# tail -fn 50 /tmp/failover.log
2016-10-17 17:47:54 PM INFO MySQL Utilities mysqlfailover version 1.6.4.
2016-10-17 17:47:54 PM INFO Server '192.168.1.233:3306' is using MySQL version 5.6.30-log.
2016-10-17 17:47:54 PM INFO Discovering slaves for master at 192.168.1.233:3306
2016-10-17 17:47:54 PM INFO Discovering slave at 192.168.1.245:3306
2016-10-17 17:47:54 PM INFO Found slave: 192.168.1.245:3306
2016-10-17 17:47:54 PM INFO Server '192.168.1.245:3306' is using MySQL version 5.6.30-log.
2016-10-17 17:47:54 PM INFO Discovering slave at 192.168.1.247:3306
2016-10-17 17:47:54 PM INFO Found slave: 192.168.1.247:3306
2016-10-17 17:47:54 PM INFO Server '192.168.1.247:3306' is using MySQL version 5.6.30-log.
2016-10-17 17:47:54 PM INFO Checking privileges.
2016-10-17 17:47:54 PM INFO Unregistering existing instances from slaves.
2016-10-17 17:47:54 PM INFO Registering instance on master.
2016-10-17 17:47:54 PM INFO Failover daemon started.
2016-10-17 17:47:54 PM INFO Failover mode = auto.
2016-10-17 17:47:57 PM INFO Master Information
2016-10-17 17:47:57 PM INFO Binary Log File: node233-binlog.000003, Position: 25463, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2016-10-17 17:47:57 PM INFO GTID Executed Set: 8dc97c98-9439-11e6-9968-000c29b82d0d:1-511
2016-10-17 17:47:57 PM INFO Getting health for master: 192.168.1.233:3306.
2016-10-17 17:47:57 PM INFO Health Status:
2016-10-17 17:47:57 PM INFO host: 192.168.1.233, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:47:57 PM INFO host: 192.168.1.245, port: 3306, role: SLAVE, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:47:57 PM INFO host: 192.168.1.247, port: 3306, role: SLAVE, state: UP, gtid_mode: ON, health: OK
###上述部分完成主从、权限检查,成功启动mysqlfailover后输出主从健康状态,后会间隔1s持续检查主从健康状态2016-10-17 17:48:15 PM INFO Discovering slaves for master at 192.168.1.233:3306
2016-10-17 17:48:15 PM INFO Discovering slave at 192.168.1.245:3306
2016-10-17 17:48:15 PM INFO Discovering slave at 192.168.1.247:3306
2016-10-17 17:48:15 PM INFO Master Information
2016-10-17 17:48:15 PM INFO Binary Log File: node233-binlog.000003, Position: 33887, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2016-10-17 17:48:15 PM INFO GTID Executed Set: 8dc97c98-9439-11e6-9968-000c29b82d0d:1-547
2016-10-17 17:48:15 PM INFO Getting health for master: 192.168.1.233:3306.
2016-10-17 17:48:15 PM INFO Health Status:
2016-10-17 17:48:15 PM INFO host: 192.168.1.233, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:48:15 PM INFO host: 192.168.1.245, port: 3306, role: SLAVE, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:48:15 PM INFO host: 192.168.1.247, port: 3306, role: SLAVE, state: UP, gtid_mode: ON, health: OK
###此时将主节点mysql关闭,发布命令 [root@node233 ~]# service mysqld stop2016-10-17 17:48:42 PM INFO Failed to reconnect to the master after 3 attemps. ###3次检测失败
2016-10-17 17:48:42 PM CRITICAL Master is confirmed to be down or unreachable.
2016-10-17 17:48:42 PM INFO Failover starting in 'auto' mode...
2016-10-17 17:48:42 PM INFO Candidate slave 192.168.1.245:3306 will become the new master.
2016-10-17 17:48:42 PM INFO Checking slaves status (before failover).
2016-10-17 17:48:42 PM INFO Preparing candidate for failover.   ###寻找candidate用于failover
2016-10-17 17:48:42 PM INFO Creating replication user if it does not exist.
2016-10-17 17:48:42 PM INFO Stopping slaves.
2016-10-17 17:48:42 PM INFO Performing STOP on all slaves.
2016-10-17 17:48:42 PM INFO Switching slaves to new master.
2016-10-17 17:48:42 PM INFO Disconnecting new master as slave.
2016-10-17 17:48:42 PM INFO Starting slaves.
2016-10-17 17:48:42 PM INFO Performing START on all slaves.
2016-10-17 17:48:42 PM INFO Checking slaves for errors.
2016-10-17 17:48:42 PM INFO Failover complete.                 ###此处failover完成
2016-10-17 17:48:42 PM INFO Discovering slaves for master at 192.168.1.245:3306
2016-10-17 17:48:47 PM INFO Unregistering existing instances from slaves.
2016-10-17 17:48:47 PM INFO Registering instance on new master 192.168.1.245:3306.
2016-10-17 17:48:48 PM INFO Master Information                 ###后续部分为持续的主从状态监测
2016-10-17 17:48:48 PM INFO Binary Log File: node245-binlog.000002, Position: 41173, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2016-10-17 17:48:48 PM INFO GTID Executed Set: 5dacc005-943a-11e6-996d-000c29328504:1[...]
2016-10-17 17:48:48 PM INFO Getting health for master: 192.168.1.245:3306.
2016-10-17 17:48:48 PM INFO Health Status:
2016-10-17 17:48:48 PM INFO host: 192.168.1.245, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:49:06 PM INFO Discovering slaves for master at 192.168.1.245:3306
2016-10-17 17:49:06 PM INFO Discovering slave at 192.168.1.247:3306
2016-10-17 17:49:06 PM INFO Found slave: 192.168.1.247:3306
2016-10-17 17:49:06 PM INFO Server '192.168.1.247:3306' is using MySQL version 5.6.30-log.
2016-10-17 17:49:06 PM INFO Master Information
2016-10-17 17:49:06 PM INFO Binary Log File: node245-binlog.000002, Position: 41173, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2016-10-17 17:49:06 PM INFO GTID Executed Set: 5dacc005-943a-11e6-996d-000c29328504:1[...]
2016-10-17 17:49:06 PM INFO Getting health for master: 192.168.1.245:3306.
2016-10-17 17:49:06 PM INFO Health Status:
2016-10-17 17:49:06 PM INFO host: 192.168.1.245, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:49:06 PM INFO host: 192.168.1.247, port: 3306, role: SLAVE, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:49:24 PM INFO Discovering slaves for master at 192.168.1.245:3306
2016-10-17 17:49:24 PM INFO Discovering slave at 192.168.1.247:3306
2016-10-17 17:49:24 PM INFO Master Information
2016-10-17 17:49:24 PM INFO Binary Log File: node245-binlog.000002, Position: 41173, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2016-10-17 17:49:24 PM INFO GTID Executed Set: 5dacc005-943a-11e6-996d-000c29328504:1[...]
2016-10-17 17:49:24 PM INFO Getting health for master: 192.168.1.245:3306.
2016-10-17 17:49:24 PM INFO Health Status:
2016-10-17 17:49:24 PM INFO host: 192.168.1.245, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2016-10-17 17:49:24 PM INFO host: 192.168.1.247, port: 3306, role: SLAVE, state: UP, gtid_mode: ON, health: OK

3、验证切换后的结果

###从节点Slave2上的记录数
[root@node247 mysql]# mysql -uroot -p -e "select count(*) from testdb.tb"
Enter password:
+----------+
| count(*) |
+----------+
|       89 |
+----------+[root@node247 mysql]# mysql -uroot -p -e "select count(*) from tempdb.tb"
Enter password:
+----------+
| count(*) |
+----------+
|       89 |
+----------+###验证从节点复制状态
(root@192.168.1.247)[(none)]>show slave status \G
*************************** 1. row ***************************
               Slave_IO_State: Waiting for master to send event
                  Master_Host: 192.168.1.245
                  Master_User: repl
                  Master_Port: 3306
                Connect_Retry: 60
              Master_Log_File: node245-binlog.000002
          Read_Master_Log_Pos: 41173
               Relay_Log_File: node247-relay-bin.000002
                Relay_Log_Pos: 643
        Relay_Master_Log_File: node245-binlog.000002
             Slave_IO_Running: Yes
            Slave_SQL_Running: Yes###新主节点(原来为Slave1)上的记录数
[root@node245 mysql]# mysql -uroot -p -e "select count(*) from testdb.tb"
Enter password:
+----------+
| count(*) |
+----------+
|       89 |
+----------+
[root@node245 mysql]# mysql -uroot -p -e "select count(*) from tempdb.tb"
Enter password:
+----------+
| count(*) |
+----------+
|       89 |
+----------+###查看新主节点上slave主机
(root@192.168.1.245)[(none)]>show slave hosts;
+-----------+---------------+------+-----------+--------------------------------------+
| Server_id | Host          | Port | Master_id | Slave_UUID                           |
+-----------+---------------+------+-----------+--------------------------------------+
|       247 | 192.168.1.247 | 3306 |       245 | eca3bd57-943a-11e6-9971-000c292e1642 |
+-----------+---------------+------+-----------+--------------------------------------+(root@192.168.1.245)[(none)]>show slave status \G
Empty set (0.00 sec)

六、几类常见的错误

1、访问拒绝权限问题

# mysqlrplshow --master=failover:pass@192.168.1.233:3306 --discover-slaves-login=failover:pass
WARNING: Using a password on the command line interface can be insecure.
# master on 192.168.1.233: ...
FAILED.ERROR: Access denied for user 'failover'@'node233.edq.com' (using password: YES)应对方案,用户需要授予基于主机名的访问权限
mysql> grant all privileges on *.* to 'failover'@'node233.edq.com' identified by 'pass';

2、权限不足的问题

# ERROR: User root on 192.168.1.233@3306 does not have sufficient privileges to execute the failover command (required: SUPER, GRANT OPTION, REPLICATION SLAVE, SELECT, RELOAD, DROP, CREATE, INSERT).
2016-10-08 16:18:20 PM CRITICAL Not enough privileges to execute command.应对方案,用户需要授予with grant option权限
mysql> grant all privileges on *.* to 'root'@'node233.edq.com' identified by 'pass' with grant option;

3、配置参数问题

[root@node233 ~]# mysqlfailover --master=root:pass@192.168.1.233:3306 --discover-slaves-login=root:pass
WARNING: Using a password on the command line interface can be insecure.
# Discovering slaves for master at 192.168.1.233:3306
# Discovering slave at 192.168.1.245:3306
# Found slave: 192.168.1.245:3306
# Discovering slave at 192.168.1.247:3306
# Found slave: 192.168.1.247:3306
# Checking privileges.
2016-10-08 16:21:40 PM CRITICAL Failover requires --master-info-repository=TABLE for all slaves.
ERROR: Failover requires --master-info-repository=TABLE for all slaves.应对方案,需要在配置文件中增加上述参数,如本文之前描述

4、多个mysqlfailover进程启动问题

[root@node233 ~]# mysqlfailover --master=failover:pass@'192.168.1.233':3306 --discover-slaves-login=failover:pass
WARNING: Using a password on the command line interface can be insecure.
# Discovering slaves for master at 192.168.1.233:3306
# Discovering slave at 192.168.1.245:3306
# Found slave: 192.168.1.245:3306
# Discovering slave at 192.168.1.247:3306
# Found slave: 192.168.1.247:3306
# Checking privileges.
Multiple instances of failover console found for master 192.168.1.233:3306.
If this is an error, restart the console with --force.
Failover mode changed to 'FAIL' for this instance.
Console will start in 10 seconds..........starting Console.
MySQL Replication Failover Utility
Failover Mode = fail     Next Interval = Mon Oct 17 17:02:17 2016如上,如果已经有启动的mysqlfailover,则出现上述failover模式
如果无启动的mysqlfailover,也出现上述情形,建议执行以下命令
mysql > truncate table mysql.failover_console;  --该表记录了主节点及端口号      

MySQL 自动故障转移工具--mysqlfailover相关推荐

  1. keepalive配置mysql自动故障转移

    本文先配置了一个双master环境,互为主从,然后通过Keepalive配置了一个虚拟IP,客户端通过虚拟IP连接master1,当master1宕机,自动切换到master2.一次只能连接其中一个m ...

  2. 故障转移集群无法连接到节点_Redis集群以及自动故障转移测试

    在Redis中,与Sentinel(哨兵)实现的高可用相比,集群(cluster)更多的是强调数据的分片或者是节点的伸缩性,如果在集群的主节点上加入对应的从节点,集群还可以自动故障转移,因此相比Sen ...

  3. postgresql 重启记录_PostgreSQL 高可用:PostgreSQL复制和自动故障转移

    原文:PostgreSQL Replication and Automatic Failover Tutorial[1] 作者:Abbas Butt 翻译整理:alitrack 1.什么是 Postg ...

  4. [译]PG复制和自动故障转移--2

    PostgreSQL 的预写日志 (WAL) 示例 1) SELECT datname, oid FROM pg_database WHERE datname = 'postgres'; datnam ...

  5. (2)MongoDB副本集自动故障转移原理(含客户端)

    前文我们搭建MongoDB三成员副本集,了解集群基本特性,今天我们围绕下图聊一聊背后的细节. 默认搭建的副本集均在主节点读写,辅助节点冗余部署,形成高可用和备份,具备自动故障转移能力. 集群心跳保活 ...

  6. sql azure 语法_Azure SQL Server自动故障转移组

    sql azure 语法 In this article, we will review how to set up auto-failover groups in Azure SQL Server ...

  7. HG_REPMGR autofailvoer自动故障转移

    目录 文档用途 详细信息 文档用途 HG_REPMGR自动故障转移配置参考 详细信息 配置集群自动故障转移(failover),需要为集群中的每个节点开启 repmgrd 守护进程.当主节点出现故障后 ...

  8. mysql被跑死_MySQL 8.0.23中复制架构从节点自动故障转移

    接触MGR有一段时间了,MySQL 8.0.23的到来,基于MySQL Group Replicaion(MGR)的高可用架构又提供了新的架构思路.灾备机房的slave,如何更好地支持主机房的MGR? ...

  9. 【Hadoop 分布式部署 十 一: NameNode HA 自动故障转移】

    问题描述:    上一篇就是NameNode 的HA 部署完成,但是存在问题,问题是如果 主NameNode的节点宕机了,还是需要人工去使用命令来切换NameNode的Acitve 这样很不方便,所以 ...

最新文章

  1. 20个开源项目托管站点推荐
  2. php zhegnze_php 正则表达式
  3. linux启动设置运行级别,Linux的运行级别和设置开机启动服务的方式
  4. Python 循环删除指定文件夹下所有的.longtian类型文件
  5. unity 纹理压缩格式‘_纹理优化:让你的纹理也“瘦”下来
  6. 95-850-020-源码-心跳-JobMaster与TaskExecutor之间的心跳检测
  7. linux脚本怎么退出while,linux中的while命令
  8. 编写自己的代码库(javascript常用实例的实现与封装)
  9. GoogleAdSense高价关键字排行榜
  10. 利用idea 打包jar包
  11. xss.haozi.me在线靶机挑战
  12. 手把手教你用SetWindowsHookEx做一个键盘记录器
  13. 超级实用的分时图指标 有了本分时图你根本不用看K线了
  14. Mybatis-plus的自动填充功能
  15. web项目的启动时文件加载顺序
  16. 百择电商:抖音什么情况下会被限流?
  17. 人工智能数学课高等数学线性微积分数学教程笔记
  18. 将word文档中所有文本框中的内容转换成普通段落
  19. 做微商,可不可以温柔一点
  20. 联想G510笔记本电脑换屏——操作步骤详解

热门文章

  1. 力扣121、122、309、714(C语言版)动态规划股票问题
  2. Spark RDD 论文详解(三)Spark 编程接口
  3. Stata数据处理:import-fred-命令导入联邦储备经济数据库-FRED
  4. 到处都是“公馆”,中国小区命名为何如此“没文化”?
  5. 杀人游戏语言中英对照
  6. 数学速算法_资深数学教师整理,小学生数学速算法,看到就是赚到!(为孩子收藏)...
  7. 南尼U盘修复——坑die专属
  8. 机构称谷歌新闻业务2018收入47亿美元 谷歌:计算方法有误
  9. 必联路由器虚拟服务器怎么设置,192.168.16.1官网 必联路由器怎么设置
  10. 汽车美容店会员开卡办理html,洗车店会员卡管理系统线下线上会员一体化?