精华总结:MHA构建中的各种报错与解决

文章目录

  • 前言
  • 一:报错与解决
      • 1.1:报错: [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln364] None of slaves can be master. Check failover configuration file or log-bin settings in my.cnf
      • 1.2:报错: User myslave does not exist or does not have REPLICATION SLAVE privilege! Other slaves can not start replication from this host.
      • 1.3:报错:[/usr/local/share/perl5/MHA/MasterMonitor.pm, ln208] Slaves settings check failed!
      • 1.4:报错:[error]/usr/local/share/perl5/MHA/MasterMonitor.pm, ln208 Slaves settings check failed!
      • 1.5:报错:Testing mysql connection and privileges..sh: mysql: 未找到命令
      • 1.6:报错:Failed to get master_ip_failover_script status with return code 2:0.

前言

一:报错与解决

1.1:报错: [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln364] None of slaves can be master. Check failover configuration file or log-bin settings in my.cnf

  • 报错描述

    [root@mha_manager ~]# masterha_check_repl -conf=/etc/masterha/app1.cnf
    ...省略内容
    Fri Jan 10 08:42:12 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln364] None of slaves can be master. Check failover configuration file or log-bin settings in my.cnf
    Fri Jan 10 08:42:12 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/local/bin/masterha_check_repl line 48.
    Fri Jan 10 08:42:12 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
    Fri Jan 10 08:42:12 2020 - [info] Got exit code 1 (Not master dead).
    
    MySQL Replication Health is NOT OK!
    
  • 原因:

    mysql集群中的slave节点中数据库配置文件/etc/my.cnf中没有配置二进制日志,只需要在所有slave节点配置二进制日志即可

    二进制日志格式
    log-bin=xxx(名称自定义)
    
  • 解决:在所有slave节点配置二进制日志

    [root@slave1 ~]# vim /etc/my.cnf
        [mysqld]段落添加
    log-bin=slave1-bin	'//添加二进制日志'
    所以slave节点都要配置,我就不一一展示了
    

1.2:报错: User myslave does not exist or does not have REPLICATION SLAVE privilege! Other slaves can not start replication from this host.

  • 报错描述

    [root@mha_manager ~]# masterha_check_repl -conf=/etc/masterha/app1.cnf
    ...省略内容
    Fri Jan 10 09:04:53 2020 - [error][/usr/local/share/perl5/MHA/Server.pm, ln398] 192.168.79.135(192.168.79.135:3306): User myslave does not exist or does not have REPLICATION SLAVE privilege! Other slaves can not start replication from this host.
    Fri Jan 10 09:04:53 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/local/share/perl5/MHA/ServerManager.pm line 1403.
    Fri Jan 10 09:04:53 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
    Fri Jan 10 09:04:53 2020 - [info] Got exit code 1 (Not master dead).
    
    MySQL Replication Health is NOT OK!
    
  • 原因:192.168.79.135主机上没有添加用户或者权限问题,重新添加用户和权限即可

  • 解决:

    添加用户
    '//192.168.79.0段的从服务器拥有复制权限,可以使用myslave身份123456密码复制所有的库和表'
    mysql> GRANT REPLICATION SLAVE ON *.* TO 'myslave'@'192.168.79.%' IDENTIFIED BY '123456';
    Query OK, 0 rows affected, 1 warning (0.01 sec)
    '//查看创建的用户,若出现两个用户,也会报错,删除一个即可'
    mysql> SELECT Repl_slave_priv AS Value FROM mysql.user WHERE user = 'myslave';
    +-------+
    | Value |
    +-------+
    | Y     |
    +-------+
    1 row in set (0.00 sec)
    

1.3:报错:[/usr/local/share/perl5/MHA/MasterMonitor.pm, ln208] Slaves settings check failed!

  • 报错描述:

    [root@mha_manager ~]# masterha_check_repl -conf=/etc/masterha/app1.cnf
    Can't exec "mysqlbinlog": 没有那个文件或目录 at /usr/local/share/perl5/MHA/BinlogManager.pm line 106.
    mysqlbinlog version command failed with rc 1:0, please verify PATH, LD_LIBRARY_PATH, and client options
     at /usr/local/bin/apply_diff_relay_logs line 493.
    Fri Jan 10 11:01:35 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln208] Slaves settings check failed!
    Fri Jan 10 11:01:35 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln416] Slave configuration failed.
    Fri Jan 10 11:01:35 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/local/bin/masterha_check_repl line 48.
    Fri Jan 10 11:01:35 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
    Fri Jan 10 11:01:35 2020 - [info] Got exit code 1 (Not master dead).
    
    MySQL Replication Health is NOT OK!
    
    
  • 原因:Can’t exec “mysqlbinlog”: 没有那个文件或目录 at /usr/local/share/perl5/MHA/BinlogManager.pm line 106.

  • 解决:

    所有节点创建软连接
    ln -s /usr/local/mysql/bin/mysqlbinlog /usr/local/bin/
    

