MySQL-MMM架构使用

  • 问题

本案例要求基于普通版的MySQL服务器改造MMM架构,完成以下任务操作:

  • 启动MMM集群架构
  • 设置集群中服务器为online状态
  • 方案

MySQL-MMM架构部署完成后需要启动,数据库端启动mmm-agent进程,管理端启动mmm-monitor进程,启动完成后设置所有数据库主机状态为online。

  • 步骤

实现此案例需要按照如下步骤进行。

步骤一:启动MMM集群架构

1)启动mmm-agent进程

master1操作:

[[email protected] ~]# /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操作:

[[email protected] ~]# /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操作:

[[email protected] ~]# /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操作:

[[email protected] ~]# /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主机操作:

[[email protected] ~]# /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服务器上执行。

查看当前集群中各服务器状态:

[[email protected] ~]# 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:

[[email protected] ~]# mmm_control set_online master1

OK: State of 'master1' changed to ONLINE. Now you can wait some time and check its new roles!

[[email protected] ~]# mmm_control set_online master2

OK: State of 'master2' changed to ONLINE. Now you can wait some time and check its new roles!

[[email protected] ~]# mmm_control set_online slave1

OK: State of 'slave1' changed to ONLINE. Now you can wait some time and check its new roles!

[[email protected] ~]# mmm_control set_online slave2

OK: State of 'slave2' changed to ONLINE. Now you can wait some time and check its new roles!

[[email protected] ~]#

再次查看当前集群中各服务器状态:

[[email protected] ~]# 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)

 

[[email protected] ~]#

步骤三:测试MySQL-MMM架构

1)客户机安装MySQL-client软件包

[[email protected] ~]# tar xvf MySQL-5.6.15-1.el6.x86_64.rpm-bundle.tar

.. ..

[[email protected] ~]# rpm -ivh MySQL-client-5.6.15-1.el6.x86_64.rpm

.. ..

2)MySQL-MMM虚拟IP访问测试

[[email protected] ~]# 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               |

+--------------------+

[[email protected] ~]#

 

[[email protected] ~]# 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               |

+--------------------+

[[email protected] ~]#

 

[[email protected] ~]# 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               |

+--------------------+

[[email protected] ~]#

3)主数据库宕机测试

[[email protected] ~]# service mysql stop //停止master1服务

Shutting down MySQL....                                    [确定]

[[email protected] ~]#

 

[[email protected] ~]# 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)

[[email protected] ~]#

 

[[email protected] ~]# 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               |

+--------------------+

[[email protected] ~]#

 

猜你喜欢

转载自blog.csdn.net/weixin_44792728/article/details/90677862