MySQL HA by using Mysql-mmm

Source: Internet
Author: User

MySQL-mmm-two nodes (master) Architecture

650) this. width = 650; "border =" 0 "alt =" "src =" http://www.bkjia.com/uploads/allimg/131229/1Q2143928-0.png "/>

In two node master-master setup, MMM uses five IPs: single permanent IP for each nodethat is never changed, 2 reader IPs (read-only) and 1 writer IP (updates ). last three IPsare migrating between the nodes depending on node availability. normally (no replication failures, no replication delay etc) active master has 2 IPs (readerand writer), standby master-1 IP (reader ). in case of a failure, both-writer and readerroles migrate to the working node. test Environment deployment Host ip descriptionMonitor 192.168.1.109 mmm monitor server master 192.168.1.106 Database Server (master) slave1 192.168.1.107 Database Server (also master) vip deployment Ip role descriptionThe 192.168.1.220 writer application connects to this ip address and performs the write operation 192.168.1.221 reader application connects to this ip address. Execute the read operation 192.168.1.222 reader application connects to this ip address to perform the read operation. The specific installation procedure is as follows: 1. install MySQL-mmm and master-master replication) 2. create mmm_monitor and mmm_agent users on the database Node
 
 
  1. GRANT REPLICATION CLIENT   ON *.* TO 'mmm_monitor'@'192.168.1.%'   
  2. IDENTIFIED BY 'RepMonitor'; 
  3. GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'192.168.1.%'   
  4. IDENTIFIED BY 'RepAgent'; 
3. Configure/etc/mysql-mmm/mmm_common.conf for all nodes including the monitor node.
 
 
  1. active_master_role      writer 
  2.  
  3.     cluster_interface       eth0 
  4.     pid_path                /var/run/mysql-mmm/mmm_agentd.pid 
  5.     bin_path                /usr/libexec/mysql-mmm/ 
  6.     replication_user        repl 
  7.     replication_password    repl 
  8.     agent_user              mmm_agent 
  9.     agent_password          RepAgent 
  10.  
  11.     ip      192.168.1.106 
  12.     mode    master 
  13.     peer    slave1 
  14.  
  15.     ip      192.168.1.107 
  16.     mode    master 
  17.     peer    master 
  18.  
  19. <role writer> 
  20.     hosts   master, slave1 
  21.     ips     192.168.1.220 
  22.     mode    exclusive 
  23. </role> 
  24.  
  25. <role reader> 
  26.     hosts   master, slave1 
  27.     ips     192.168.1.221, 192.168.1.222 
  28.     mode    balanced 
  29. </role> 

4. Configure the database node/etc/mysql-mmm/mmm_agent.conf

 
 
  1. Include mmm_common.conf
  2.  
  3. # The 'this' variable refers to this server. Proper operation requires
  4. # That 'it' server (db1 by default), as well as all other servers, have
  5. # Proper IP addresses set in mmm_common.conf.
  6. # Change to host name
  7. This master

5. monitor node configuration/etc/mysql-mmm/mmm_mon.conf

 
 
  1. include mmm_common.conf 
  2.  
  3. <monitor> 
  4.     ip                  127.0.0.1 
  5.     pid_path            /var/run/mysql-mmm/mmm_mond.pid 
  6.     bin_path            /usr/libexec/mysql-mmm 
  7.     status_path         /var/lib/mysql-mmm/mmm_mond.status 
  8.     ping_ips            192.168.1.1, 192.168.1.106, 192.168.1.107 
  9.     auto_set_online     60 
  10.  
  11.     # The kill_host_bin does not exist by default, though the monitor will 
  12.     # throw a warning about it missing.  See the section 5.10 "Kill Host 
  13.     # Functionality" in the PDF documentation. 
  14.     # 
  15.     # kill_host_bin     /usr/libexec/mysql-mmm/monitor/kill_host 
  16.     # 
  17. </monitor> 
  18.  
  19.     monitor_user        mmm_monitor 
  20.     monitor_password    RepMonitor 
  21.  
  22. debug 0 

6. MySQL-mmm test

 
 
  1. [Root @ monitor mysql-mmm] # mmm_control show
  2. Master (192.168.1.106) master/ONLINE. Roles: reader (192.168.1.222), writer (192.168.1.220)
  3. Slave1 (192.168.1.107) master/ONLINE. Roles: reader (192.168.1.221)
  4.  
  5. -- The mysql service on the master host is disabled, and the role is successfully switched.
  6. [Root @ monitor mysql-mmm] # mmm_control show
  7. Master (192.168.1.106) master/HARD_OFFLINE. Roles:
  8. Slave1 (192.168.1.107) master/ONLINE. Roles: reader (192.168.1.221), reader (192.168.1.222), writer (192.168.1.220)
  9.  
  10. -- Start the mysql service on the master host and switch the role
  11. [Root @ monitor mysql-mmm] # mmm_control show
  12. Master (192.168.1.106) master/ONLINE. Roles: reader (192.168.1.221)
  13. Slave1 (192.168.1.107) master/ONLINE. Roles: reader (192.168.1.222), writer (192.168.1.220)

7. Common commands

 
 
  1. [root@monitor mysql-mmm]# mmm_control show 
  2. [root@monitor mysql-mmm]# mmm_control set_online slave1 
  3. [root@monitor mysql-mmm]# mmm_control set_offline slave1 

 

This article is from the "day with IT" blog, please be sure to keep this source http://raugher.blog.51cto.com/3472678/1174255

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.