>  기사  >  데이터 베이스  >  MHA masterha_check_repl 检测过程

MHA masterha_check_repl 检测过程

WBOY
WBOY원래의
2016-06-07 16:07:361108검색

MHA部署及配置是否OK,我们可以借助于MHA自带的masterha_check_ssh以及masterha_check_repl脚本来检测。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 [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  :
    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)

성명:
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
이전 기사:MHA 在线切换过程다음 기사:MHA VIP切换脚本