Mysql-mmm集群部署
admin
2023-05-05 03:40:58
0

  90主 <----------> 91主

   |

   |

   |

  ------------------------------

   | |

   | |

   | |

  92从 93从    


systemctl stop firewalld.service ;systemctl disable firewalld.service ;setenforce 0



MySQL-mmm

一、配置主从同步结构

1)配置主从同步

90: 用户配置 启用 binlog 日志 重启数据库服务 指定主数据库服务器信息

91: 用户配置 启用 binlog 日志 允许级联复制 重启数据库服务 指定主数据库服务器信息

[root@pc91 ~]# vim /etc/my.cnf

[mysqld]

validate_password_policy=0

validate_password_length=6

server_id=91

log-bin=master91

binlog_format="mixed"

log_slave_updates


-> grant replication slave on *.* to slaveuser@"%" identified by '123456';


-> change master to

-> master_host="主服务器 ip 地址",

-> master_user="授权用户名",

-> master_password="授权用户密码",

-> master_log_file="主服务器正在使用的 binlog 日志",

-> master_log_pos=主服务当前的偏移量;

#指定主服务器


2)配置一主多从结构

92: 指定server_id 重启数据库服务 指定主数据库服务器信息

93: 指定server_id 重启数据库服务 指定主数据库服务器信息


[root@pc92 ~]# vim /etc/my.cnf

[mysqld]

validate_password_policy=0

validate_password_length=6

server_id=92


-> change master to

-> master_host="主服务器 ip 地址",

-> master_user="授权用户名",

-> master_password="授权用户密码",

-> master_log_file="主服务器正在使用的 binlog 日志",

-> master_log_pos=主服务当前的偏移量;

#指定主服务器


mysql> show master status\G;


mysql> start slave;


mysql> show slave status\G;


3)在客户端测试主从同步配置

a、 

在90主机上添加访问数据的用户guser,能够在其他3台主机上也有相同的授权用户

-> grant select  on gamedb.* to guser@'%' identified by '123456';


b、

在客户端主机94 使用授权用户guser 连接14服务器,产生的新数据在他3台主机上也有

-> select user,host from mysql.user where user="guser";


二、配置mysql-mmm

1)mysql-mmm 介绍 

监控服务: 运行在管理节点  用来监控数据节点

代理服务: 运行在数据节点  用来提供系统给监控主机


2)在所有主机上安装mysql-mmm软件(90-94)

#yum  -y  install   perl-*

#unzip  mysql-mmm.zip

#cd mysql-mmm

#make  install

#ls  /etc/mysql-mmm/*.conf


3)修改配置文件

a  修改数据节点代理服务配置文件  (90 91 92 93) 

vim  /etc/mysql-mmm/mmm_agent.conf

include  mmm_command.conf

this  自定义名称


b  修改管理节点监控服务的配置文件 (94)

vim /etc/mysql-mmm/mmm_mon.conf

>

include mmm_common.conf


        ip                      192.168.4.94 //本机IP

        pid_path                                /var/run/mmm_mond.pid

        bin_path                                /usr/lib/mysql-mmm/

        status_path                             /var/lib/misc/mmm_mond.status

        ping_ips        192.168.4.90, 192.168.4.91, 192.168.4.92, 192.168.4.93 //监控的服务器IP


        monitor_user                    monitor //监控状态时使用的用户名

        monitor_password                123456 //监控状态时使用的用户密码

>


c 修改公共文件 

vim /etc/mysql-mmm/mmm_command.conf

>

active_master_role      writer



        cluster_interface               eth0


        pid_path                                /var/run/mmm_agentd.pid

        bin_path                                /usr/lib/mysql-mmm/


    replication_user        slaveuser //设置主从同步的用户

    replication_password    123456 //设置主从同步用户密码


        agent_user              agent //控制数据库用户

        agent_password          123456 //控制数据库用户密码


//设置第一个主服务器

        ip                              192.168.4.90

        mode                                    master

        peer                                    db91 //指定另外一台主服务器


//设置第二台主服务器

        ip                              192.168.4.91

        mode                                    master

        peer                                    db90


//设置从服务器

        ip                              192.168.4.92

        mode                                    slave


//设置从服务器

        ip                              192.168.4.93

        mode                                    slave



//指定主服务器VIP地址

        hosts                           db90, db91

        ips                             192.168.4.100

        mode                                    exclusive


