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. mybatis Sql语句配置详解

    sql语句配置 id sqlSession执行的唯一标识 resultMap 结果集封装映射,可用于内部对象一对多封装 resultType 返回的结果类型,直接就是一个po对象 resultSets ...

  2. 回文树(回文自动机PAM)小结

    回文树学习博客:lwfcgz    poursoul 边写边更新,大概会把回文树总结在一个博客里吧... 回文树的功能 假设我们有一个串S,S下标从0开始,则回文树能做到如下几点: 1.求串S前缀0~ ...

  3. SCZ 20170812 T2 MFS

    题面照例十分暴力,我再次重写一下吧-- 题目描述 有\(n\)个数构成的数列\(A\)元素为\(a_i\),你要构造一个数列\(B\),元素为\(b_i\),使得满足\(b_{i}>0,a_{i ...

  4. k倍区间(解题报告)前缀和简单应用

    测评地址 问题 1882: [蓝桥杯][2017年第八届真题]k倍区间 时间限制: 1Sec 内存限制: 128MB 提交: 351 解决: 78 题目描述 给定一个长度为N的数列,A1, A2, . ...

  5. AtCoder Beginner Contest 188 C - ABC Tournament (模拟)

    题意:有\(2^n\)个人站成一排比赛,刚开始每个人都和自己右边的人进行比赛,赢得人晋级下一轮(下标的小的在前面),不断重复这个过程,问最后拿到第二名的人的编号. 题解:根据题意,可以用vector直 ...

  6. 一维二维Sparse Table

    写在前面: 记录了个人的学习过程,同时方便复习 Sparse Table 有些情况,需要反复读取某个指定范围内的值而不需要修改 逐个判断区间内的每个值显然太浪费时间 我们希望用空间换取时间 ST表就是 ...

  7. 抓取QQ音乐歌单

    抓取QQ音乐歌单1.通过分析歌曲下载路径来分析所需参数: 通过比较, 得出其中歌曲下载url与参数vkey是可变的,歌曲下载url中可变得值是请求歌单返回的歌曲数据的strMediaMid参数, 而v ...

  8. 14. 从0学ARM-exynos4412-看门狗裸机程序编写

    看门狗 一.概念 看门狗的简称是WDT(Watch Dog Timer),exynos4412scp中的看门狗定时器(WDT)是一种定时装置. 1. 工作原理 由(一般需要客户编写)软件读写定时器相关 ...

  9. 使VS开发的程序在Win7系统运行时自动提升权限

    软件开发时,总是会遇到在Win7系统上运行不起来或者异常的情况,这通常是用户的权限不够引起的. 下面提供一个可以使程序运行时,自动提升用户权限的方法. 1.右键点击启动项目,单击"属性&qu ...

  10. 缓冲区溢出实验 4 内存管理(类似于malloc free)

    实验环境.代码.及准备 https://www.cnblogs.com/lqerio/p/12870834.html vul4 观察foo函数,可见问题在于最后一次tfree(q).由于之前已经tfr ...