1. 两个包:mha4mysql-manager-0.56-0.el6.noarch.rpm 和 mha4mysql-node-0.56-0.el6.norch.rpm

地址:https://code.google.com/archive/p/mysql-master-ha/

2. 一些依赖包

yum install perl-DBD-MySQL
yum install perl-Config-Tiny
yum install perl-Log-Dispatch
yum install perl-Parallel-ForkManager

所有节点全装,不然可能报错;

3. manager节点的一些工具:

masterha_check_ssh:MHA依赖的ssh环境检测

masterha_check_repl:MHA复制环境检测

masterha_manager:服务主程序

masterha_check_status:MHA运行状态检测

masterha_stop:关闭MHA

4. masterha_check_ssh检测中遇到的问题:

[root@manager ~]# masterha_check_ssh -conf=/etc/mha_master/mha.cnf
Can't locate MHA/SSHCheck.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/bin/masterha_check_ssh line 25.
BEGIN failed--compilation aborted at /usr/bin/masterha_check_ssh line 25.

应该是环境变量的问题;

[root@manager ~]# find / -name SSHCheck.pm

/usr/lib/perl5/vendor_perl/MHA/SSHCheck.pm

将相关路径加入PERL5LIB,(根本问题是MHA和OS版本不匹配)

export PERL5LIB=$PERL5LIB:/usr/lib/perl5/vendor_perl/

5. materha_check_repl检测遇到的问题:

[root@manager ~]# masterha_check_repl -conf=/etc/mha_master/mha.cnf
Mon Mar 1 12:27:17 2021 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Mar 1 12:27:17 2021 - [info] Reading application default configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 12:27:17 2021 - [info] Reading server configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 12:27:17 2021 - [info] MHA::MasterMonitor version 0.55.
Creating directory /etc/mha_master/app1.. done.
Mon Mar 1 12:27:17 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/ServerManager.pm, ln255] Got MySQL error when connecting 192.168.10.30(192.168.10.30:3306) :1130:Host '192.168.10.10' is not allowed to connect to this MariaDB server, but this is not mysql crash. Check MySQL server settings.
at /usr/lib/perl5/vendor_perl//MHA/ServerManager.pm line 251.
Mon Mar 1 12:27:18 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/ServerManager.pm, ln263] Got fatal error, stopping operations
Mon Mar 1 12:27:18 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln386] Error happend on checking configurations. at /usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm line 300.
Mon Mar 1 12:27:18 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln482] Error happened on monitoring servers.
Mon Mar 1 12:27:18 2021 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

检查每个节点是不是都安装了依赖包;

6. materha_check_repl检测遇到的问题:

[root@manager ~]# masterha_check_repl -conf=/etc/mha_master/mha.cnf
Mon Mar 1 12:29:06 2021 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Mar 1 12:29:06 2021 - [info] Reading application default configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 12:29:06 2021 - [info] Reading server configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 12:29:06 2021 - [info] MHA::MasterMonitor version 0.55.
Mon Mar 1 12:29:06 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/ServerManager.pm, ln255] Got MySQL error when connecting 192.168.10.30(192.168.10.30:3306) :1045:Access denied for user 'mhaadmin'@'192.168.10.10' (using password: YES), but this is not mysql crash. Check MySQL server settings.
at /usr/lib/perl5/vendor_perl//MHA/ServerManager.pm line 251.
Mon Mar 1 12:29:07 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/ServerManager.pm, ln263] Got fatal error, stopping operations
Mon Mar 1 12:29:07 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln386] Error happend on checking configurations. at /usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm line 300.
Mon Mar 1 12:29:07 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln482] Error happened on monitoring servers.
Mon Mar 1 12:29:07 2021 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

查看每个MySQL中是不是都有对manager节点的授权了,如果有的话刷新一下授权表;

7. materha_check_repl检测遇到的问题:

