Mysql-mmm Architecture Detailed Tutorial

Source: Internet
Author: User
Tags db2

8.12.3.2 Mysql-mmm Frame composition

Mysql MMM features
Advantages: High availability, scalability, automatic failover, for master synchronization, at the same time only provide a database write operation, to ensure the consistency of the data.
Disadvantage: Monitor node is a single point, can be combined with keepalived to achieve high availability, the number of host requirements, the need to achieve read and write separation, the program is a challenge.

8.12.3.3 mysql-mmm Installation
You need to install MYSQL-MMM on all servers
wget http://dl.fedoraproject.org/pub/epel/6/i386/epel-release-6-8.noarch.rpm
RPM-UVH epel-release-6-8.noarch.rpm
Yum Install-y mysql-mmm*

8.12.3.4 mysql-mmm Configuration

    1. Configure the MMM agent and monitor account permissions

The environment is now configured, I do not ignore the MySQL library and the user table, so as long as any one of the main library to do the following operations, the other libraries have these two accounts.
What I do here on Master1
mysql> grant replication Client on . to ' mmm_monitor ' @ ' 192.168.0.% ' identified by ' Oldboy123 ';
mysql> Grant Super, replication client, process on . to ' mmm_agent ' @ ' 192.168.0.% ' identified by ' oldboy123 ';

  1. All servers need to be configured/etc/mysql-mmm/mmm_common.conf
    Active_master_role writer
    Cluster_ Interface eth0
    Pid_path/var/run/mysql-mmm/mmm_agentd.pid
    bin_path/usr/libexec/mysql-mmm/
    Replication_ User Rep #同步用户
    Replication_password oldboy123 #同步密码
    Agent_user mmm_agent # mmm_agent User
    Agent_password oldboy123 # Mmm_agent User's password
    IP 192.168.0.60 # db1 master-1 physical IP
    Mode Master Br>peer DB2
    IP 192.168.0.61 # DB2 master-2 physical IP
    Mode Master
    Peer db1
    IP 192.168.0.62 # db3 slave physical IP
    mode slave
    <role WRI Ter>
    hosts DB1, DB2
    IPs 192.168.0.20 #写入的虚拟IP地址 VIP
    Mode exclusive
    </role>
    <role reader> ;
    hosts DB1, DB2, DB3
    IPs 192.168.0.21, 192.168.0.22, 192.168.0.23 #虚拟读取IP地址
    Mode balanced
    </role>

  2. All servers need to be configured/etc/mysql-mmm/mmm_agent.conf
    vi/etc/mysql-mmm/mmm_agent.conf
    include mmm_common.conf
    The ' this ' variable refers to this server. Proper operation requires
    that's ' This ' server (db1 by default), as well as all other servers, with the
    Proper IP ad Dresses set in mmm_common.conf.
    This db1 #分别修改为本机的主机名, which is DB1, DB2, DB3, and DB4

  3. Monitor Host Configuration/etc/mysql-mmm/mmm_mon.conf
    [Email protected] tools]# cat/etc/mysql-mmm/mmm_mon.conf
    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 192.168.0.60,192.168.0.61,192.168.0.62 #监控的IP
    Auto_set_online #切换浮动IP的时间 (default 60 seconds) The Kill_host_bin does not exist by default, though the monitor Willthrow a warning About it missing. See the sections 5.10 "Kill hostfunctionality" in the PDF Documentation.kill_host_bin/usr/libexec/mysql-mmm/monitor/kill _host

    </monitor>
    Monitor_user mmm_monitor #mmm_monitor Users
    Monitor_password oldboy123 #mmm_monitor Password
    Debug 0

8.12.3.5 mysql-mmm Start
1) master-1,master-2,slave start agent:

All database hosts start mmm-agent:
/etc/init.d/mysql-mmm-agent start

10.204.3.4:9989 0.0.0.0:* LISTEN 2407/mmm_agentd

2) Monitor host boot Mmm-monitor
/etc/init.d/mysql-mmm-monitor start

8.12.3.6 mysql-mmm Test
Mmm_control command to monitor MySQL server status
[Email protected] ~]# Mmm_control Show
DB1 (192.168.0.60) master/online. Roles:reader (192.168.0.23), writer (192.168.0.20)
DB2 (192.168.0.61) master/online. Roles:reader (192.168.0.22)
DB3 (192.168.0.62) slave/online. Roles:reader (192.168.0.21)

Test whether two MySQL server can fail auto-switch
Stop the DB1 MySQL service
[[email protected] tools]#/etc/init.d/mysqld stop
Shutting down MySQL ... success!
Wait 30 seconds for monitoring on the Mysql-mmm-monitor server view
[Email protected] ~]# Mmm_control Show
DB1 (192.168.0.60) master/hard_offline. Roles:
DB2 (192.168.0.61) master/online. Roles:reader (192.168.0.22), writer (192.168.0.20)
DB3 (192.168.0.62) slave/online. Roles:reader (192.168.0.21), Reader (192.168.0.23)

Slave check if Master_host has switched to another main library address:
[Email protected] ~]# mysql-e "show slave Status\g" |egrep "Master_host:"
master_host:192.168.0.61

Recovery Master-1 (DB1)
[[email protected] tools]#/etc/init.d/mysqld start
Starting MySQL ... success!
Monitor-side Check recovery status
[Email protected] ~]# Mmm_control Show
DB1 (192.168.0.60) master/online. Roles:reader (192.168.0.21)
DB2 (192.168.0.61) master/online. Roles:reader (192.168.0.22), writer (192.168.0.20)
DB3 (192.168.0.62) slave/online. Roles:reader (192.168.0.23)
We can see the role of slave when DB1 is restored! The DB1 will assume the write function of the primary server only after the DB2 is hung up.

8.12.3.7 Mmm_control Command Introduction
Valid Commands is:
Help-show this message
#查看帮助信息
Ping-ping Monitor
#ping监控
Show-show status
#查看状态信息
Checks [#显示检查状态, including (Ping, MySQL, rep_threads, Rep_backlog)
Set_online #设置某host为online状态
Set_offline #设置某host为offline状态
Mode-print current mode.
#打印当前的模式, is it active, MANUAL, PASSIVE?
#默认ACTIVE模式
Set_active-switch into active mode.
#更改为active模式
Set_manual-switch into manual mode.
#更改为manual模式
Set_passive-switch into passive mode.
#更改为passive模式
Move_role [--force] <role> #更改host的模式, such as changing the MySQL database role in slave to write
(Only use--force if you know, what is doing!)
SET_IP <ip> #为host设置ip, only allow changes when passive mode is available!

Mysql-mmm Architecture Detailed Tutorial

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.