MHA原理服务角色MHA(Master HA)是一款开源的 MysqL 的高可用程序,它为 MysqL 主从复制架构提供了 automating master failover 功能。MHA 在监控到 master 节点故障时,会提升其中拥有最新数据的 slave 节点成为新的master 节点,在此期间,MHA 会通过于其它从节点获取额外信息来避免一致性方面的问题。MHA 还提供了 master 节点的在线切换功能,即按需切换 master/slave 节点。
MHA 是由日本人 yoshinorim(原就职于DeNA现就职于FaceBook)开发的比较成熟的 MysqL 高可用方案。MHA只负责MysqL主库的高可用,主库发生故障时,MHA会选择一个数据最接近原主库的候选节点作为新的主节点,并补齐和之前Dead Master差异的binlog,数据补齐之后,将写vip飘逸到新主库上对外提供服务.MHA还提供在线主库切换的功能,能够安全地切换当前运行的主库到一个新的主库上(通过将从库提升为主库)大概0.5-2秒即可完成.
MHA服务有两种角色,MHA Manager(管理节点)和MHA Node(数据节点)
MHA Manager
通常单独部署在一台独立机器上管理多个 master/slave 集群(组),每个 master/slave 集群称作一个 application,用来管理统筹整个集群。
MHA node
运行在每台 MysqL 服务器上(master/slave/manager),它通过监控具备解析和清理 logs 功能的脚本来加快故障转移
主要是接收管理节点所发出指令的代理,代理需要运行在每一个 MysqL 节点上。简单讲 node 就是用来收集从节点服务器上所生成的 bin-log 。对比打算提升为新的主节点之上的从节点的是否拥有并完成 *** 作,如果没有发给新主节点在本地应用后提升为主节点。
由上图我们可以看出,每个复制组内部和 Manager 之间都需要ssh实现无密码互连,只有这样,在 Master 出故障时, Manager 才能顺利的连接进去,实现主从切换功能。
/* 当Master出现故障时,他可以自动将最新数据的Slave提升为新的Master,然后将所有其他的Slave重新指向新的Master,整个故障转移过程对应的程序是完全透明的.*/
工作原理# MHA工作原理总结为以下几条:# 1 从宕机崩溃的 master 保存二进制日志事件(binlog events);# 2 识别含有最新更新的 slave ;# 3 应用差异的中继日志(relay log) 到其他 slave ;# 4 应用从 master 保存的二进制日志事件(binlog events);# 5 提升一个 slave 为新 master ;# 6 使用其他的 slave 连接新的 master 进行复制。
环境配置在MHA自动故障切换过程中,MHA试图从宕机的主服务器上保存二进制日志,最大程度的保证数据的不丢失,但这并不总是可行的。例如,如果主服务器硬件故障或无法通过ssh访问,MHA没法保存二进制日志,只进行故障转移而丢失了最新的数据。使用MysqL 5.5的半同步复制,可以大大降低数据丢失的风险。MHA可以与半同步复制结合起来。如果只有一个slave已经收到了最新的二进制日志,MHA可以将最新的二进制日志应用于其他所有的slave服务器上,因此可以保证所有节点的数据一致性
MHA 对 MysqL 复制环境有特殊要求,例如各节点都要开启二进制日志及中继日志,各从节点必须显示启用其
read-only
属性,并关闭relay_log_purge
功能等,这里对配置做事先说明。
主机名 | IP | 服务角色 | 备注 |
---|---|---|---|
Manager | 192.168.43.125 | Manager控制器 | 监控管理 |
master | 192.168.43.241 | 数据库主 | |
slave1 | 192.168.43.183 | 数据库从 | |
slave2 | 192.168.43.252 | 数据库从 |
注意是四台机器互相喔
echo -e "\n" |ssh-keygen -t dsa -N "" ssh-copy-ID -i .ssh/ID_dsa.pub slave1ssh-copy-ID -i .ssh/ID_dsa.pub slave2ssh-copy-ID -i .ssh/ID_dsa.pub master
准备MysqL主从复制环境注意
binlog-do-db 和 replicate-ignore-db 设置必须相同。 MHA 在启动时候会检测过滤规则,如果过滤规则不同,MHA 不启动监控和故障转移
tar xf MysqL-5.7.25-linux-glibc2.12-x86_64.tar.gz -C /usr/local/useradd MysqL -s /sbin/nologin -Mmv MysqL-5.7.25-linux-glibc2.12-x86_64 /usr/local/MysqLcd /usr/local/MysqLmkdir logs\cp support-files/MysqL.server /etc/init.d/MysqLdchmod +x /etc/init.d/MysqLd chown -R MysqL:MysqL /usr/local/MysqL/ln -s /usr/local/MysqL/bin/* /usr/local/bin/chkconfig --add MysqLdMysqLd --initialize-insecure --user=MysqL --basedir=/usr/local/MysqL/ --datadir=/usr/local/MysqL/data/`/etc/my.cnf master`[MysqLd]basedir=/usr/local/MysqL/datadir=/usr/local/MysqL/datasocket=/usr/local/MysqL/MysqL.sockport=3306log_error=/usr/local/MysqL/logs/error.logserver-ID = 1binlog_format = rowexpire_logs_days = 30max_binlog_size = 100MgtID_mode = ONenforce_gtID_consistency = ONlog-bin = /usr/local/MysqL/logs/MysqL-binlog_bin_index = /usr/local/MysqL/logs/MysqL-bin.indexlog-slave-updates = ON[MysqLd_safe]log_error=/usr/local/MysqL/logs/error.logpID-file=/usr/local/MysqL/logs/MysqL.pID[clIEnt]socket=/usr/local/MysqL/MysqL.sock/etc/init.d/MysqLd startMysqLset password=password('ZHOUjian.22');
配置从节点`/etc/my.cnf slave1`cat /etc/my.cnf[MysqLd]basedir=/usr/local/MysqL/datadir=/usr/local/MysqL/datasocket=/usr/local/MysqL/MysqL.sockport=3306log_error=/usr/local/MysqL/logs/error.logserver-ID = 2gtID_mode = ONenforce_gtID_consistency = ONlog-slave-updates = ONskip-slave-start = trueexpire_logs_days = 30max_binlog_size = 100Mread_only = ONlog-bin = /usr/local/MysqL/logs/MysqL-binlog_bin_index = /usr/local/MysqL/logs/MysqL-bin.indexrelay-log = /usr/local/MysqL/logs/relay-logrelay-log-index = /usr/local/MysqL/logs/relay-log-indexrelay-log-info-file = /usr/local/MysqL/logs/relay-log.infomaster-info-repository = tablerelay-log-info-repository = table[MysqLd_safe]log_error=/usr/local/MysqL/logs/error.logpID-file=/usr/local/MysqL/logs/MysqL.pID[clIEnt]socket=/usr/local/MysqL/MysqL.sock`/etc/my.cnf slave2`cat /etc/my.cnf[MysqLd]basedir=/usr/local/MysqL/datadir=/usr/local/MysqL/datasocket=/usr/local/MysqL/MysqL.sockport=3306log_error=/usr/local/MysqL/logs/error.logserver-ID = 3gtID_mode = ONenforce_gtID_consistency = ONlog-slave-updates = ONskip-slave-start = trueexpire_logs_days = 30max_binlog_size = 100Mread_only = ONlog-bin = /usr/local/MysqL/logs/MysqL-binlog_bin_index = /usr/local/MysqL/logs/MysqL-bin.indexrelay-log = /usr/local/MysqL/logs/relay-logrelay-log-index = /usr/local/MysqL/logs/relay-log-indexrelay-log-info-file = /usr/local/MysqL/logs/relay-log.infomaster-info-repository = tablerelay-log-info-repository = table[MysqLd_safe]log_error=/usr/local/MysqL/logs/error.logpID-file=/usr/local/MysqL/logs/MysqL.pID[clIEnt]socket=/usr/local/MysqL/MysqL.sock
配置slave一主多从复制`主库执行以下增加权限配置`MysqL> grant replication slave on *.* to 'repl'@'192.168.43.%' IDentifIEd by 'ZHOUjian.22';MysqL> grant all privileges on *.* to 'mha'@'192.168.43.%' IDentifIEd by 'ZHOUjian.22';MysqL> flush privileges;`两个从库添加repl同步权限`change master to master_host='192.168.43.241',master_user='repl',master_password='ZHOUjian.22',master_auto_position=1;start slave;show slave status\G; Slave_IO_Running: Yes # io_thread 负责从主master取数据 Slave_sql_Running: Yes # sql_thread 从取来数据应用到从库上
检测一主多从复制master节点
MysqL> show processList;+----+------+---------------+------+-------------+------+---------------------------------------------------------------+------------------+| ID | User | Host | db | Command | Time | State | Info |+----+------+---------------+------+-------------+------+---------------------------------------------------------------+------------------+| 6 | repl | MysqL03:40668 | NulL | binlog Dump | 2922 | Master has sent all binlog to slave; waiting for more updates | NulL || 7 | root | localhost | NulL | query | 0 | starting | show processList || 8 | repl | manager:56232 | NulL | binlog Dump | 9 | Master has sent all binlog to slave; waiting for more updates | NulL |+----+------+---------------+------+-------------+------+---------------------------------------------------------------+------------------+3 rows in set (0.00 sec)
安装配置MHA在所有 MysqL 节点授权拥有管理权限的用户可在本地网络中有其他节点上远程访问。 当然, 此时仅需要且只能在 master 节点运行类似如下 sql 语句即可。
wget https://github.com/yoshinorim/mha4MysqL-manager/releases/download/v0.58/mha4MysqL-manager-0.58-0.el7.centos.noarch.rpm wget https://github.com/yoshinorim/mha4MysqL-node/releases/download/v0.58/mha4MysqL-node-0.58-0.el7.centos.noarch.rpm # 所有机器安装下面依赖包yum -y install perl-dbd-mysql -y# 三node节点分别安装rpm -ivh mha4MysqL-node-0.58-0.el7.centos.noarch.rpm# manager先安装node再安装manageryum install epel-release -yyum -y install perl-dbd-mysql perl-Config-Tiny perl-Log-dispatch perl-Parallel-ForkManager perl-Time-HiResrpm -ivh mha4MysqL-node-0.58-0.el7.centos.noarch.rpm rpm -ivh mha4MysqL-manager-0.58-0.el7.centos.noarch.rpm
配置机器之间免密ssh-keygen # 四台机器分别之间相互免密ssh-copy-ID 192.168.43.183ssh-copy-ID 192.168.43.47ssh-copy-ID 192.168.43.241ssh-copy-ID 192.168.43.252
配置全局@R_403_6179@mkdir -p /var/log/mha/mha1mkdir /etc/mhacat /etc/mha/mha1.cnf [server default]manager_log=/var/log/mha/mha1/managermanager_workdir=/var/log/mha/mha1master_binlog_dir=/usr/local/MysqL/datapassword=ZHOUjian.22Ping_interval=2repl_password=ZHOUjian.22repl_user=replssh_user=rootuser=mha[server1]hostname=192.168.43.241port=3306[server2]hostname=192.168.43.183port=3306[server3]hostname=192.168.43.252no_master=1port=3306# 测试配置[root@manager masterha]# masterha_check_ssh --conf=/etc/mha/mha1.cnf# Wed Oct 14 12:55:32 2020 - [info] All SSH connection tests passed successfully.[root@manager ~]# masterha_check_repl --conf=/etc/mha/mha1.cnf# MysqL Replication Health is OK.
启动mhanohup masterha_manager --conf=/etc/mha/mha1.cnf -remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/mha/mha1/manager.log 2>&1 &ps -ef |grep managerroot 14203 963 0 01:36 pts/0 00:00:00 grep --color=auto manager[1]+ Exit 1 nohup masterha_manager --conf=/etc/mha/mha1.cnf -remove_dead_master_conf --ignore_last_failover ha/mha1/manager.log < /dev/null > /var/log/m 2>&1
MHA管理软件包工具介绍提供的工具MHA会提供诸多工具程序,常见的如下所示
/* 1. Manager节点: 可以单独部署在一台独立的机器上管理多个master-slave集群,也可以部署在一台slave节点上 2. Node节点: 运行在每节点上*/
Manager节点
masterha_check_ssh: # MHA 依赖的 ssh 环境监测工具;masterha_check_repl:# MysqL 复制环境检测工具;masterga_manager: # MHA 服务主程序;启动MHA管理器,自动监控和自动故障转移 # 常用参数 # --conf={config file path}: # 应用或本地范围的配置参数文件,必须指定. # --global-conf={global config file path}: # 全局范围的配置参数,默认/etc/masterha_default.cnf # manager_workdir,--workdir: # manager工作的目录,存放mha manager产生关联的状态文件. # mastera_log,--log_output # 存放mha manager产生的日志文件,如果没有设置,将会使用标准输出. # 当执行failover,mha manager忽略此配置,使用标准的输出 # wait_on_monitor_error=(seconds): # 在监控的过程,当发出错误了,masterha_manager等待wait_no_monitor_error的时间后退出. # 如果设置为0,直接退出,这个好处,是当后台运行master monitor和failover scripts的时候,# masterha_manager可以在wait_no_monitor_error时间到达之前重启监控. # --ignore_fail_on_start # 默认的情况下,当一个或多个从库宕机后,主库监控(不是failover)进程无法启动,除非ignore_fail_on_start参数开启. # Failover参数 # --last_failover_minute=(minutes): # 当最近的一个failover切换发生在last_failover_minute(默认为8小时)之内,# MHA manager将不会切换,因为他会认为有些问题没有得到解决,如果设置了--ignore_last_failover参数,参数(--last_failover_minute)将会失效. # --ignore_last_failover: # 如果最近failover失败,MHA将不会再次开始failover机制: # 常规步骤: # 1. 手动清理failover错误文件,此文件一般在manager_workdir/app_name.failover.error文件,# 然后在启动failover机制,如果设置此参数,MHA将会继续failover不管上次failover状态. # wait_on_failover_error=(seconds) # 在failover的过程,masterha_manager等待wait_no_failover_error的时间后退出,# 如果设置为0,# masterha_manager可以在wait_no_failover_error时间到达之前重启监控. # --remove_dead_master_conf # 如果设置此参数,当成功failover后,MHA manager将会自动删除@R_403_6179@中关于dead master的配置选项.masterha_check_status:# MHA 运行状态探测工具;# Example[root@manager ~]# masterha_check_status --conf=/masterha/app1.cnfapp1 (pID:14555) is running(0:Ping_OK),master:192.168.43.241masterha_master_monitor: # MysqL master 节点可用性监测工具;masterha_master_swith:master:# 节点切换工具; # masterha_manager是一个自动监控和执行主服务器故障转移的程序,masterha_master_switch程序不监控master. # masterha_master_switch可以用于主服务故障转移,也可以用于在线切换. masterha_conf_host: # 添加或删除配置的节点;# 在某些情况,可能希望自动在@R_403_6179@中添加/删除主机条目,例如,当你设置新的从属服务器时,# 不需要手动编辑@R_403_6179@,只需添加新的主机条目.masterha_stop: # 关闭 MHA 服务的工具。
Node节点
这些工具都是由MHA Manager的脚本触发,无须认为 *** 作
save_binary_logs: # 保存和复制 master 的二进制日志;apply_diff_relay_logs:# 识别差异的中继日志事件并应用于其他 slave;purge_relay_logs: # 清除中继日志(不会阻塞 sql 线程);# MysqL数据库主从复制在缺省情况下从库的relay log会在sql线程执行完被自动删除,但对于MHA场景下,# 对于某些滞后从库的恢复依赖于其他从库的relay log,因此采取禁用自动删除功能以及定义清理的方法,# 对于清理过大的relay log需要注意引起的复制延迟,资源开销等,MHA可通过purge_relay_logs脚本及配置cronjob来完成此项任务.# 自定义扩展:secondary_check_script:# 通过多条网络路由检测master的可用性;master_ip_failover_script:# 更新application使用的masterip;report_script:# 发送报告;init_conf_load_script:# 加载初始配置参数; master_ip_online_change_script; # 更新master节点ip地址。
MHA自动故障转移模拟主数据库宕机
[root@master ~]# /etc/init.d/MysqLd stop[root@master ~]# tailf /var/log/mha/mha1/manager Thu Oct 15 01:16:37 2020 - [info] -- Slave recovery on host 192.168.43.252(192.168.43.252:3306) started,pID: 14071. Check tmp log /var/log/mha/mha1/192.168.43.252_3306_20201015011635.log if it takes time..Thu Oct 15 01:16:38 2020 - [info] Thu Oct 15 01:16:38 2020 - [info] Log messages from 192.168.43.252 ...Thu Oct 15 01:16:38 2020 - [info] Thu Oct 15 01:16:37 2020 - [info] resetting slave 192.168.43.252(192.168.43.252:3306) and starting replication from the new master 192.168.43.183(192.168.43.183:3306)..Thu Oct 15 01:16:37 2020 - [info] Executed CHANGE MASTER.Thu Oct 15 01:16:37 2020 - [info] Slave started.Thu Oct 15 01:16:37 2020 - [info] gtID_wait(21c673b5-0e3b-11eb-9f94-000c2923a3e6:1,a784a36d-0e39-11eb-9711-000c29053764:1-2) completed on 192.168.43.252(192.168.43.252:3306). Executed 2 events.Thu Oct 15 01:16:38 2020 - [info] End of log messages from 192.168.43.252.Thu Oct 15 01:16:38 2020 - [info] -- Slave on host 192.168.43.252(192.168.43.252:3306) started.Thu Oct 15 01:16:38 2020 - [info] All new slave servers recovered successfully.Thu Oct 15 01:16:38 2020 - [info] Thu Oct 15 01:16:38 2020 - [info] * Phase 5: New master cleanup phase..Thu Oct 15 01:16:38 2020 - [info] Thu Oct 15 01:16:38 2020 - [info] resetting slave info on the new master..Thu Oct 15 01:16:38 2020 - [info] 192.168.43.183: resetting slave info succeeded.Thu Oct 15 01:16:38 2020 - [info] Master failover to 192.168.43.183(192.168.43.183:3306) completed successfully.Thu Oct 15 01:16:38 2020 - [info] Deleted server1 entry from /etc/mha/mha1.cnf .Thu Oct 15 01:16:38 2020 - [info] ----- Failover Report -----mha1: MysqL Master failover 192.168.43.241(192.168.43.241:3306) to 192.168.43.183(192.168.43.183:3306) succeededMaster 192.168.43.241(192.168.43.241:3306) is down!Check MHA Manager logs at tracker1:/var/log/mha/mha1/manager for details.Started automated(non-interactive) failover.Selected 192.168.43.183(192.168.43.183:3306) as a new master.192.168.43.183(192.168.43.183:3306): OK: Applying all logs succeeded.192.168.43.252(192.168.43.252:3306): OK: Slave started,replicating from 192.168.43.183(192.168.43.183:3306)192.168.43.183(192.168.43.183:3306): resetting slave info succeeded.Master failover to 192.168.43.183(192.168.43.183:3306) completed successfully.
恢复主库
MysqL> change master to master_host='192.168.43.241',MASTER_PORT=3306,MASTER_USER='repl',MASTER_PASSWORD='ZHOUjian.22',MASTER_auto_position=1;MysqL> start slave;MysqL> SHOW SLAVE STATUS\G;*************************** 1. row *************************** Slave_IO_State: Master_Host: 192.168.43.241 Master_User: repl Master_Port: 3306 `验证主从切换` `我们可以查看183这台Mha自动切换的主库有两个从库了` MysqL> show processList;+----+------+---------------+------+------------------+------+---------------------------------------------------------------+------------------+| ID | User | Host | db | Command | Time | State | Info |+----+------+---------------+------+------------------+------+---------------------------------------------------------------+------------------+| 14 | repl | manager:10199 | NulL | binlog Dump GTID | 580 | Master has sent all binlog to slave; waiting for more updates | NulL || 15 | repl | MysqL02:46340 | NulL | binlog Dump GTID | 145 | Master has sent all binlog to slave; waiting for more updates | NulL || 16 | root | localhost | NulL | query | 0 | starting | show processList |+----+------+---------------+------+------------------+------+---------------------------------------------------------------+------------------+3 rows in set (0.00 sec)
重新将@R_403_6179@少去的宕机master配置加入到mha配置[root@manager ~]# cat /etc/mha/mha1.cnf [server default]manager_log=/var/log/mha/mha1/managermanager_workdir=/var/log/mha/mha1master_binlog_dir=/usr/local/MysqL/datapassword=ZHOUjian.22Ping_interval=2repl_password=ZHOUjian.22repl_user=replssh_user=rootuser=mha[server1]hostname=192.168.43.241port=3306[server2]hostname=192.168.43.183port=3306[server3]hostname=192.168.43.252no_master=1port=3306# 重启Mhanohup masterha_manager --conf=/etc/mha/mha1.cnf -remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/mha/mha1/manager.log 2>&1 &
发生故障时,MHA做了什么配置vip漂移漂移方式1 . 当作为master的192.168.43.241主机上的MysqL宕机以后,MHA通过检测发现192.168.43.241的MysqL宕机了,就会将binlog日志最全的从库192.168.43.183(备用master)立刻提升为主库,而其他的从库会指向新的主库进行再次同步.
2 . MHA自己会结束自己的进程,还会将/etc/mha/app1.cnf@R_403_6179@中发生故障的那台主机去除.
/* 1. 通过keepalived的方式,管理虚拟IP的漂移. 2. 通过MHA自带脚本的方式,管理虚拟IP的漂移,用mha自带的一个VIP漂移的脚本,那台服务器变为(master),就漂到那个上面,根据binlog最新的slave提升*/
编写漂移脚本[root@manager ~]# cat /usr/local/bin/master_ip_failover#!/usr/bin/env perl# copyright (C) 2011 DeNA Co.,Ltd.## This program is free software; you can redistribute it and/or modify# it under the terms of the GNU General Public license as published by# the Free Software Foundation; either version 2 of the license,or# (at your option) any later version.## This program is distributed in the hope that it will be useful,# but WITHOUT ANY WARRANTY; without even the implIEd warranty of# MERCHANTABIliTY or fitness FOR A PARTIculaR PURPOSE. See the# GNU General Public license for more details.## You should have received a copy of the GNU General Public license# along with this program; if not,write to the Free Software# Foundation,Inc.,# 51 Franklin Street,Fifth Floor,Boston,MA 02110-1301 USA## Note: This is a sample script and is not complete. Modify the script based on your environment.use strict;use warnings FATAL => 'all';use Getopt::Long;use MHA::DBHelper;my ( $command,$ssh_user,$orig_master_host,$orig_master_ip,$orig_master_port,$new_master_host,$new_master_ip,$new_master_port,$new_master_user,$new_master_password);my $vip = '192.168.43.100/24';my $key = '1';my $ssh_start_vip = "/sbin/ifconfig ens32:$key $vip";my $ssh_stop_vip = "/sbin/ifconfig ens32:$key down";Getoptions( 'command=s' => $command,'ssh_user=s' => $ssh_user,'orig_master_host=s' => $orig_master_host,'orig_master_ip=s' => $orig_master_ip,'orig_master_port=i' => $orig_master_port,'new_master_host=s' => $new_master_host,'new_master_ip=s' => $new_master_ip,'new_master_port=i' => $new_master_port,'new_master_user=s' => $new_master_user,'new_master_password=s' => $new_master_password,);exit &main();sub main { if ( $command eq "stop" || $command eq "stopssh" ) { # $orig_master_host,$orig_master_port are passed. # If you manage master ip address at global catalog database,# invalIDate orig_master_ip here. my $exit_code = 1; eval { # updating global catalog,etc $exit_code = 0; }; if ($@) { warn "Got Error: $@\n"; exit $exit_code; } exit $exit_code; } elsif ( $command eq "start" ) { # all arguments are passed. # If you manage master ip address at global catalog database,# activate new_master_ip here. # You can also grant write access (create user,set read_only=0,etc) here. my $exit_code = 10; eval { my $new_master_handler = new MHA::DBHelper(); # args: hostname,port,user,password,raise_error_or_not $new_master_handler->connect( $new_master_ip,$new_master_password,1 ); ## Set read_only=0 on the new master $new_master_handler->disable_log_bin_local(); print "Set read_only=0 on the new master.\n"; $new_master_handler->disable_read_only(); ## Creating an app user on the new master print "Creating app user on the new master..\n"; FIXME_xxx_create_user( $new_master_handler->{dbh} ); $new_master_handler->enable_log_bin_local(); $new_master_handler->disconnect(); ## Update master ip on the catalog database,etc # FIXME_xxx; $exit_code = 0; }; if ($@) { warn $@; # If you want to continue failover,exit 10. exit $exit_code; } exit $exit_code; } elsif ( $command eq "status" ) { # do nothing exit 0; } else { &usage(); exit 1; }}sub usage { print"Usage: master_ip_failover --command=start|stop|stopssh|status --orig_master_host=host --orig_master_ip=ip --orig_master_port=port --new_master_host=host --new_master_ip=ip --new_master_port=port\n";}
master添加vip[root@MysqL-master ~]# ifconfig ens32:1 192.168.43.100/24
防止manager监控程序自动死掉[root@manager ~]# cat /usr/local/bin/masterha_start.shnohup masterha_manager --conf=/etc/mha/mha1.cnf -remove_dead_master_conf --ignore_last_failover < /dev/null > /var/log/mha/mha1/manager.log 2>&1 &[root@manager ~]# chmod +x /usr/local/bin/masterha_start.sh[root@manager ~]# nohup /usr/local/bin/manager_status_check &[root@manager ~]# echo "nohup /usr/local/bin/manager_status_check &" >> /etc/rc.d/rc.local# 只要修复好主库,添加好配置就能自动运行,不用专门再去输入命令启动
总结 以上是内存溢出为你收集整理的Mysql通过MHA实现高可用全部内容,希望文章能够帮你解决Mysql通过MHA实现高可用所遇到的程序开发问题。
如果觉得内存溢出网站内容还不错,欢迎将内存溢出网站推荐给程序员好友。
欢迎分享,转载请注明来源:内存溢出
评论列表(0条)