[root@manager ~]# masterha_check_repl -conf=/etc/mha_master/mha.cnf
Mon Mar 1 12:34:06 2021 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Mar 1 12:34:06 2021 - [info] Reading application default configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 12:34:06 2021 - [info] Reading server configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 12:34:06 2021 - [info] MHA::MasterMonitor version 0.55.
Mon Mar 1 12:34:07 2021 - [info] Dead Servers:
Mon Mar 1 12:34:07 2021 - [info] Alive Servers:
Mon Mar 1 12:34:07 2021 - [info] 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 12:34:07 2021 - [info] 192.168.10.30(192.168.10.30:3306)
Mon Mar 1 12:34:07 2021 - [info] 192.168.10.40(192.168.10.40:3306)
Mon Mar 1 12:34:07 2021 - [info] Alive Slaves:
Mon Mar 1 12:34:07 2021 - [info] 192.168.10.30(192.168.10.30:3306) Version=5.5.68-MariaDB (oldest major version between slaves) log-bin:enabled
Mon Mar 1 12:34:07 2021 - [info] Replicating from 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 12:34:07 2021 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Mar 1 12:34:07 2021 - [info] 192.168.10.40(192.168.10.40:3306) Version=5.5.68-MariaDB (oldest major version between slaves) log-bin:enabled
Mon Mar 1 12:34:07 2021 - [info] Replicating from 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 12:34:07 2021 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Mar 1 12:34:07 2021 - [info] Current Alive Master: 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 12:34:07 2021 - [info] Checking slave configurations..
Mon Mar 1 12:34:07 2021 - [info] Checking replication filtering settings..
Mon Mar 1 12:34:07 2021 - [info] binlog_do_db= , binlog_ignore_db=
Mon Mar 1 12:34:07 2021 - [info] Replication filtering check ok.
Mon Mar 1 12:34:07 2021 - [info] Starting SSH connection tests..
Mon Mar 1 12:34:10 2021 - [info] All SSH connection tests passed successfully.
Mon Mar 1 12:34:10 2021 - [info] Checking MHA Node version..
Mon Mar 1 12:34:10 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/ManagerUtil.pm, ln122] Got error when getting node version. Error:
Mon Mar 1 12:34:10 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/ManagerUtil.pm, ln123]
Can't locate MHA/BinlogManager.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/bin/apply_diff_relay_logs line 24.
BEGIN failed--compilation aborted at /usr/bin/apply_diff_relay_logs line 24.
Mon Mar 1 12:34:10 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/ManagerUtil.pm, ln151] node version on 192.168.10.30 not found! Maybe MHA Node package is not installed?
at /usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm line 346.
Mon Mar 1 12:34:10 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln386] Error happend on checking configurations. node version on 192.168.10.30 not found! Maybe MHA Node package is not installed?
at /usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm line 346.
...propagated at /usr/lib/perl5/vendor_perl//MHA/ManagerUtil.pm line 152.
Mon Mar 1 12:34:10 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln482] Error happened on monitoring servers.
Mon Mar 1 12:34:10 2021 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

解决办法:ln -s /usr/lib/perl5/vendor_perl/MHA /usr/lib64/perl5/vendor_perl/

8. materha_check_repl检测遇到的问题:

