MySQL MHA Deployment Guide
This article explains the supported boundaries and basic usage of mha.yml.
1. Support boundaries
- Currently maintained only for
CentOS 7 / Red Hat 7 - Target architecture: one master, multiple replicas + MHA Manager
- Applicable version: MySQL
5.7
mha.yml belongs to the traditional high availability solution. For new clusters, it is recommended to use MGR or InnoDB Cluster.
192.168.161.* is the default dbbot three-node regression subnet, not a legacy MHA-specific environment. To validate mha.yml, prepare a separate CentOS 7 or Red Hat 7 environment and use MySQL 5.7.
2. inventory and roles
mha.yml still uses the [dbbot_mysql] host group, and the actual roles are distinguished by variables:
[dbbot_mysql]
192.0.2.131 ansible_user=root ansible_ssh_pass="'<your_password>'"
192.0.2.132 ansible_user=root ansible_ssh_pass="'<your_password>'"
192.0.2.133 ansible_user=root ansible_ssh_pass="'<your_password>'"
3. Key variables
Edit mysql_ansible/playbooks/vars/var_mha.yml:
master_ip: 192.0.2.131
slave_ips:
- 192.0.2.132
- 192.0.2.133
manager_ip: 192.0.2.133
vip: 192.0.2.130
vip_netmask: "32"
net_work_interface: ens33
Description:
manager_ipcannot be the same asmaster_ipmanager_ipshould be placed on the replica nodevip,vip_netmask,net_work_interfaceneed to be consistent with the actual network environmentens33is only an example interface name. Before running a VIP-related playbook, confirm the real interface withip routeorip addr. Sample environments using the dbbot192.168.161.*test inventory usually useenp1s0, but legacy MHA must still be validated in a dedicatedCentOS 7orRed Hat 7environment.
4. Execution entry
cd /usr/local/dbbot/mysql_ansible/playbooks
ansible-playbook mha.yml
5. Uninstall
mha_unsafe_uninstall.yml stops the classic MHA manager, removes the configured VIP and MHA runtime files, and then removes the MySQL instance data, log, and runtime directories for the current mysql_port:
cd /usr/local/dbbot/mysql_ansible/playbooks
ansible-playbook mha_unsafe_uninstall.yml
During execution, enter confirm as prompted. For non-interactive execution, append -e dbbot_confirmation_input=confirm.
By default, the playbook does not remove the MHA RPM packages. If you need to remove mha4mysql-manager and mha4mysql-node, append -e '{"mha_uninstall_remove_packages": true}'.
6. Things to note
- The current
mha.ymldocument only coversCentOS 7andRed Hat 7prerequisites. - Three-node regression environments that do not meet the
CentOS 7/Red Hat 7and MySQL5.7requirements are expected to be blocked by themha.ymlpreflight checks. - If you use it on other distributions, you need to verify Perl dependencies and MHA RPM compatibility yourself first.
- If you need to rerun after a failure, it is recommended to confirm the MHA Manager configuration, VIP status, and MySQL instance status before deciding whether to clean up the residual files.