MySQL-MMM架構使用

3.MySQL-MMM架構使用
問題
本案例要求基於普通版的MySQL服務器改造MMM架構,完成以下任務操作:
啓動MMM集羣架構
設置集羣中服務器爲online狀態
方案
MySQL-MMM架構部署完成後需要啓動,數據庫端啓動mmm-agent進程,管理端啓動mmm-monitor進程,啓動完成後設置所有數據庫主機狀態爲online。
步驟
實現此案例需要按照如下步驟進行。
步驟一:啓動MMM集羣架構
1)啓動mmm-agent進程
master1操作:
[root@master1 ~]# /etc/init.d/mysql-mmm-agent start
Daemon bin: ‘/usr/sbin/mmm_agentd’
Daemon pid: ‘/var/run/mmm_agentd.pid’
Starting MMM Agent daemon… Ok
master2操作:
[root@master2 ~]# /etc/init.d/mysql-mmm-agent start
Daemon bin: ‘/usr/sbin/mmm_agentd’
Daemon pid: ‘/var/run/mmm_agentd.pid’
Starting MMM Agent daemon… Ok
slave1操作:
[root@master2 ~]# /etc/init.d/mysql-mmm-agent start
Daemon bin: ‘/usr/sbin/mmm_agentd’
Daemon pid: ‘/var/run/mmm_agentd.pid’
Starting MMM Agent daemon… Ok
slave2操作:
[root@slave2 ~]# /etc/init.d/mysql-mmm-agent start
Daemon bin: ‘/usr/sbin/mmm_agentd’
Daemon pid: ‘/var/run/mmm_agentd.pid’
Starting MMM Agent daemon… Ok
2)啓動mmm-monitor進程
monitor主機操作:
[root@monitor ~]# /etc/init.d/mysql-mmm-monitor start
Daemon bin: ‘/usr/sbin/mmm_mond’
Daemon pid: ‘/var/run/mmm_mond.pid’
Starting MMM Monitor daemon: Ok
步驟二:設置集羣中服務器爲online狀態
控制命令只能在管理端monitor服務器上執行。
查看當前集羣中各服務器狀態:
[root@monitor ~]# mmm_control show
master1(192.168.4.10) master/AWAITING_RECOVERY. Roles:
master2(192.168.4.11) master/AWAITING_RECOVERY. Roles:
slave1(192.168.4.12) slave/AWAITING_RECOVERY. Roles:
slave2(192.168.4.13) slave/AWAITING_RECOVERY. Roles:
設置4臺數據庫主機狀態爲online:
[root@monitor ~]# mmm_control set_online master1
OK: State of ‘master1’ changed to ONLINE. Now you can wait some time and check its new roles!
[root@monitor ~]# mmm_control set_online master2
OK: State of ‘master2’ changed to ONLINE. Now you can wait some time and check its new roles!
[root@monitor ~]# mmm_control set_online slave1
OK: State of ‘slave1’ changed to ONLINE. Now you can wait some time and check its new roles!
[root@monitor ~]# mmm_control set_online slave2
OK: State of ‘slave2’ changed to ONLINE. Now you can wait some time and check its new roles!
[root@monitor ~]#
再次查看當前集羣中各服務器狀態:
[root@monitor ~]# mmm_control show
master1(192.168.4.10) master/ONLINE. Roles: writer(192.168.4.200)
master2(192.168.4.11) master/ONLINE. Roles:
slave1(192.168.4.12) slave/ONLINE. Roles: reader(192.168.4.201)
slave2(192.168.4.13) slave/ONLINE. Roles: reader(192.168.4.202)

[root@monitor ~]#
步驟三:測試MySQL-MMM架構
1)客戶機安裝MySQL-client軟件包
[root@client ~]# tar xvf MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar
… …
[root@client ~]# rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm
… …
2)MySQL-MMM虛擬IP訪問測試
[root@client ~]# mysql -h192.168.4.200 -uroot -ppwd123 -e “show databases”
Warning: Using a password on the command line interface can be insecure.
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| tarena |
| test |
±-------------------+
[root@client ~]#

[root@client ~]# mysql -h192.168.4.200 -uroot -ppwd123 -e “show databases”
Warning: Using a password on the command line interface can be insecure.
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| tarena |
| test |
±-------------------+
[root@client ~]#

[root@client ~]# mysql -h192.168.4.202 -uroot -ppwd123 -e “show databases”
Warning: Using a password on the command line interface can be insecure.
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| tarena |
| test |
±-------------------+
[root@client ~]#
3)主數據庫宕機測試
[root@master1 ~]# service mysql stop //停止master1上服務
Shutting down MySQL… [確定]
[root@master1 ~]#

[root@monitor ~]# mmm_control show //查看集羣內服務器狀態
通過輸出信息可以看到虛擬IP從master1切換到master2:
master1(192.168.4.10) master/HARD_OFFLINE. Roles:
master2(192.168.4.11) master/ONLINE. Roles: writer(192.168.4.200)
slave1(192.168.4.12) slave/ONLINE. Roles: reader(192.168.4.201)
slave2(192.168.4.13) slave/ONLINE. Roles: reader(192.168.4.202)
[root@monitor ~]#

[root@client ~]# mysql -h192.168.4.200 -uroot -ppwd123 -e “show databases” //訪問虛擬IP測試
Warning: Using a password on the command line interface can be insecure.
±-------------------+
| Database |
±-------------------+
| information_schema |
| mysql |
| performance_schema |
| tarena |
| test |
±-------------------+
[root@client ~]#

發佈了225 篇原創文章 · 獲贊 196 · 訪問量 2萬+
發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章