2017-05-15 17 views
1

MySQLデータベースの高可用性を実現するために、私はmysqlfailoverユーティリティを使用しています。私は--exec-afterスクリプトを実行しても応答がありません

mysqlfailover --master=root:[email protected]:3306 --slaves=root:[email protected]:3306 --rpl-user=slave-user:slave-pass --log=log.txt --force --daemon=start 

を実行していたときにすべてがうまく動作しており、それは私がマスターの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 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 

を生成しますスイッチオーバーまたはフェールオーバー後のスクリプトが実行されます。スクリプトの目的は、私のアプリケーションのデータベース接続に関連するものですが、現在私は、次の内容

#!/bin/bash 
echo "creating a new file after failover" 
touch troubleshoot.txt 
exit 0 

そして今、私は、コマンドに

mysqlfailover --master=root:[email protected]:3306 --slaves=root:[email protected]:3306 --rpl-user=slave-user:slave-pass --log=log.txt --force --daemon=start --exec-after="./exec.sh" 
を実行していますとサンプルスクリプト 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 
あります

出力には「外部スクリプトの生成」と表示されますが、この手順の後には何も起こりません。また、スクリプトの実行許可と終了時の終了ステータスが0であることを確認しました。今後の実行を止めている問題が何であるかを知るのを手伝ってください。

+0

おそらくobvousと書かれていますが、相対パスの代わりにスクリプトのフルパスを指定してみましたか? – lloiacono

+1

@lloiaconoはい、完全なパスが指定されています。ありがとう。 –

答えて

0

相対パスではなくスクリプトに完全パスを指定してください。

mysqlfailover --master=root:[email protected]:3306 --slaves=root:[email protected]:3306 --rpl-user=slave-user:slave-pass --log=log.txt --force --daemon=start --exec-after="/full/path/to/exec.sh" 
関連する問題