MHA masterha_check_repl 检测过程

MHA部署及配置是否OK,我们可以借助于MHA自带的masterha_check_ssh以及masterha_check_repl脚本来检测。masterha_check_repl检测是保证MHA成功切换的重要一步。本文主要描述了masterha_check_repl这个检测脚本到底做了些什么事情。有助于更好的理解MHA的相关原理及过程等。

1、当前的主从环境
[roo[email protected] ~]# more /etc/hosts
127.0.0.1    localhost.localdomain localhost
192.168.1.6  vdbsrv1  #master
192.168.1.7  vdbsrv2  #slave1
192.168.1.8  vdbsrv3  #slave2
192.168.1.12 vdbsrv4  #manager

###os环境
[[email protected] ~]# more /etc/issue
CentOS release 5.9 (Final)
Kernel \r on an \m

###mysql环境
[[email protected] ~]# mysql -e "show variables like ‘version‘"
+---------------+------------+
| Variable_name | Value      |
+---------------+------------+
| version       | 5.6.22-log |
+---------------+------------+

[[email protected] ~]# masterha_manager --version
masterha_manager version 0.56.

2、当前的MHA配置信息
[[email protected] ~]$ more /etc/masterha/app1.cnf
[server default]
manager_workdir=/var/log/masterha/app1
manager_log=/var/log/masterha/app1/manager.log

user=mha
password=xxx
ssh_user=root
repl_user=repl  
repl_password=repl  
ping_interval=1
shutdown_script=""
master_ip_online_change_script=""
report_script=""
master_ip_failover_script=/tmp/master_ip_failover
 
[server1]
hostname=vdbsrv1
master_binlog_dir=/data/mysqldata

[server2]
hostname=vdbsrv2
master_binlog_dir=/data/mysqldata

[server3]
hostname=vdbsrv3
master_binlog_dir=/data/mysqldata/
#candidate_master=1

3、masterha_check_repl检测步骤
a、读取配置文件
b、检测配置文件中列出的mysql服务器(识别主从)
c、检测从库配置信息
    read_only参数
    relay_log_purge参数
    复制过滤规则
d、ssh等效性验证 
e、检测主库保存binlog脚本(save_binary_logs) ,主要是用于在master死掉后从binlog读取日志
f、检测各从库能否apply差量binlog(apply_diff_relay_logs)
g、检测IP切换,如果有部署脚本

4、实际检测过程 
[[email protected] ~]# masterha_check_repl --conf=/etc/masterha/app1.cnf
Fri Apr 17 18:48:41 2015 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Fri Apr 17 18:48:41 2015 - [info] Reading application default configuration from /etc/masterha/app1.cnf..
Fri Apr 17 18:48:41 2015 - [info] Reading server configuration from /etc/masterha/app1.cnf.. ###读取配置文件
Fri Apr 17 18:48:41 2015 - [info] MHA::MasterMonitor version 0.56.
Fri Apr 17 18:48:42 2015 - [info] GTID failover mode = 0
Fri Apr 17 18:48:42 2015 - [info] Dead Servers:   ###开始检测配置文件中列出的mysql服务器(识别主从)
Fri Apr 17 18:48:42 2015 - [info] Alive Servers:
Fri Apr 17 18:48:42 2015 - [info]   vdbsrv1(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info]   vdbsrv2(192.168.1.7:3306)
Fri Apr 17 18:48:42 2015 - [info]   vdbsrv3(192.168.1.8:3306)
Fri Apr 17 18:48:42 2015 - [info] Alive Slaves:
Fri Apr 17 18:48:42 2015 - [info]   vdbsrv2(192.168.1.7:3306)  Version=5.6.22-log (oldest major version between slaves) log-bin:enabled
Fri Apr 17 18:48:42 2015 - [info]     Replicating from 192.168.1.6(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info]   vdbsrv3(192.168.1.8:3306)  Version=5.6.22-log (oldest major version between slaves) log-bin:enabled
Fri Apr 17 18:48:42 2015 - [info]     Replicating from 192.168.1.6(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info] Current Alive Master: vdbsrv1(192.168.1.6:3306)
Fri Apr 17 18:48:42 2015 - [info] Checking slave configurations..  ###检测从库配置信息
Fri Apr 17 18:48:42 2015 - [info]  read_only=1 is not set on slave vdbsrv2(192.168.1.7:3306).
Fri Apr 17 18:48:42 2015 - [warning]  relay_log_purge=0 is not set on slave vdbsrv2(192.168.1.7:3306).
Fri Apr 17 18:48:42 2015 - [info]  read_only=1 is not set on slave vdbsrv3(192.168.1.8:3306).
Fri Apr 17 18:48:42 2015 - [warning]  relay_log_purge=0 is not set on slave vdbsrv3(192.168.1.8:3306).
Fri Apr 17 18:48:42 2015 - [info] Checking replication filtering settings..    ###检测复制过滤规则
Fri Apr 17 18:48:42 2015 - [info]  binlog_do_db= , binlog_ignore_db=
Fri Apr 17 18:48:42 2015 - [info]  Replication filtering check ok.
Fri Apr 17 18:48:42 2015 - [info] GTID (with auto-pos) is not supported
Fri Apr 17 18:48:42 2015 - [info] Starting SSH connection tests..              ###ssh等效性验证
Fri Apr 17 18:48:43 2015 - [info] All SSH connection tests passed successfully.
Fri Apr 17 18:48:43 2015 - [info] Checking MHA Node version..
Fri Apr 17 18:48:44 2015 - [info]  Version check ok.
Fri Apr 17 18:48:44 2015 - [info] Checking SSH publickey authentication settings on the current master..
Fri Apr 17 18:48:44 2015 - [info] HealthCheck: SSH to vdbsrv1 is reachable.
Fri Apr 17 18:48:44 2015 - [info] Master MHA Node version is 0.56.
Fri Apr 17 18:48:44 2015 - [info] Checking recovery script configurations on vdbsrv1(192.168.1.6:3306)..###检测主库保存binlog脚本
Fri Apr 17 18:48:44 2015 - [info]   Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/data/mysqldata
    --output_file=/var/tmp/save_binary_logs_test --manager_version=0.56 --start_file=mysql-bin.000012
