mysql-mmm安裝部署

mysql-mmm文檔下載地址

http://down.51cto.com/data/339582

部署環境

操作系統:Red Hat Enterprise Linux Server release 6.1

Master1192.168.5.73

Master2192.168.5.76

Monitor192.168.5.77

安裝步驟

1、假設mysql Mater-Master模式已經配置成功,可以參考mysql master-slave配置文章

http://360537539.blog.51cto.com/3803422/781612

爲了避免master-master AUTO_INCREMENT列值重複情況,需要在my.cnf配置中配置如下內容

 

master1:

  1. auto_increment_increment = 2 
  2. auto_increment_offset = 1 

 

master2:

  1. auto_increment_increment = 2  
  2. auto_increment_offset = 2 

有關auto_increment_increment和auto_increment_offset參考

http://blog.csdn.net/wh62592855/article/details/6726724

2、安裝mysql-mmm-agent mysql-mmm-common mysql-mmm-monredhatcentos系統通過yum方式安裝比較方便(省去了很多依賴包的安裝),但是默認的centos軟件倉庫默認不包含這些rpm包,需要epel-release的支持。

1)安裝epel-release

#rpm -Uvh http://mirror.xfes.ru/fedora-epel/6/i386/epel-release-6-5.noarch.rpm,不同的系統版本注意選擇對應的鏡像位置

2)安裝mysql-mmm系列包

yum install mysql-mmm* -y

3)創建mysql 用戶並賦予權限

條件:

monitor user

A MySQL user with privileges REPLICATION CLIENT for MMM monitor.

agent user

A MySQL user with privileges SUPER, REPLICATION CLIENT, PROCESS for

MMM agent.

replication user

A MySQL user with privileges REPLICATION SLAVE used for replication.

運行命令


  1. mysql>GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'192.168.%' IDENTIFIED BY 'ictsoft'
  2.  
  3. mysql> GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'192.168.%' IDENTIFIED BY 'ictsoft'
  4.  
  5. mysql> GRANT REPLICATION SLAVE ON *.* TO 'replication'@'192.168.%' IDENTIFIED BY 'ictsoft'

4、配置mysql-mmm

vi /etc/mysql-mmm/mmm_common.conf


  1. active_master_role      writer 
  2.  
  3.  <host default> 
  4.  
  5.   cluster_interface       eth0 
  6.  
  7.     pid_path                /var/run/mysql-mmm/mmm_agentd.pid 
  8.  
  9.     bin_path                /usr/libexec/mysql-mmm/ 
  10.  
  11.     replication_user        rep 
  12.  
  13.     replication_password    ictsoft 
  14.  
  15.     agent_user              mmm_agent 
  16.  
  17.     agent_password          ictsoft 
  18.  
  19. </host> 
  20.  
  21. <host db1> 
  22.  
  23.     ip      192.168.5.73 
  24.  
  25.     mode    master 
  26.  
  27.     peer    db2 
  28.  
  29. </host> 
  30. <host db2> 
  31.     ip      192.168.5.76 
  32.  
  33.     mode    master 
  34.  
  35.     peer    db1 
  36.  
  37. </host> 
  38. <role writer> 
  39.     hosts   db1, db2 
  40.  
  41.     ips     192.168.5.80 
  42.  
  43.     mode    exclusive 
  44.  
  45. </role> 
  46. <role reader> 
  47.     hosts   db1, db2 
  48.  
  49.     ips     192.168.5.84, 192.168.5.82 
  50.  
  51.     mode    balanced 
  52.  
  53. </role> 

192.168.5.73  192.168.5.76angetip地址

192.168.5.80  192.168.5.82  192.168.5.843個浮動ip192.168.5.84, 192.168.5.82對應角色,192.168.5.80對應角色,浮動ip會根據mysql服務的情況進行漂移,後面會詳細介紹。

將配置文件拷貝到monitoragent的響應目錄下(/etc/mysql-mmm/mysql-common.conf)

修改mysql-mmm-agent.conf

vi /etc/mysql-mmm/mmm_agent.conf

  1. include mmm_common.conf 
  2.  
  3. this db1 

注意此處this的值要和common中的配置相對應

修改mysql-mmm-monitor.conf


  1. include mmm_common.conf 
  2.  

  3. <monitor> 

  4.         ip                                      127.0.0.1 
  5.  
  6.         pid_path                                /var/run/mmm_mond.pid 
  7.  
  8.         bin_path                                /usr/lib/mysql-mmm/ 
  9.  
  10.         status_path                             /var/lib/misc/mmm_mond.status 
  11.  
  12.         ping_ips                                192.168.5.73 
  13.  
  14. </monitor> 
  15.  
  16.  
  17. <host default> 

  18.         monitor_user                    mmm_monitor 
  19.  
  20.         monitor_password                ictsoft 
  21.  
  22. </host> 
  23.  
  24. debug 1 

 

 

5、啓動mysql-mmm-agentmysql-mmm-monitor服務

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

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

6、檢測狀態

monitor 


  1. #mmm_control show 
  2.  
  3. b1(192.168.5.73) master/AWAITING_RECOVERY. Roles: 
  4.  
  5. db2(192.168.5.76) master/AWAITING_RECOVERY. Roles: 

對兩臺dbset_online操作


  1. #mmm_control set_online db1 
  2.  
  3. #mmm_control set_online db2 

查看狀態


  1. #mmm_control show 
  2.  
  3. db1(192.168.5.73) master/ONLINE. Roles: reader(192.168.5.82), writer(192.168.5.80) 
  4.  
  5. db2(192.168.5.76) master/ONLINE. Roles: reader(192.168.5.84) 

7、測試

停掉db1mysql,在monitor端查看狀態


  1. #mmm_control show 
  2.  
  3. db1(192.168.5.73) master/HARD_OFFLINE. Roles: 
  4.  
  5. db2(192.168.5.76) master/ONLINE. Roles: reader(192.168.5.82), reader(192.168.5.84), writer(192.168.5.80) 

發現原來在db1上的讀和寫角色(ip)都漂移到了db2,啓動db1mysql后角色重新分配

發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章