Using MYSQL-MMM for MySQL cluster deployment

Source: Internet
Author: User

Background: The previously implemented MySQL synchronous replication feature (see author before article http://blog.csdn.net/kingofworld/article/details/39210937) is just a dual-machine hot standby feature, It is not possible to automatically switch Mysql links.

This configuration enables a true MySQL cluster, allowing the application to automatically switch to a MySQL connection on another machine when the MySQL application on one machine stops. Achieve high stability of applications and make it possible to extend Mysql Services.

This configuration implements cluster functionality using the Mysql-mmm (master-master Replication Manager for MySQL) component.

This demo is configured using three machines with the following architecture:


Master1 and Master2 Two machines for dual-machine hot-standby, one of the machine's mysql services stopped or machine down, The application automatically switches the database connection to another machine. In addition, the Master1 data is backed up in real time with one machine .

1. Installation mysql-mmm service

Installed on all three machines

wget http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

RPM-IVH epel-release-6-8.noarch.rpm

Yum-y Install mysql-mmm*

View rpm-qa|grep mysql-mmm when finished

The following components indicate a successful installation


Rhel5 or centos5,32 bit:/http/dl.fedoraproject.org/pub/epel/5/i386/epel-release-5-4.noarch.rpm

Rhel6 or centos6,32 bit:/http/dl.fedoraproject.org/pub/epel/6/i386/ epel-release-6-5.noarch.rpm

Rhel6 or centos6,64 bit:http://dl.fedoraproject.org/pub/epel/6/x86_64/epel-release-6-8.noarch.rpm

1. Add mysql user

Add MySQL users to each of the three machines for replication,

Go to MySQL service mysql-u root-p

Use MySQL;

Grant REPLICATION slave,replication CLIENT on * * to ' repl ' @ '% ' identified by ' password '; Create a replication user

Grant Process,super,replication CLIENT on * * to ' mmm_agent ' @ ' percent ' identified by 'password'; //build agent User

Grant REPLICATION CLIENT on * * to ' mmm_monitor ' @ ' percent ' identified by 'password'; //Build User

FLUSH privileges;

2. Configuring synchronous replication

Configure the replication policy as shown in the schema diagram.

Configuration method In my previous article has introduced, here no longer repeat, see the author before the article http://blog.csdn.net/kingofworld/article/details/39210937

3. Modify the hosts

Modify the hosts file for each of the three machines

Vi/etc/hosts

Add to

200.200.168.24 M1

200.200.168.25 M2

200.200.168.23 slave1

4, configuration mysql-mmm

Modify the/etc/mysql-mmm/mmm_common.conf each machine configuration is the same

active_master_role writer

Note: 200.200.168.26 and 200.200.168.27 are two virtual IP addresses that can be used by applications to provide write and read services, using only two of the IP that no one occupies. For later implementation of the database read/write separation (but to achieve read and write separation needs to modify the application,mysql does not automatically recognize and switch).

Modify/etc/mysql-mmm/mmm_agent.conf

Three machines are set to this M1,thisM2,thisslave1 , respectively

Modify/etc/mysql-mmm/mmm_mon.conf

Only monitor (200.200.168.24) needs to be configured

Include mmm_common.conf<monitor>    IP                  127.0.0.1    pid_path            /var/run/mysql-mmm/mmm_mond.pid    bin_path            /usr/libexec/mysql-mmm    status_path         /var/lib/mysql-mmm/mmm_mond.status    ping_ips            200.200.168.24,200.200.168.25,200.200.168.23    auto_set_online    # The Kill_host_bin does not exist by default, though the monitor would    # throw a warning about it missing.  See the sections 5.10 "Kill Host     # functionality" in the PDF documentation.    #    # kill_host_bin     /usr/libexec/mysql-mmm/monitor/kill_host    #</monitor>

Run after configuration is complete

Three machines are required to run:

/etc/init.d/mysql-mmm-agent start

Monitor machine running

/etc/init.d/mysql-mmm-monitor start

5. View service status and test

running Mmm_control Show on Monitor

You can see the following information:


Indicates that the Write server (200.200.168.26) is using 200.200.168.24

Read server (200.200.168.27) is using 200.200.168.25

To view the status of individual services:

Mmm_control checks All


6. Test:

Stop the Master1 MySQL service and then Mmm_control Show to view the status


Can see the read-write server is transferred to the Master2, the server master1 process application can also be used normally, can carry out the application process test

Then view Mmm_control checks all


Start the master1 mysql service and check the status:


Read and write servers are separated.


Using MYSQL-MMM for MySQL cluster deployment

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.