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 ~]#

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

董筱杰

你的鼓励将是我创作的最大动力

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值