[root@manager ~]# masterha_check_repl -conf=/etc/mha_master/mha.cnf
Mon Mar 1 15:16:22 2021 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Mon Mar 1 15:16:22 2021 - [info] Reading application default configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 15:16:22 2021 - [info] Reading server configurations from /etc/mha_master/mha.cnf..
Mon Mar 1 15:16:22 2021 - [info] MHA::MasterMonitor version 0.55.
Mon Mar 1 15:16:23 2021 - [info] Dead Servers:
Mon Mar 1 15:16:23 2021 - [info] Alive Servers:
Mon Mar 1 15:16:23 2021 - [info] 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 15:16:23 2021 - [info] 192.168.10.30(192.168.10.30:3306)
Mon Mar 1 15:16:23 2021 - [info] 192.168.10.40(192.168.10.40:3306)
Mon Mar 1 15:16:23 2021 - [info] Alive Slaves:
Mon Mar 1 15:16:23 2021 - [info] 192.168.10.30(192.168.10.30:3306) Version=5.5.68-MariaDB (oldest major version between slaves) log-bin:enabled
Mon Mar 1 15:16:23 2021 - [info] Replicating from 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 15:16:23 2021 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Mar 1 15:16:23 2021 - [info] 192.168.10.40(192.168.10.40:3306) Version=5.5.68-MariaDB (oldest major version between slaves) log-bin:enabled
Mon Mar 1 15:16:23 2021 - [info] Replicating from 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 15:16:23 2021 - [info] Primary candidate for the new Master (candidate_master is set)
Mon Mar 1 15:16:23 2021 - [info] Current Alive Master: 192.168.10.20(192.168.10.20:3306)
Mon Mar 1 15:16:23 2021 - [info] Checking slave configurations..
Mon Mar 1 15:16:23 2021 - [info] Checking replication filtering settings..
Mon Mar 1 15:16:23 2021 - [info] binlog_do_db= , binlog_ignore_db=
Mon Mar 1 15:16:23 2021 - [info] Replication filtering check ok.
Mon Mar 1 15:16:23 2021 - [info] Starting SSH connection tests..
Mon Mar 1 15:16:25 2021 - [info] All SSH connection tests passed successfully.
Mon Mar 1 15:16:25 2021 - [info] Checking MHA Node version..
Mon Mar 1 15:16:26 2021 - [info] Version check ok.
Mon Mar 1 15:16:26 2021 - [info] Checking SSH publickey authentication settings on the current master..
Mon Mar 1 15:16:26 2021 - [info] HealthCheck: SSH to 192.168.10.20 is reachable.
Mon Mar 1 15:16:27 2021 - [info] Master MHA Node version is 0.54.
Mon Mar 1 15:16:27 2021 - [info] Checking recovery script configurations on the current master..
Mon Mar 1 15:16:27 2021 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/var/lib/mysql,/var/log/mysql --output_file=/mydata/mha_masterapp1/save_binary_logs_test --manager_version=0.55 --start_file=mysql-bin.000002
Mon Mar 1 15:16:27 2021 - [info] Connecting to root@192.168.10.20(192.168.10.20)..
Creating /mydata/mha_masterapp1 if not exists.. ok.
Checking output directory is accessible or not..
ok.
Binlog found at /var/lib/mysql, up to mysql-bin.000002
Mon Mar 1 15:16:27 2021 - [info] Master setting check done.
Mon Mar 1 15:16:27 2021 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Mon Mar 1 15:16:27 2021 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='mhaadmin' --slave_host=192.168.10.30 --slave_ip=192.168.10.30 --slave_port=3306 --workdir=/mydata/mha_masterapp1 --target_version=5.5.68-MariaDB --manager_version=0.55 --relay_log_info=/var/lib/mysql/relay-log.info --relay_dir=/var/lib/mysql/ --slave_pass=xxx
Mon Mar 1 15:16:27 2021 - [info] Connecting to root@192.168.10.30(192.168.10.30:22)..
Checking slave recovery environment settings..
Opening /var/lib/mysql/relay-log.info ... ok.
Relay log found at /var/lib/mysql, up to mysql-relay-bin.000005
Temporary relay log file is /var/lib/mysql/mysql-relay-bin.000005
Testing mysql connection and privileges..ERROR 1045 (28000): Access denied for user 'mhaadmin'@'slave1' (using password: YES)
mysql command failed with rc 1:0!
at /usr/bin/apply_diff_relay_logs line 367.
main::check() called at /usr/bin/apply_diff_relay_logs line 486
eval {...} called at /usr/bin/apply_diff_relay_logs line 466
main::main() called at /usr/bin/apply_diff_relay_logs line 112
Mon Mar 1 15:16:28 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln195] Slaves settings check failed!
Mon Mar 1 15:16:28 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln375] Slave configuration failed.
Mon Mar 1 15:16:28 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln386] Error happend on checking configurations. at /usr/bin/masterha_check_repl line 48.
Mon Mar 1 15:16:28 2021 - [error][/usr/lib/perl5/vendor_perl//MHA/MasterMonitor.pm, ln482] Error happened on monitoring servers.
Mon Mar 1 15:16:28 2021 - [info] Got exit code 1 (Not master dead).

MySQL Replication Health is NOT OK!

这里可能是MHA自动识别主机名对主机名进行解析,在/etc/hosts下添加解析就行了;

9. 启动MHA时候的报错:

Mon Mar 1 16:03:14 2021 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.10.20' (4))
Mon Mar 1 16:03:14 2021 - [warning] Connection failed 1 time(s)..
Mon Mar 1 16:03:15 2021 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.10.20' (4))
Mon Mar 1 16:03:15 2021 - [warning] Connection failed 2 time(s)..
Mon Mar 1 16:03:16 2021 - [warning] Got error on MySQL connect: 2003 (Can't connect to MySQL server on '192.168.10.20' (4))
Mon Mar 1 16:03:16 2021 - [warning] Connection failed 3 time(s)..
Mon Mar 1 16:03:18 2021 - [warning] HealthCheck: Got timeout on checking SSH connection to 192.168.10.20! at /usr/lib/perl5/vendor_perl//MHA/HealthCheck.pm line 298.
Mon Mar 1 16:03:18 2021 - [warning] Master is not reachable from health checker!
Mon Mar 1 16:03:18 2021 - [warning] Master 192.168.10.20(192.168.10.20:3306) is not reachable!
Mon Mar 1 16:03:18 2021 - [warning] SSH is NOT reachable.
Mon Mar 1 16:03:18 2021 - [info] Connecting to a master server failed. Reading configuration file /etc/masterha_default.cnf and /etc/mha_master/mha.cnf again, and trying to connect to all servers to check server status..

这里连接不上master节点,还是主机名解析的问题,添加/etc/hosts解析;

10. 切换master节点后,MHA会down掉,添加新节点后,需要重启,新的从节点可能没有对manager的授权,需要刷新一下授权表;

MHA架构搭建中遇到的问题的更多相关文章

  1. CentOS6.8下MySQL MHA架构搭建笔记

    转载请注明出处,本文地址:http://www.cnblogs.com/ajiangg/p/6552855.html 以下是CentOS6.8下MySQL MHA架构搭建笔记 IP资源规划: 192. ...

  2. mysql MHA架构搭建过程

    [环境介绍] 系统环境:Red Hat Enterprise Linux 7 + 5.7.18 + MHA version 0.57 系统 IP 主机名 备注 版本 xx系统 192.168.142. ...

  3. CENTOS6.6 下mysql MHA架构搭建

    本文来自我的github pages博客http://galengao.github.io/ 即www.gaohuirong.cn 摘要: 本篇是自己搭建的一篇mysql MHA文章 前面的安装步骤基 ...

  4. MySQL高可用架构之基于MHA的搭建

    一.MySQL MHA架构介绍: MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Fa ...

  5. MySQL高可用之MHA的搭建 转

     http://www.cnblogs.com/muhu/p/4045780.html http://www.cnblogs.com/gomysql/p/3675429.html http://www ...

  6. MySQL高可用之MHA的搭建

    MySQL MHA架构介绍: MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Face ...

  7. 美团点评基于MGR的CMDB高可用架构搭建之路【转】

    王志朋 美团点评DBA 曾在京东金融担任DBA,目前就职于美团点评,主要负责金融业务线数据库及基础组件数据库的运维. MySQL Group Replication(以下简称MGR),于5.7.17版 ...

  8. 用c#开发微信 (11) 微统计 - 阅读分享统计系统 1 基础架构搭建

    微信平台自带的统计功能太简单,有时我们需要统计有哪些微信个人用户阅读.分享了微信公众号的手机网页,以及微信个人用户访问手机网页的来源:朋友圈分享访问.好友分享消息访问等.本系统实现了手机网页阅读.分享 ...

  9. mvc项目架构搭建之UI层的搭建

    项目架构搭建之UI层的搭建 Contents 系列一[架构概览] 0.项目简介 1.项目解决方案分层方案 2.所用到的技术 3.项目引用关系 系列二[架构搭建初步] 4.项目架构各部分解析 5.项目创 ...

随机推荐

  1. 2019牛客多校第三场D-Big Integer

    题意 定义\(A(n)\) 为 n个1表示的十进制数,例如\(A(3) = 111\) 然后对于\(1 \le i \le n,1\le j \le m\) 问有多少的 \(pairs(i,j)\)满 ...

  2. Codeforces错题本

    为什么我这么菜啊QAQ Codeforces 1364C

  3. Educational Codeforces Round 91 (Rated for Div. 2) A. Three Indices

    题目链接:https://codeforces.com/contest/1380/problem/A 题意 给出一个大小为 $n$ 的排列,找出是否有三个元素满足 $p_i < p_j\ and ...

  4. 【POJ 2411】【Mondriaans Dream】 状压dp+dfs枚举状态

    题意: 给你一个高为h,宽为w的矩阵,你需要用1*2或者2*1的矩阵填充它 问你能有多少种填充方式 题解: 如果一个1*2的矩形横着放,那么两个位置都用二进制1来表示,如果是竖着放,那么会对下一层造成 ...

  5. Revit二次开发环境配置(Revit 2020 +Visual Studio 2019)

    Revit二次开发环境搭建(Revit 2019+Visual Studio 2017)准备内容 Revit 2019开发环境的搭建,需要安装的内容如下: Revit 2019(主要的开发环境) Vi ...

  6. MySQL 字符集及校验规则

    字符集 Mysql 的字符集有4个级别的默认设置:服务器级,数据库级,表级和字段级,客户端交互时,也可以指定字符集 # 字符集:是一个系统支持的所有抽象字符的集合.字符是各种文字和符号的总称,包括各国 ...

  7. List遍历以及剔除指定数据

    一.list三种遍历方式 1.for循环 List<String> list = new ArrayList<String>(); list.add("A" ...

  8. SPN在域环境中的应用

    0X01 SPN    服务主体名称(SPN)是Kerberos客户端用于唯一标识给特定Kerberos目标计算机的服务实例名称.Kerberos身份验证使用SPN将服务实例与服务登录帐户相关联.如果 ...

  9. js camelCase formatter

    js camelCase formatter 驼峰命名 转换器 'A'.charCodeAt(); // 65 'Z'.charCodeAt(); // 90 'a'.charCodeAt(); // ...

  10. .NET 面试题: C# override && overloading (C# 覆写 && 重载)

    1 1 1 .NET 面试题, C# ,override , overloading, 覆写, 重载,.NET,ASP.NET, override (覆写/重写): 方法名相同,参数的个数和类型相同, ...