运行 --exec-after 脚本时无响应
No response when running --exec-after script
为了实现 MySQL 数据库的高可用性,我使用了 mysqlfailover 实用程序。当我 运行
时,一切都很好 运行
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
当我停止 master 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
但我想在执行切换或故障转移后执行脚本。虽然脚本的目的与我的应用程序的数据库连接有关,但目前我 运行 一个示例脚本 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 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
虽然输出显示 "Spawning external script" 但此步骤后没有任何反应。我还检查了脚本是否具有足够的执行权限以及最后的 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"
为了实现 MySQL 数据库的高可用性,我使用了 mysqlfailover 实用程序。当我 运行
时,一切都很好 运行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
当我停止 master 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
但我想在执行切换或故障转移后执行脚本。虽然脚本的目的与我的应用程序的数据库连接有关,但目前我 运行 一个示例脚本 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 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
虽然输出显示 "Spawning external script" 但此步骤后没有任何反应。我还检查了脚本是否具有足够的执行权限以及最后的 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"