Mysql 运行--exec after脚本时没有响应

Mysql 运行--exec after脚本时没有响应,mysql,high-availability,Mysql,High Availability,为了实现MySQL数据库的高可用性,我使用MySQLFilover实用程序。我跑步的时候一切都很好 mysqlfailover --master=root:pass@master-host:3306 --slaves=root:pass@slave-host:3306 --rpl-user=slave-user:slave-pass --log=log.txt --force --daemon=start 它产生如下输出 2017-05-15 12:41:06 PM INFO Server '

为了实现MySQL数据库的高可用性,我使用MySQLFilover实用程序。我跑步的时候一切都很好

mysqlfailover --master=root:pass@master-host:3306 --slaves=root:pass@slave-host:3306 --rpl-user=slave-user:slave-pass --log=log.txt --force --daemon=start
它产生如下输出

2017-05-15 12:41:06 PM INFO Server 'master-host:3306' is using MySQL version 5.6.36-log.
2017-05-15 12:41:06 PM INFO Server 'slave-host:3306' is using MySQL version 5.6.36-log.
2017-05-15 12:41:06 PM INFO Unregistering instance on master.
2017-05-15 12:41:06 PM INFO Checking privileges.
2017-05-15 12:41:06 PM INFO Unregistering existing instances from slaves.
2017-05-15 12:41:06 PM INFO Registering instance on master.
2017-05-15 12:41:06 PM INFO Failover daemon started.
2017-05-15 12:41:06 PM INFO Failover mode = auto.
2017-05-15 12:41:09 PM INFO Master Information
2017-05-15 12:41:09 PM INFO Binary Log File: mysql-bin.000020, Position: 191, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2017-05-15 12:41:09 PM INFO GTID Executed Set: 952b004a-3567-11e7-b46e-0a767d02b017:1-10
2017-05-15 12:41:09 PM INFO Getting health for master: master-host:3306.
2017-05-15 12:41:09 PM INFO Health Status:
2017-05-15 12:41:09 PM INFO host: master-host, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2017-05-15 12:41:09 PM INFO host: slave-host, port: 3306, role: SLAVE, state: UP, gtid_mode: ON, health: OK
当我停止主MySQL守护程序时,输出是

2017-05-15 12:40:01 PM INFO Master may be down. Waiting for 3 seconds.
2017-05-15 12:40:16 PM INFO Failed to reconnect to the master after 3 attemps.
2017-05-15 12:40:16 PM CRITICAL Master is confirmed to be down or unreachable.
2017-05-15 12:40:16 PM INFO Failover starting in 'auto' mode...
2017-05-15 12:40:16 PM INFO Candidate slave slave-host:3306 will become the new master.
2017-05-15 12:40:16 PM INFO Checking slaves status (before failover).
2017-05-15 12:40:16 PM INFO Preparing candidate for failover.
2017-05-15 12:40:16 PM INFO Creating replication user if it does not exist.
2017-05-15 12:40:16 PM INFO Stopping slaves.
2017-05-15 12:40:16 PM INFO Performing STOP on all slaves.
2017-05-15 12:40:16 PM INFO Switching slaves to new master.
2017-05-15 12:40:16 PM INFO Disconnecting new master as slave.
2017-05-15 12:40:16 PM INFO Starting slaves.
2017-05-15 12:40:16 PM INFO Performing START on all slaves.
2017-05-15 12:40:16 PM INFO Checking slaves for errors.
2017-05-15 12:40:16 PM INFO Failover complete.
2017-05-15 12:40:21 PM INFO Unregistering existing instances from slaves.
2017-05-15 12:40:21 PM INFO Registering instance on new master slave-host:3306.
2017-05-15 12:40:22 PM INFO Master Information
2017-05-15 12:40:22 PM INFO Binary Log File: mysql-bin.000003, Position: 191, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2017-05-15 12:40:22 PM INFO GTID Executed Set: 952b004a-3567-11e7-b46e-0a767d02b017:1-10
2017-05-15 12:40:22 PM INFO Getting health for master: slave-host:3306.
2017-05-15 12:40:22 PM INFO Health Status:
2017-05-15 12:40:22 PM INFO host: slave-host, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2017-05-15 13:04:42 PM INFO Master may be down. Waiting for 3 seconds.
2017-05-15 13:04:57 PM INFO Failed to reconnect to the master after 3 attemps.
2017-05-15 13:04:57 PM CRITICAL Master is confirmed to be down or unreachable.
2017-05-15 13:04:57 PM INFO Failover starting in 'auto' mode...
2017-05-15 13:04:57 PM INFO Candidate slave slave-host:3306 will become the new master.
2017-05-15 13:04:57 PM INFO Checking slaves status (before failover).
2017-05-15 13:04:57 PM INFO Preparing candidate for failover.
2017-05-15 13:04:57 PM INFO Creating replication user if it does not exist.
2017-05-15 13:04:57 PM INFO Spawning external script.
2017-05-15 13:04:57 PM INFO Unregistering instance on master
但我希望在执行切换或故障切换后执行脚本。虽然脚本的用途与我的应用程序的数据库连接有关,但目前我运行的示例脚本exec.sh包含以下内容