Fri Apr 17 18:48:44 2015 - [info]   Connecting to [email protected](vdbsrv1:22)..
  Creating /var/tmp if not exists..    ok.
  Checking output directory is accessible or not..
   ok.
  Binlog found at /data/mysqldata, up to mysql-bin.000012
Fri Apr 17 18:48:44 2015 - [info] Binlog setting check done.  ###以下部分检测各从库能否apply差量binlog
Fri Apr 17 18:48:44 2015 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Fri Apr 17 18:48:44 2015 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=‘mha‘ --slave_host=vdbsrv2
 --slave_ip=192.168.1.7 --slave_port=3306 --workdir=/var/tmp --target_version=5.6.22-log --manager_version=0.56
 --relay_log_info=/data/mysqldata/relay-log.info  --relay_dir=/data/mysqldata/  --slave_pass=xxx
Fri Apr 17 18:48:44 2015 - [info]   Connecting to [email protected](vdbsrv2:22)..
  Checking slave recovery environment settings..
    Opening /data/mysqldata/relay-log.info ... ok.
    Relay log found at /data/mysqldata, up to vdbsrv2-relay-bin.000006
    Temporary relay log file is /data/mysqldata/vdbsrv2-relay-bin.000006
    Testing mysql connection and privileges.. done.  #Author : Leshami
    Testing mysqlbinlog output.. done.               #Blog   : http://blog.csdn.net/leshami
    Cleaning up test file(s).. done.
Fri Apr 17 18:48:44 2015 - [info]   Executing command : apply_diff_relay_logs --command=test --slave_user=‘mha‘ --slave_host=vdbsrv3
 --slave_ip=192.168.1.8 --slave_port=3306 --workdir=/var/tmp --target_version=5.6.22-log --manager_version=0.56
 --relay_log_info=/data/mysqldata/relay-log.info  --relay_dir=/data/mysqldata/  --slave_pass=xxx
Fri Apr 17 18:48:44 2015 - [info]   Connecting to [email protected](vdbsrv3:22)..
  Checking slave recovery environment settings..
    Opening /data/mysqldata/relay-log.info ... ok.
    Relay log found at /data/mysqldata, up to vdbsrv3-relay-bin.000006
    Temporary relay log file is /data/mysqldata/vdbsrv3-relay-bin.000006
    Testing mysql connection and privileges.. done.
    Testing mysqlbinlog output.. done.
    Cleaning up test file(s).. done.
Fri Apr 17 18:48:45 2015 - [info] Slaves settings check done.
Fri Apr 17 18:48:45 2015 - [info]
vdbsrv1(192.168.1.6:3306) (current master)
 +--vdbsrv2(192.168.1.7:3306)
 +--vdbsrv3(192.168.1.8:3306)

Fri Apr 17 18:48:45 2015 - [info] Checking replication health on vdbsrv2..
Fri Apr 17 18:48:45 2015 - [info]  ok.
Fri Apr 17 18:48:45 2015 - [info] Checking replication health on vdbsrv3..
Fri Apr 17 18:48:45 2015 - [info]  ok.
Fri Apr 17 18:48:45 2015 - [info] Checking master_ip_failover_script status:  ###检测IP切换
Fri Apr 17 18:48:45 2015 - [info]   /tmp/master_ip_failover --command=status --ssh_user=root --orig_master_host=vdbsrv1
  --orig_master_ip=192.168.1.6 --orig_master_port=3306

IN SCRIPT TEST====/sbin/ifconfig eth0:0 down==/sbin/ifconfig eth0:0 192.168.1.13/24===

