MySQL笔记-MHA(Master High Availability)搭建
这里以在Linux上个演示。
这里在SSH免密码登录的前提上个进行设置的。
如何设置免密登录,请看前一篇博文,或者搜索下,在此不再给出链接。
同样的3台主机
名称 | ip |
Centos 7 MySQL Master | 192.168.79.134 |
Centos 7 MySQL Slave | 192.168.79.136 |
Centos 7 MySQL Manager |
192.168.79.137 |
三台主机全部安装依赖:
yum install perl-DBD-MySQL
yum install perl-DBI
yum install mysql-libs
get http://dl.fedoraproject.org/pub/epel/epel-release-latest-7.noarch.rpm
rpm -ivh epel-release-latest-7.noarch.rpm
yum install -y perl-DBD-MySQL perl-Config-Tiny perl-Log-Dispatch perl-Parallel-ForkManager
然后在Manager上个,也就是192.168.79.137的机器上个安装控制端:
wget https://qiniu.wsfnk.com/mha4mysql-manager-0.58-0.el7.centos.noarch.rpm
rpm -ivh mha4mysql-manager-0.58-0.el7.centos.noarch.rpm
随后在Manager机器上个添加如下文件/etc/app1.cnf
[server default]
manager_workdir=/var/log/mha/app1
manager_log=/var/log/mha/app1/manager.log
user=root
password=root
ssh_user=root
repl_user=rep1
repl_password=rep1
ping_interval=1[server1]
hostname=192.168.79.134
port=3306
master_binlog_dir=/u01/mysql3306/log/binlog
candidate_master=1
check_repl_delay=0[server2]
hostname=192.168.79.136
port=3306
master_binlog_dir=/u01/mysql3306/log/binlog
candidate_master=1
check_repl_delay=0
这里改创建新路径要创建,master_binlog_dir需要改的就要改。
下面是一些常用命令:
masterha_check_ssh --conf=/etc/app1.cnf
masterha_check_repl --conf=/etc/app1.cnf
masterha_manager --conf=/etc/app1.cnf
masterha_check_status --conf=/etc/app1.cnf
masterha_stop --conf=/etc/app1.cnf
如下测试条命令:
[root@localhost ~]# masterha_check_ssh --conf=/etc/app1.cnf
Sat Jun 6 14:03:39 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sat Jun 6 14:03:39 2020 - [info] Reading application default configuration from /etc/app1.cnf..
Sat Jun 6 14:03:39 2020 - [info] Reading server configuration from /etc/app1.cnf..
Sat Jun 6 14:03:39 2020 - [info] Starting SSH connection tests..
Sat Jun 6 14:03:39 2020 - [debug]
Sat Jun 6 14:03:39 2020 - [debug] Connecting via SSH from root@192.168.79.134(192.168.79.134:22) to root@192.168.79.136(192.168.79.136:22)..
Sat Jun 6 14:03:39 2020 - [debug] ok.
Sat Jun 6 14:03:40 2020 - [debug]
Sat Jun 6 14:03:39 2020 - [debug] Connecting via SSH from root@192.168.79.136(192.168.79.136:22) to root@192.168.79.134(192.168.79.134:22)..
Sat Jun 6 14:03:39 2020 - [debug] ok.
Sat Jun 6 14:03:40 2020 - [info] All SSH connection tests passed successfully.
第二个:
[root@localhost ~]# masterha_check_repl --conf=/etc/app1.cnf
Sat Jun 6 16:36:33 2020 - [warning] Global configuration file /etc/masterha_default.cnf not found. Skipping.
Sat Jun 6 16:36:33 2020 - [info] Reading application default configuration from /etc/app1.cnf..
Sat Jun 6 16:36:33 2020 - [info] Reading server configuration from /etc/app1.cnf..
Sat Jun 6 16:36:33 2020 - [info] MHA::MasterMonitor version 0.58.
Sat Jun 6 16:36:34 2020 - [info] GTID failover mode = 0
Sat Jun 6 16:36:34 2020 - [info] Dead Servers:
Sat Jun 6 16:36:34 2020 - [info] Alive Servers:
Sat Jun 6 16:36:34 2020 - [info] mydb1(192.168.79.134:3306)
Sat Jun 6 16:36:34 2020 - [info] mydb2(192.168.79.136:3306)
Sat Jun 6 16:36:34 2020 - [info] Alive Slaves:
Sat Jun 6 16:36:34 2020 - [info] mydb2(192.168.79.136:3306) Version=5.7.25-log (oldest major version between slaves) log-bin:enabled
Sat Jun 6 16:36:34 2020 - [info] Replicating from 192.168.79.134(192.168.79.134:3306)
Sat Jun 6 16:36:34 2020 - [info] Primary candidate for the new Master (candidate_master is set)
Sat Jun 6 16:36:34 2020 - [info] Current Alive Master: mydb1(192.168.79.134:3306)
Sat Jun 6 16:36:34 2020 - [info] Checking slave configurations..
Sat Jun 6 16:36:34 2020 - [info] read_only=1 is not set on slave mydb2(192.168.79.136:3306).
Sat Jun 6 16:36:34 2020 - [warning] relay_log_purge=0 is not set on slave mydb2(192.168.79.136:3306).
Sat Jun 6 16:36:34 2020 - [info] Checking replication filtering settings..
Sat Jun 6 16:36:34 2020 - [info] binlog_do_db= , binlog_ignore_db=
Sat Jun 6 16:36:34 2020 - [info] Replication filtering check ok.
Sat Jun 6 16:36:34 2020 - [info] GTID (with auto-pos) is not supported
Sat Jun 6 16:36:34 2020 - [info] Starting SSH connection tests..
Sat Jun 6 16:36:35 2020 - [info] All SSH connection tests passed successfully.
Sat Jun 6 16:36:35 2020 - [info] Checking MHA Node version..
Sat Jun 6 16:36:35 2020 - [info] Version check ok.
Sat Jun 6 16:36:35 2020 - [info] Checking SSH publickey authentication settings on the current master..
Sat Jun 6 16:36:35 2020 - [info] HealthCheck: SSH to mydb1 is reachable.
Sat Jun 6 16:36:36 2020 - [info] Master MHA Node version is 0.58.
Sat Jun 6 16:36:36 2020 - [info] Checking recovery script configurations on mydb1(192.168.79.134:3306)..
Sat Jun 6 16:36:36 2020 - [info] Executing command: save_binary_logs --command=test --start_pos=4 --binlog_dir=/u01/mysql3306/log/binlog --output_file=/var/tmp/save_binary_logs_test --manager_version=0.58 --start_file=binlog.000054
Sat Jun 6 16:36:36 2020 - [info] Connecting to root@192.168.79.134(mydb1:22).. Creating /var/tmp if not exists.. ok.Checking output directory is accessible or not..ok.Binlog found at /u01/mysql3306/log/binlog, up to binlog.000054
Sat Jun 6 16:36:36 2020 - [info] Binlog setting check done.
Sat Jun 6 16:36:36 2020 - [info] Checking SSH publickey authentication and checking recovery script configurations on all alive slave servers..
Sat Jun 6 16:36:36 2020 - [info] Executing command : apply_diff_relay_logs --command=test --slave_user='root' --slave_host=mydb2 --slave_ip=192.168.79.136 --slave_port=3306 --workdir=/var/tmp --target_version=5.7.25-log --manager_version=0.58 --relay_log_info=/u01/mysql3306/log/relay-log.info --relay_dir=/u01/mysql3306/data/ --slave_pass=xxx
Sat Jun 6 16:36:36 2020 - [info] Connecting to root@192.168.79.136(mydb2:22).. Checking slave recovery environment settings..Opening /u01/mysql3306/log/relay-log.info ... ok.Relay log found at /u01/mysql3306/log, up to relaylog.000002Temporary relay log file is /u01/mysql3306/log/relaylog.000002Checking if super_read_only is defined and turned on.. not present or turned off, ignoring.Testing mysql connection and privileges..
mysql: [Warning] Using a password on the command line interface can be insecure.done.Testing mysqlbinlog output.. done.Cleaning up test file(s).. done.
Sat Jun 6 16:36:36 2020 - [info] Slaves settings check done.
Sat Jun 6 16:36:36 2020 - [info]
mydb1(192.168.79.134:3306) (current master)+--mydb2(192.168.79.136:3306)Sat Jun 6 16:36:36 2020 - [info] Checking replication health on mydb2..
Sat Jun 6 16:36:36 2020 - [info] ok.
Sat Jun 6 16:36:36 2020 - [warning] master_ip_failover_script is not defined.
Sat Jun 6 16:36:36 2020 - [warning] shutdown_script is not defined.
Sat Jun 6 16:36:36 2020 - [info] Got exit code 0 (Not master dead).MySQL Replication Health is OK.
[root@localhost ~]#
MySQL笔记-MHA(Master High Availability)搭建相关推荐
- Mysql群集MHA高可用配置(所爱隔山海,山海皆可平)
文章目录 一.MHA概述 1.简介 2.MHA 的组成 (1)MHA Node(数据节点) (2)MHA Manager(管理节点) 3.MHA的特点 二.搭建MHA高可用数据库群集 1.主从复制 ( ...
- MySQL之MHA架构的介绍
一.前言: 1.1 MHA介绍 MHA(Master High Availability)目前在MySQL高可用方面是一个相对成熟的解决方案,它由日本DeNA公司youshimaton(现就职于Fac ...
- MYSQL使用MHA实现主从复制高可用、Galera Cluster介绍、压力测试、my.cnf配置参考
MHA介绍 MHA: Master High Availability,对主节点进行监控,可实现自动故障转移至其它从节点:通过提升某一从节点为新的主节点,基于主从复制实现,还需要客户端配合实现,目前M ...
- MySQL之MHA高可用配置及故障切换
目录 一.MHA概述 1.2 MHA 的组成 1.3 MHA 的特点 二.MHA搭建准备 1.1实验思路 1.2实验准备 三.MHA搭建的步骤 3.1配置主从复制 3.1 安装 MHA 软件 3.2 ...
- MySQL之MHA高可用配置及故障切换(理论加实战详细部署步骤)
MySQL之MHA高可用配置及故障切换(理论加实战详细部署步骤) 文章目录 一.MHA介绍 (一).什么是MHA (二).MHA 的组成 (三).MHA 的特点 二.搭建 MySQL MHA (一). ...
- MySQL之MHA高可用配置及故障切换实例
MySQL之MHA高可用配置及故障切换实例 前言 一.MHA概述 (1)MHA是什么 (2)MHA的组成 (3)MHA的特点 二.部署MHA (1)配置主从服务 ①环境初始化 ③修改master.sl ...
- MHA高可用架构搭建
MHA高可用架构搭建 1.环境软件版本 2.环境架构介绍 3.MySQL主从搭建 3.1 MySQL安装(3台) 3.2 关闭防火墙 3.3 MySQL主从配置 Master节点 Slave1节点 S ...
- MySQL 部署MHA集群部署
目录 MySQL 部署MHA集群部署 MHA集群概述 MHA介绍 MHA简介 MHA组成 MHA工作过程 MHA集群架构 MHA工作过程 拓扑结构 IP规划 拓扑图 部署MHA集群 准备集群环境 安装 ...
- mysql配置MHA集群
** 本文针对Mysql–MHA集群搭建.vip配置及宕机之后数据库和manager恢复做记录** 搭建环境: 用4台服务器塔尖Mysql-MHA集群 服务器版本:CentOS 7.6 1.192.1 ...
最新文章
- mysql临时表如何分页查询慢_数据量很大,分页查询很慢,怎么优化?
- python tkinter 实现一个秒表 从0开始_Writeathon:从0开始实现的一个side project
- redis 未授权访问利用 两种方式
- 怎样将网站未收录的页面重新收录?
- (十四)struts2的国际化
- 2022年3月14日蓝桥杯基础算法能力测试
- 专家:番茄花园洪磊最高可判刑7年
- 腾讯云服务器CentOS安装JDK+Tomcat+MySQL详细步骤(以及遇到的各种坑)
- 【Java】为什么 StringBuilder 不是线程安全的
- SQL Server中的STRING_SPLIT函数
- IE下easyui 缓存问题
- Android应用开发提高系列(5)——Android动态加载(下)——加载已安装APK中的类和资源...
- MTK各个分区功能大全
- Excel文本如何间隔指定字符插入分隔符
- 排队服务系统仿真研究计算机模拟,基于蒙特卡洛方法排队系统性能的仿真优化研究...
- java stringbuilder 构造函数_java---StringBuilder类的用法(转载)
- 寄存器、缓存、内存、硬盘、存储器的理解
- ASO外的App推广方式有这些
- 运动学习与控制 示范与口授
- 下载安装指定版本的pandas