#!/bin/bash
echo "creating a new file after failover"
touch troubleshoot.txt
exit 0
现在当我运行命令时

mysqlfailover --master=root:pass@master-host:3306 --slaves=root:pass@slave-host:3306 --rpl-user=slave-user:slave-pass --log=log.txt --force --daemon=start --exec-after="./exec.sh"
它在主机上注销实例时停止,输出为

2017-05-15 12:40:01 PM INFO Master may be down. Waiting for 3 seconds.
2017-05-15 12:40:16 PM INFO Failed to reconnect to the master after 3 attemps.
2017-05-15 12:40:16 PM CRITICAL Master is confirmed to be down or unreachable.
2017-05-15 12:40:16 PM INFO Failover starting in 'auto' mode...
2017-05-15 12:40:16 PM INFO Candidate slave slave-host:3306 will become the new master.
2017-05-15 12:40:16 PM INFO Checking slaves status (before failover).
2017-05-15 12:40:16 PM INFO Preparing candidate for failover.
2017-05-15 12:40:16 PM INFO Creating replication user if it does not exist.
2017-05-15 12:40:16 PM INFO Stopping slaves.
2017-05-15 12:40:16 PM INFO Performing STOP on all slaves.
2017-05-15 12:40:16 PM INFO Switching slaves to new master.
2017-05-15 12:40:16 PM INFO Disconnecting new master as slave.
2017-05-15 12:40:16 PM INFO Starting slaves.
2017-05-15 12:40:16 PM INFO Performing START on all slaves.
2017-05-15 12:40:16 PM INFO Checking slaves for errors.
2017-05-15 12:40:16 PM INFO Failover complete.
2017-05-15 12:40:21 PM INFO Unregistering existing instances from slaves.
2017-05-15 12:40:21 PM INFO Registering instance on new master slave-host:3306.
2017-05-15 12:40:22 PM INFO Master Information
2017-05-15 12:40:22 PM INFO Binary Log File: mysql-bin.000003, Position: 191, Binlog_Do_DB: N/A, Binlog_Ignore_DB: N/A
2017-05-15 12:40:22 PM INFO GTID Executed Set: 952b004a-3567-11e7-b46e-0a767d02b017:1-10
2017-05-15 12:40:22 PM INFO Getting health for master: slave-host:3306.
2017-05-15 12:40:22 PM INFO Health Status:
2017-05-15 12:40:22 PM INFO host: slave-host, port: 3306, role: MASTER, state: UP, gtid_mode: ON, health: OK
2017-05-15 13:04:42 PM INFO Master may be down. Waiting for 3 seconds.
2017-05-15 13:04:57 PM INFO Failed to reconnect to the master after 3 attemps.
2017-05-15 13:04:57 PM CRITICAL Master is confirmed to be down or unreachable.
2017-05-15 13:04:57 PM INFO Failover starting in 'auto' mode...
2017-05-15 13:04:57 PM INFO Candidate slave slave-host:3306 will become the new master.
2017-05-15 13:04:57 PM INFO Checking slaves status (before failover).
2017-05-15 13:04:57 PM INFO Preparing candidate for failover.
2017-05-15 13:04:57 PM INFO Creating replication user if it does not exist.
2017-05-15 13:04:57 PM INFO Spawning external script.
2017-05-15 13:04:57 PM INFO Unregistering instance on master

虽然输出显示“生成外部脚本”,但此步骤之后什么也没有发生。我还检查了脚本是否有足够的执行权限以及最后的0退出状态。请帮助我找出停止进一步执行的问题所在。

请确保提供脚本的完整路径,而不是相对路径

mysqlfailover --master=root:pass@master-host:3306 --slaves=root:pass@slave-host:3306 --rpl-user=slave-user:slave-pass --log=log.txt --force --daemon=start --exec-after="/full/path/to/exec.sh"

可能说明了对象,但您是否尝试提供脚本的完整路径而不是相对路径?@lloiacono是,指定完整路径有效。谢谢