MySQL中MMM实现高可用群集(2)

<host db3>
    ip      192.168.177.132
    mode    slave
</host>
<host db4>
    ip      192.168.177.133
    mode    slave
</host>
<role writer>
    hosts  db1, db2
    ips    192.168.177.200    #主服务器虚拟IP
    mode    exclusive
</role>
<role reader>
    hosts  db3, db4
    ips    192.168.177.20,192.168.177.30  #从服务器虚拟IP
    mode    balanced
</role>
在主1上面复制:
# scp mmm_common.conf root@192.168.177.135:/etc/mysql-mmm/
# scp mmm_common.conf root@192.168.177.133:/etc/mysql-mmm/
# scp mmm_common.conf root@192.168.177.132:/etc/mysql-mmm/

MySQL中MMM实现高可用群集

MySQL中MMM实现高可用群集

MySQL中MMM实现高可用群集

在monitor服务器上配置

# systemctl stop firewalld.service
# setenforce 0
# wget -O /etc/yum.repos.d/CentOS-Base.repo
# yum -y install epel-release
# yum clean all && yum makecache
# yum -y install mysql-mmm*
# cd /etc/mysql-mmm
# vim mmm_mon.conf
<host default>
    ping_ips            192.168.177.132,192.168.177.128,192.168.177.133,192.168.177.135 //四台地址
    monitor_user        mmm_monitor
    monitor_password    123456
    auto_set_online    10
</host>
在m1上:# scp mmm_common.conf root@192.168.177.134:/etc/mysql-mmm/

在所有数据库上为mmm_agent授权-四台主从

# mysql>
# grant super, replication client, process on *.* to 'mmm_agent'@'192.168.177.%' identified by '123456';

在所有数据库上为mmm_moniter授权-四台主从

# grant replication client on *.* to 'mmm_monitor'@'192.168.177.%' identified by '123456';
# flush privileges;

修改所有数据库的mmm_agent.conf-四台主从

# vim /etc/mysql-mmm/mmm_agent.conf
this db1 //根据规划进行逐一调整
this db2
this db3
this db4

在所有数据库服务器上启动mysql-mmm-agent-四台主从

# systemctl start mysql-mmm-agent.service
# systemctl enable mysql-mmm-agent.service  #开机自启动

在monitor服务器上配置

# systemctl start mysql-mmm-monitor.service
# mmm_control show
# mmm_control checks all
# mmm_control move_role writer db2    //指定db2绑定虚拟IP

MySQL中MMM实现高可用群集

故障测试

停止m1 确认 虚拟地址 200 是否移动到 m2 上。注意:主不会抢占
# systemctl stop mariadb.service //m1上
# mmm_control show
  db1(192.168.177.128) master/HARD_OFFLINE. Roles:
  db2(192.168.177.135) master/ONLINE. Roles: writer(192.168.177.200)

Linux公社的RSS地址:https://www.linuxidc.com/rssFeed.aspx

内容版权声明:除非注明,否则皆为本站原创文章。

转载注明出处:https://www.heiqu.com/0efe28fa851bcea6e7cf7d780802356c.html