zoukankan      html  css  js  c++  java
  • master_ip_failover_script问题终极解决方案

    [root@kube-node5 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 ($@) {
                warn "Got Error: $@
    ";
                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 ($@) {
                warn $@;
                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

  • 相关阅读:
    (续)在深度计算框架MindSpore中如何对不持续的计算进行处理——对数据集进行一定epoch数量的训练后,进行其他工作处理,再返回来接着进行一定epoch数量的训练——单步计算
    YAML文件简介
    训练集验证集测试集的概念
    泛化误差
    drawio的打开方法
    移动硬盘无法被电脑识别
    r5 3600相当于英特尔什么级别
    Ubuntu WPS字体缺失配置
    pytorch深度学习cpu占用太高
    常用的架构设计原则-云原生架构设计快速入门
  • 原文地址:https://www.cnblogs.com/fangyuan303687320/p/9481581.html
Copyright © 2011-2022 走看看