1.4:报错:[error]/usr/local/share/perl5/MHA/MasterMonitor.pm, ln208 Slaves settings check failed!

  • 报错描述:

    [root@mha_manager bin]# masterha_check_repl -conf=/etc/masterha/app1.cnf
    mysqlbinlog: [ERROR] unknown variable 'default-character-set=utf8'
    mysqlbinlog version command failed with rc 7:0, please verify PATH, LD_LIBRARY_PATH, and client options
     at /usr/local/bin/apply_diff_relay_logs line 493.
    Fri Jan 10 11:03:09 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln208] Slaves settings check failed!
    Fri Jan 10 11:03:09 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln416] Slave configuration failed.
    Fri Jan 10 11:03:09 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/local/bin/masterha_check_repl line 48.
    Fri Jan 10 11:03:09 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
    Fri Jan 10 11:03:09 2020 - [info] Got exit code 1 (Not master dead).
    
    MySQL Replication Health is NOT OK!
    
    
  • 原因:mysqlbinlog: [ERROR] unknown variable ‘default-character-set=utf8’

  • 解决:从服务器上都注释掉client段的默认字符集

    [root@slave1 ~]# vim /etc/my.cnf
    [client]
    #default-character-set=utf8	'//注释掉此'
    

1.5:报错:Testing mysql connection and privileges…sh: mysql: 未找到命令

  • 报错描述:

    Fri Jan 10 11:20:21 2020 - [info]   Connecting to [email protected](192.168.79.135:22).. 
      Checking slave recovery environment settings..
        Opening /usr/local/mysql/data/relay-log.info ... ok.
        Relay log found at /usr/local/mysql/data, up to relay-log-bin.000043
        Temporary relay log file is /usr/local/mysql/data/relay-log-bin.000043
        Testing mysql connection and privileges..sh: mysql: 未找到命令
    mysql command failed with rc 127:0!
     at /usr/local/bin/apply_diff_relay_logs line 375.
            main::check() called at /usr/local/bin/apply_diff_relay_logs line 497
            eval {...} called at /usr/local/bin/apply_diff_relay_logs line 475
            main::main() called at /usr/local/bin/apply_diff_relay_logs line 120
    Fri Jan 10 11:20:21 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln208] Slaves settings check failed!
    Fri Jan 10 11:20:21 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln416] Slave configuration failed.
    Fri Jan 10 11:20:21 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/local/bin/masterha_check_repl line 48.
    Fri Jan 10 11:20:21 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
    Fri Jan 10 11:20:21 2020 - [info] Got exit code 1 (Not master dead).
    
    MySQL Replication Health is NOT OK!
    
    
  • 原因:没有mysql命令

    Testing mysql connection and privileges..sh: mysql: 未找到命令
    mysql command failed with rc 127:0!
    
  • 解决:创建mysql软连接

    ln -s /usr/local/mysql/bin/mysql /usr/local/bin/
    

1.6:报错:Failed to get master_ip_failover_script status with return code 2:0.

  • 报错描述:

    /usr/local/bin/master_ip_failover:行2: use: 未找到命令
    /usr/local/bin/master_ip_failover:行3: use: 未找到命令
    /usr/local/bin/master_ip_failover:行5: use: 未找到命令
    /usr/local/bin/master_ip_failover:行7: 未预期的符号 `newline' 附近有语法错误
    /usr/local/bin/master_ip_failover:行7: ` my ('
    Fri Jan 10 11:58:44 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln229]  Failed to get master_ip_failover_script status with return code 2:0.
    Fri Jan 10 11:58:44 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln427] Error happened on checking configurations.  at /usr/local/bin/masterha_check_repl line 48.
    Fri Jan 10 11:58:44 2020 - [error][/usr/local/share/perl5/MHA/MasterMonitor.pm, ln525] Error happened on monitoring servers.
    Fri Jan 10 11:58:44 2020 - [info] Got exit code 1 (Not master dead).
    
    MySQL Replication Health is NOT OK!
    
  • 原因:master_ip_failover 文件语法问题

  • 解决:#!/usr/bin/env perl顶格写就行

    [root@mha_manager bin]# vim master_ip_failover
    #!/usr/bin/env perl	'//第一行要最顶行写,不要有空格'
    
    

你可能感兴趣的:(踩坑日志)