MySQL-mmm-two nodes(master)架構
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. 測試環境部署
主機 ip 說明monitor 192.168.1.109 mmm monitor伺服器master 192.168.1.106 資料庫伺服器(master)slave1 192.168.1.107 資料庫伺服器(同樣也為master) vip部署
ip role 說明 192.168.1.220 writer 應用串連此ip執行寫操作192.168.1.221 reader 應用串連此ip執行讀操作192.168.1.222 reader 應用串連此ip執行讀操作 具體安裝配置過程:1.安裝MySQL-mmm與master-master複製略) 2.資料庫節點建立mmm_monitor與mmm_agent使用者
- GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'192.168.1.%'
- IDENTIFIED BY 'RepMonitor';
- GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'192.168.1.%'
- IDENTIFIED BY 'RepAgent';
3.所有節點包括monitor節點)配置/etc/mysql-mmm/mmm_common.conf所有節點均相同
- active_master_role writer
-
- <host default>
- cluster_interface eth0
- pid_path /var/run/mysql-mmm/mmm_agentd.pid
- bin_path /usr/libexec/mysql-mmm/
- replication_user repl
- replication_password repl
- agent_user mmm_agent
- agent_password RepAgent
- </host>
-
- <host master>
- ip 192.168.1.106
- mode master
- peer slave1
- </host>
-
- <host slave1>
- ip 192.168.1.107
- mode master
- peer master
- </host>
-
- <role writer>
- hosts master, slave1
- ips 192.168.1.220
- mode exclusive
- </role>
-
- <role reader>
- hosts master, slave1
- ips 192.168.1.221, 192.168.1.222
- mode balanced
- </role>
4.資料庫節點配置/etc/mysql-mmm/mmm_agent.conf
- include mmm_common.conf
-
- # The 'this' variable refers to this server. Proper operation requires
- # that 'this' server (db1 by default), as well as all other servers, have the
- # proper IP addresses set in mmm_common.conf.
- # 修改為主機名稱
- this master
5.monitor節點配置/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.1.1, 192.168.1.106, 192.168.1.107
- auto_set_online 60
-
- # The kill_host_bin does not exist by default, though the monitor will
- # throw a warning about it missing. See the section 5.10 "Kill Host
- # Functionality" in the PDF documentation.
- #
- # kill_host_bin /usr/libexec/mysql-mmm/monitor/kill_host
- #
- </monitor>
-
- <host default>
- monitor_user mmm_monitor
- monitor_password RepMonitor
- </host>
-
- debug 0
6.MySQL-mmm測試
- [root@monitor mysql-mmm]# mmm_control show
- master(192.168.1.106) master/ONLINE. Roles: reader(192.168.1.222), writer(192.168.1.220)
- slave1(192.168.1.107) master/ONLINE. Roles: reader(192.168.1.221)
-
- --關閉master主機上的mysql服務,角色成功切換
- [root@monitor mysql-mmm]# mmm_control show
- master(192.168.1.106) master/HARD_OFFLINE. Roles:
- slave1(192.168.1.107) master/ONLINE. Roles: reader(192.168.1.221), reader(192.168.1.222), writer(192.168.1.220)
-
- --啟動master主機上的mysql服務,角色成功切換
- [root@monitor mysql-mmm]# mmm_control show
- master(192.168.1.106) master/ONLINE. Roles: reader(192.168.1.221)
- slave1(192.168.1.107) master/ONLINE. Roles: reader(192.168.1.222), writer(192.168.1.220)
7.常用命令
- [root@monitor mysql-mmm]# mmm_control show
- [root@monitor mysql-mmm]# mmm_control set_online slave1
- [root@monitor mysql-mmm]# mmm_control set_offline slave1
本文出自 “與IT一起的日子” 部落格,請務必保留此出處http://raugher.blog.51cto.com/3472678/1174255