master_ip_failover_script问题终极解决方案
Posted fangyuan303687320
tags:
篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了master_ip_failover_script问题终极解决方案相关的知识,希望对你有一定的参考价值。
[[email protected] run]# masterha_check_repl --conf=/etc/mha/app2.cnf Wed Aug 15 14:47:52 2018 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Wed Aug 15 14:47:52 2018 - [info] Reading application default configuration from /etc/mha/app2.cnf.. Wed Aug 15 14:47:52 2018 - [info] Reading server configuration from /etc/mha/app2.cnf.. Wed Aug 15 14:47:52 2018 - [info] MHA::MasterMonitor version 0.58. Wed Aug 15 14:47:53 2018 - [info] GTID failover mode = 1 Wed Aug 15 14:47:53 2018 - [info] Dead Servers: Wed Aug 15 14:47:53 2018 - [info] Alive Servers: Wed Aug 15 14:47:53 2018 - [info] 192.168.152.156(192.168.152.156:3306) Wed Aug 15 14:47:53 2018 - [info] 192.168.152.157(192.168.152.157:3306) Wed Aug 15 14:47:53 2018 - [info] 192.168.152.158(192.168.152.158:3306) Wed Aug 15 14:47:53 2018 - [info] Alive Slaves: Wed Aug 15 14:47:53 2018 - [info] 192.168.152.157(192.168.152.157:3306) Version=5.7.23-log (oldest major version between slaves) log-bin:enabled Wed Aug 15 14:47:53 2018 - [info] GTID ON Wed Aug 15 14:47:53 2018 - [info] Replicating from 192.168.152.156(192.168.152.156:3306) Wed Aug 15 14:47:53 2018 - [info] Primary candidate for the new Master (candidate_master is set) Wed Aug 15 14:47:53 2018 - [info] 192.168.152.158(192.168.152.158:3306) Version=5.7.23-log (oldest major version between slaves) log-bin:enabled Wed Aug 15 14:47:53 2018 - [info] GTID ON Wed Aug 15 14:47:53 2018 - [info] Replicating from 192.168.152.156(192.168.152.156:3306) Wed Aug 15 14:47:53 2018 - [info] Not candidate for the new Master (no_master is set) Wed Aug 15 14:47:53 2018 - [info] Current Alive Master: 192.168.152.156(192.168.152.156:3306) Wed Aug 15 14:47:53 2018 - [info] Checking slave configurations.. Wed Aug 15 14:47:53 2018 - [info] Checking replication filtering settings.. Wed Aug 15 14:47:53 2018 - [info] binlog_do_db= , binlog_ignore_db= Wed Aug 15 14:47:53 2018 - [info] Replication filtering check ok. Wed Aug 15 14:47:53 2018 - [info] GTID (with auto-pos) is supported. Skipping all SSH and Node package checking. Wed Aug 15 14:47:53 2018 - [info] Checking SSH publickey authentication settings on the current master.. Wed Aug 15 14:47:53 2018 - [info] HealthCheck: SSH to 192.168.152.156 is reachable. Wed Aug 15 14:47:53 2018 - [info] 192.168.152.156(192.168.152.156:3306) (current master) +--192.168.152.157(192.168.152.157:3306) +--192.168.152.158(192.168.152.158:3306) Wed Aug 15 14:47:53 2018 - [info] Checking replication health on 192.168.152.157.. Wed Aug 15 14:47:53 2018 - [info] ok. Wed Aug 15 14:47:53 2018 - [info] Checking replication health on 192.168.152.158.. Wed Aug 15 14:47:53 2018 - [info] ok. Wed Aug 15 14:47:53 2018 - [info] Checking master_ip_failover_script status: Wed Aug 15 14:47:53 2018 - [info] ====1==== /etc/mha/run/failover3 --command=status --ssh_user=root --orig_master_host=192.168.152.156 --orig_master_ip=192.168.152.156 --orig_master_port=3306 : No such file or directory Wed Aug 15 14:47:53 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln229] Failed to get master_ip_failover_script status with return code 127:0. Wed Aug 15 14:47:53 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations. at /usr/bin/masterha_check_repl line 48. Wed Aug 15 14:47:53 2018 - [error][/usr/share/perl5/vendor_perl/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers. Wed Aug 15 14:47:53 2018 - [info] Got exit code 1 (Not master dead). mysql Replication Health is NOT OK!
这个路径是存在的。那么这里出问题的就是这个脚本的问题。
从官网上下载mha0.58的源码
用samples 里面的master_ip_failover_script 脚本
修改为:
#!/usr/bin/env perl # Copyright (C) 2011 DeNA Co.,Ltd. # You should have received a copy of the GNU General Public License # along with this program; if not, write to the Free Software # Foundation, Inc., # 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA ## Note: This is a sample script and is not complete. Modify the script based on your environment. use strict; use warnings FATAL => ‘all‘; use Getopt::Long; use MHA::DBHelper; my ( $command, $ssh_user, $orig_master_host, $orig_master_ip, $orig_master_port, $new_master_host, $new_master_ip, $new_master_port, $new_master_user, $new_master_password ); my $vip = ‘192.168.152.159/24‘; my $key = ‘88‘; my $ssh_start_vip = "/sbin/ifconfig ens33:$key $vip"; my $ssh_stop_vip = "/sbin/ifconfig ens33:$key down"; GetOptions( ‘command=s‘ => $command, ‘ssh_user=s‘ => $ssh_user, ‘orig_master_host=s‘ => $orig_master_host, ‘orig_master_ip=s‘ => $orig_master_ip, ‘orig_master_port=i‘ => $orig_master_port, ‘new_master_host=s‘ => $new_master_host, ‘new_master_ip=s‘ => $new_master_ip, ‘new_master_port=i‘ => $new_master_port, ‘new_master_user=s‘ => $new_master_user, ‘new_master_password=s‘ => $new_master_password, ); exit &main(); sub main { print " IN SCRIPT TEST====$ssh_stop_vip==$ssh_start_vip=== "; if ( $command eq "stop" || $command eq "stopssh" ) { my $exit_code = 1; eval { print "Disabling the VIP on old master: $orig_master_host "; &stop_vip(); $exit_code = 0; }; if ([email protected]) { warn "Got Error: [email protected] "; exit $exit_code; } exit $exit_code; } elsif ( $command eq "start" ) { my $exit_code = 10; eval { print "Enabling the VIP - $vip on the new master - $new_master_host "; &start_vip(); $exit_code = 0; }; if ([email protected]) { warn [email protected]; exit $exit_code; } exit $exit_code; } elsif ( $command eq "status" ) { print "Checking the Status of the script.. OK "; exit 0; } else { &usage(); exit 1; } } sub start_vip() { `ssh $ssh_user@$new_master_host " $ssh_start_vip "`; } sub stop_vip() { return 0 unless ($ssh_user); `ssh $ssh_user@$orig_master_host " $ssh_stop_vip "`; } sub usage { print "Usage: master_ip_failover --command=start|stop|stopssh|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port "; }
经测试ok
以上是关于master_ip_failover_script问题终极解决方案的主要内容,如果未能解决你的问题,请参考以下文章