MHA masterha_check_repl 检测过程

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

1、当前的主从环境 [root@vdbsrv1 ~]# 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环境 [root@vdbsrv4 ~]# more /etc/issue CentOS release 5.9 (Final) Kernel \r on an \m

###mysql环境 [root@vdbsrv4 ~]# mysql -e "show variables like 'version'" +---------------+------------+ | Variable_name | Value      | +---------------+------------+ | version       | 5.6.22-log | +---------------+------------+

[root@vdbsrv4 ~]# masterha_manager --version masterha_manager version 0.56.

2、当前的MHA配置信息 [root@vdbsrv4 ~]$ 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、实际检测过程  [root@vdbsrv4 ~]# 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 root@192.168.1.6(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 root@192.168.1.7(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 root@192.168.1.8(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.

本文参与腾讯云自媒体分享计划,欢迎正在阅读的你也加入,一起分享。

发表于

我来说两句

0 条评论
登录 后参与评论

相关文章

来自专栏一个会写诗的程序员的博客

Springboot从HellWorld开始第三章 从HellWorld开始

https://github.com/LightSwordSpringBoot/lightsword_helloworld

1303
来自专栏一个会写诗的程序员的博客

Spring Boot 2.0 内嵌 Tomcat 定制 : WebServerFactoryCustomizer

Spring Boot 2.0 内嵌 Tomcat 定制 : WebServerFactoryCustomizer

1832
来自专栏我是攻城师

Spring Boot开发之明月千城(一)

3493
来自专栏闻道于事

Spring Boot入门

Spring Boot入门: 使用IDEA创建Spring Boot 项目: 选择 ? 勾选Web ? 生成项目结构: ? 例子: package com.ex...

2944
来自专栏码匠的流水账

使用openjdk9-alpine运行springboot2

本文主要研究怎么在docker的java9镜像上运行springboot2并精简jdk.

5971
来自专栏bboysoul

社会工程学信息收集工具(Userrecon)

这个工具最主要的功能就是可以让你在知道用户名的情况下批量去各个社交网站上查找这个用户名的主页,方便收集对象的主页

3584
来自专栏happyJared

Spring Boot几种启动问题的解决方案

  使用Spring Boot以来,遇到和解决过好几次不同的项目启动问题,大多数事故起于错误的配置和依赖。因此,本文用于汇总这些问题,以及提供相应的解决方案,帮...

6111
来自专栏Dawnzhang的开发者手册

@Controller和@RestController的区别?

1)如果只是使用@RestController注解Controller,则Controller中的方法无法返回jsp页面,配置的视图解析器InternalRes...

3713
来自专栏一个会写诗的程序员的博客

下载最新eclipse,jdk路径报错

863
来自专栏增长技术

Maven部署Web项目到Tomcat的配置

Maven自动部署实际上调的是Tomcat安装目录下的manager功能。而为了能正常访问http://localhost:8080/manager页面,我们需...

3753

扫码关注云+社区

领取腾讯云代金券