数据库MHA高可用集群部署

本文详细介绍了MHA(MySQL High Availability)集群的部署过程,包括其特点、组成、工作流程,以及具体的拓扑规划和实施步骤,旨在实现数据库的高可用性和故障快速切换。
摘要由CSDN通过智能技术生成

一、MHA集群特点:

**是一套优秀的mysql高可用解决方案
**可在0~30s内完成数据可自动故障切换
**故障切换过程中最大限度保证数据库的一致性

二、MHA的组成

**MHA Manger(管理节点)
–管理所有的数据库服务器
–可以单独部署在独立的机器上也可以部署在某台数据库上
**MHA Node(数据节点)
–存储数据的mysql服务器
–运行在每台mysql服务器上

三、工作过程

**Manger定时探测集群中的master节点
**当master故障时,Manger自动将拥有最近数据的slave提升为master

四、拓扑规划

在这里插入图片描述在这里插入图片描述

ip规划
在这里插入图片描述

五、部署思路

1.准备集群环境(node)
①安装依赖包
②所有数据库配置免密认证登录
③配置一主多从
2.配置管理节点(mgm)----管理集群命令
①安装MHA程序的软件包
②编写主配置文件(节点信息、监控用户信息、主数据库信息、故障切换脚本)
3.配置数据库节点信息
①配置主服务器VIP地址(51)
②在所有数据库服务器上安装mha-node软件包(51/52/53)
③配置主数据库服务器后重启(监控用户授权、半同步复制、进制自动删除中继日志、binlog日志)-51/52/53
4.测试配置
①在管理主机,测试ssh配置
[root@mgm57 ~]# masterha_check_ssh --conf=/etc/mha/app1.cnf //执行测试命令
②在管理主机上测试主从同步
[root@host57 ~]# masterha_check_repl --conf=/etc/mha/app1.cnf //执行测试命令


配置完成图

在这里插入图片描述************************************************************************************************************************************************************
1)配置数据库服务器192.168.4.51

[root@host51 ~]# ssh-keygen //创建秘钥对

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): //回车

Enter passphrase (empty for no passphrase): //回车

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:qb7EZByHad3Jadr+zkiEbo7ZKGmCNlctgp+Wfp3Yad0 root@pxcnode71

The key's randomart image is:

+---[RSA 2048]----+

| |

| + o o |

| = o * |

| o o * |

| . = S o |

| . . * + o |

| .. =.O * + |

|.o.*+= & o E |

|. =+..B.o ..+ |

+----[SHA256]-----+

[root@host51 ~]#

[root@host51 ~]# ssh-copy-id root@192.168.4.52 //传递公钥给host52主机

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@192.168.4.71's password: //输入host52主机系统管理员root用户密码

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'root@192.168.4.52'"

and check to make sure that only the key(s) you wanted were added.

[root@host51 ~]#

[root@host51 ~]# ssh-copy-id root@192.168.4.53 //传递公钥给host53主机

/usr/bin/ssh-copy-id: INFO: Source of key(s) to be installed: "/root/.ssh/id_rsa.pub"

/usr/bin/ssh-copy-id: INFO: attempting to log in with the new key(s), to filter out any that are already installed

/usr/bin/ssh-copy-id: INFO: 1 key(s) remain to be installed -- if you are prompted now it is to install the new keys

root@192.168.4.71's password: //输入host53主机系统管理员root用户密码

Number of key(s) added: 1

Now try logging into the machine, with: "ssh 'root@192.168.4.53'"

and check to make sure that only the key(s) you wanted were added.

[root@host51 ~]#

[root@host51 ~]# ssh root@192.168.4.52 //可以无密码连接52主机

Last login: Fri Jun 21 13:21:39 2019 from 192.168.4.254

.-"""-.

/ .===. \

\/ 6 6 \/

( \___/ )

_________ooo__\_____/_____________

/ \

| I am Virtual Host ! ! ! |

\_______________________ooo________/

| | |

|_ | _|

| | |

|__|__|

/-'Y'-\

(__/ \__)

[root@host52 ~]#

[root@host52 ~]# exit //断开连接

登出

Connection to 192.168.4.52 closed.

[root@host51 ~]#

[root@host51 ~]# ssh root@192.168.4.53 //可以无密码连接52主机

Last login: Fri Jun 21 09:01:15 2019 from 192.168.4.254

.-"""-.

/ .===. \

\/ 6 6 \/

( \___/ )

_________ooo__\_____/_____________

/ \

| I am Virtual Host ! ! ! |

\_______________________ooo________/

| | |

|_ | _|

| | |

|__|__|

/-'Y'-\

(__/ \__)

[root@host53 ~]# exit//断开连接

登出

Connection to 192.168.4.53 closed.

[root@host51 ~]#

2)配置数据库服务器192.168.4.52

[root@host52 ~]# ssh-keygen //创建秘钥对

Generating public/private rsa key pair.

Enter file in which to save the key (/root/.ssh/id_rsa): //回车

Enter passphrase (empty for no passphrase): //回车

Enter same passphrase again:

Your identification has been saved in /root/.ssh/id_rsa.

Your public key has been saved in /root/.ssh/id_rsa.pub.

The key fingerprint is:

SHA256:qb7EZByHad3Jadr+zkiEbo7ZKGmCNlctgp+Wfp3Yad0 root@pxcnode71

The key's randomart image is:

+---[RSA 2048]----+

| |

| + o o |

| = o * |
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值