Databases 6 min read

Step-by-Step Guide to Deploying MHA for MySQL High Availability

This tutorial walks through preparing a CentOS 6.6 environment, creating MHA users and SSH keys, configuring hosts, installing MHA Node and Manager, verifying configurations, and testing master failover to achieve reliable MySQL high‑availability using MHA.

dbaplus Community
dbaplus Community
dbaplus Community
Step-by-Step Guide to Deploying MHA for MySQL High Availability

Prerequisite

MHA does not automatically create master‑slave topology, so you must set up a MySQL master‑slave environment manually. Ensure all slaves are not read‑only and have binary logging enabled; the designated failover slave must have binlog enabled and be read‑write.

Architecture

System Environment

# cat /etc/redhat-release

CentOSrelease 6.6 (Final) # uname -rm 2.6.32-504.el6.x86_64

Create MHA User

Run on the master server:

mysql> grant all privileges on *.* to 'mha'@'192.168.56.%' identified by '123456';

Create Symlinks (if MySQL not installed via yum)

# ln -s /application/mysql/bin/mysqlbinlog /usr/bin/mysqlbinlog
# ln -s /application/mysql/bin/mysql /usr/bin/mysql

Configure SSH Public‑Key Authentication

Generate a DSA key pair on the manager host: # ssh-keygen -t dsa Distribute the public key to all MySQL hosts.

Configure Hosts File

Deploy MHA Node

Install MHA Node on every MySQL server (both master and slaves). Example on the manager host: # mkdir /softs Then install the node package (see image for detailed steps).

Deploy MHA Manager

The manager runs on a designated server (can be a slave). Install the manager package:

Standardize the MHA directory layout:

Configure app1.cnf (example screenshots):

Set up the global configuration file:

Check Configuration

Run these checks on the manager host.

SSH Connectivity

Replication Status

Start Manager

Check Manager Status

Master Failover Test

Simulate master failure and observe automatic promotion:

Verify the new master (e.g., mysql-slave02) shows the expected data and replication state:

After verification, the MHA cluster provides seamless MySQL high availability.

Original Source

Signed-in readers can open the original source through BestHub's protected redirect.

Sign in to view source
Republication Notice

This article has been distilled and summarized from source material, then republished for learning and reference. If you believe it infringes your rights, please contactadmin@besthub.devand we will review it promptly.

high availabilityLinuxmysqlMHADatabase Administration
dbaplus Community
Written by

dbaplus Community

Enterprise-level professional community for Database, BigData, and AIOps. Daily original articles, weekly online tech talks, monthly offline salons, and quarterly XCOPS&DAMS conferences—delivered by industry experts.

0 followers
Reader feedback

How this landed with the community

Sign in to like

Rate this article

Was this worth your time?

Sign in to rate
Discussion

0 Comments

Thoughtful readers leave field notes, pushback, and hard-won operational detail here.