Checking the Status of the script.. OK
Fri Apr 17 18:48:45 2015 - [info]  OK.
Fri Apr 17 18:48:45 2015 - [warning] shutdown_script is not defined.
Fri Apr 17 18:48:45 2015 - [info] Got exit code 0 (Not master dead).

MySQL Replication Health is OK.

时间: 2024-10-08 00:32:02

MHA masterha_check_repl 检测过程的相关文章

MHA自动Failover过程解析(updated) 转

允许转载, 转载时请以超链接形式标明文章原始出处和网站信息 http://www.mysqlsystems.com/2012/03/figure-out-process-of-autofailover-on-mha.html MHA自动Failover过程解析(updated) By zhang, on March 31st, 2012 MHA是一位日本MySQL大牛用Perl写的一套MySQL故障切换方案,来保证数据库系统的高可用.近期,在田老师的推动下,开始一步步深入了解这个HA方案,并也计

MHA在线切换过程

MySQL MHA 在线切换是MHA除了自动监控切换换提供的另外一种方式,多用于诸如硬件升级,MySQL数据库迁移等等.该方式提供快速切换和优雅的阻塞写入,无关关闭原有服务器,整个切换过程在0.5-2s 的时间左右,大大减少了停机时间.本文演示了MHA 在线切换并给出了在线切换的基本步骤. 1.MHA在线切换方式及要求    $ masterha_master_switch --master_state=alive --conf=/etc/app1.cnf --new_master_host=h

MHA 主从切换过程及日志分析

本文主要在MHA 切换日志的角度分析MHA切换的过.MHA故障切换过程如下图所示 第一部分:开启MHA 监控 通过分析日志,得到以下步骤: 1.读取MHA manager 节点的配置文件,并检查配置文件中参数设置的正确性. Sat Jun 22 20:16:29 2019 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping. Sat Jun 22 20:16:29 2019 - [

记一次Linux服务器被入侵后的检测过程

作者 | 哈兹本德     来源 | FreeBuf 0×00 前言 故事是这样的,大年初一,客户反应他们服务器无法访问,查看路由,发现某oracle+tomcat服务器UDP流量超大,把带宽占完了,过年嘛,客户那边先找了当地的技术人员弄了几天没搞定,然后没办法大年初三的找我们弄-顾客是上帝! 其实吧以前也遇到过这类攻击,当时某IDC都被打瘫了,只不过马儿不在我们的设备上,所以没过多关注- 0×01 查找木马 首先SSH登陆,top查看进程,发现奇怪名字的命令gejfhzthbp,一看就感觉有问

记一次CVE漏洞检测过程

今天对安全防御设备进行安全检查时,发现了中午某一时间段存在有大量攻击,次数600多次 查看下攻击源IP为当前局域网(如果是外网设备一定是攻击行为,需要进行黑名单处理) 不清楚是人工还是认为的爆破,所以我对其进行了一番调查 首先使用了nmap进行指纹探测,发现其存在大量端口开放,且服务器为windows2008 既然是winserver的 那应该不是人为了,难道这台机器被人攻击了?(不仅是外网机器,当然内网机器也是有可能被攻击过的) 我使用了nse脚本对其进行了漏洞探测: 发现多个端口运行了IIS

一次mysql MHA架构搭建过程

[环境介绍] 系统环境:Red Hat Enterprise Linux 7 + 5.7.18 + MHA version 0.57 系统 IP 主机名 备注 版本 xx系统 192.168.142.111 mysqlmha1 主库 5.7.18 -log MySQL Community Server (GPL) 192.168.142.112 mysqlmha2 备库(预主库) 192.168.142.113 mysqlmha3 备库/MHA MGM 192.168.142.111 mysql

局域网入侵检测过程详解

首先申明: 1.入侵的范围只包括局域网,如果在学校上,可以入侵整个校园网;2.能入侵的只是存在弱口令(用户名为administrator等,密码为空),或已知道账号密码 并且开了139端口,但没开防火墙的机子. 入侵工具:一般要用到三个:NTscan变态扫描器,Recton–D贺免杀专用版,DameWare迷你中文版 4.5. (前两个工具杀毒软件都会报毒,建议将杀毒软件实时防毒暂时关掉,并将这两个软件的压缩包加密,防止被杀.) 入侵步骤:1.使用”NTscan变态扫描器”,在IP处填上要扫描的

毕业课题之------------路面区域增强和整体检测过程

MHA 日常管理

MHA是众多使用MySQL数据库企业高可用的不二选择,它简单易用,功能强大,实现了基于MySQL replication架构的自动主从故障转移.本文主要描述MHA的日常相关操作,同时给出了关于MHA的相关连接,供大家参考. 一.MHA的主要脚本(perl)1.manager端masterha_check_ssh              检查MHA的SSH配置状况masterha_check_repl             检查MySQL复制状况masterha_manger