//指定从服务器VIP地址

        hosts                           db92, db93

        ips                             192.168.4.101, 192.168.0.102

        mode                                    balanced

>


d 根据配置文件的设置,在数据节点主机上添加对应授权用户

-> grant replication client on *.* to monitor@'%' identified by '123456';

-> grant replication client,process,super on *.* to agent@'%' identified by '123456';

-> select  user,host from mysql.user where user in ("monitor","agent");


4)启动服务

a 启动数据节点主机上代理服务: mmm_agent

安装服务运行依赖的软件包   安装获取vip地址软件包arp_net   启动服务

[root@pc90 ~]# /etc/init.d/mysql-mmm-agent start

[root@pc90 ~]# netstat -pantu | grep 9989


b 启动管理节点主机上监控服务:mmm_mond

安装服务运行依赖的软件包    启动服务

[root@pc94 ~]# /etc/init.d/mysql-mmm-monitor start

[root@pc94 ~]# netstat -pantu | grep 9988


三、验证mysql-mmm配置

a 查看数据库节点上的数据库服务是运行的

[root@pc94 ~]# systemctl status mysqld


b IO线程 和 SQL 线程都是Yes状态  

mysql> show slave status\G;


c 在监控服务器本机登录管理界面查看,查看数据库服务器的状态

[root@pc94 ~]# mmm_control show

defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined()?)

  db90(192.168.4.90) master/AWAITING_RECOVERY. Roles: 

  db91(192.168.4.91) master/AWAITING_RECOVERY. Roles: 

  db92(192.168.4.92) slave/AWAITING_RECOVERY. Roles: 

  db93(192.168.4.93) slave/AWAITING_RECOVERY. Roles:


[root@pc94 ~]# mmm_control set_online db90

[root@pc94 ~]# mmm_control show

defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined()?)

  db90(192.168.4.90) master/ONLINE. Roles: writer(192.168.4.100)

  db91(192.168.4.91) master/ONLINE. Roles: 

  db92(192.168.4.92) slave/ONLINE. Roles: reader(192.168.0.102)

  db93(192.168.4.93) slave/ONLINE. Roles: reader(192.168.4.101)


[root@pc94 ~]# mmm_control show

defined(@array) is deprecated at /usr/share/perl5/vendor_perl/Log/Log4perl/Config.pm line 863.

(Maybe you should just omit the defined()?)

  db90(192.168.4.90) master/ONLINE. Roles: writer(192.168.4.100)

  db91(192.168.4.91) master/HARD_OFFLINE. Roles: 

  db92(192.168.4.92) slave/ONLINE. Roles: reader(192.168.0.102)

  db93(192.168.4.93) slave/ONLINE. Roles: reader(192.168.4.101)


相关内容

热门资讯

Google在港推出AI代理G... 观点网讯:7月29日,Google在香港推出AI代理Gemini Spark,该代理可全天候在后台运...
5G+165Hz!联想新品官宣... 近两年来,小屏平板一直是比较有趣的一个品类。 不同于大平板注重效率、手机追求万能的特点,拯救者Y70...
原创 马... 马斯克又出来了。这次说2036年钱就没用了。 理由是人工智能加机器人,东西多到你用不完,还拿钱干嘛...
美的集团:我国智能家居互联互通... IT之家 7 月 30 日消息,美的集团今日发布公告,7 月 21 日至 23 日,智能家居互联互通...
华为新款MatePad Pro... 【CNMO科技消息】7月30日,@华为终端 官宣全新旗舰平板华为MatePad Pro。 新款华为...
从实验室到实景验证:6G光子太... 全息通信是第六代移动通信(6G)的典型应用场景之一,旨在通过融合无线传输与全息三维成像技术,实现超大...
从“能对话”到“能干活”——人... 【经济界面】 光明日报记者 刘坤 李晓东 周洪双 人工智能(AI)眼镜化身为个人“助理”,实时进行...
【全新发布】UminiP Pr... (来源:洲明科技)
日本通过“H3火箭8号”发射失... △H3火箭(资料图) 日本文部科学省30日召开关于去年“H3火箭8号”发射失败的会议。会议通过的最终...
互联网巨头抢滩健康硬件,上游芯... 封面新闻记者 付文超 当下,互联网巨头对健康硬件的押注,正在成为产业现实,加速拉动整个产业链步入新一...