网创优客建站品牌官网
为成都网站建设公司企业提供高品质网站建设
热线:028-86922220
成都专业网站建设公司

定制建站费用3500元

符合中小企业对网站设计、功能常规化式的企业展示型网站建设

成都品牌网站建设

品牌网站建设费用6000元

本套餐主要针对企业品牌型网站、中高端设计、前端互动体验...

成都商城网站建设

商城网站建设费用8000元

商城网站建设因基本功能的需求不同费用上面也有很大的差别...

成都微信网站建设

手机微信网站建站3000元

手机微信网站开发、微信官网、微信商城网站...

建站知识

当前位置:首页 > 建站知识

Mysql-mmm集群部署

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

我们提供的服务有:成都网站制作、网站设计、微信公众号开发、网站优化、网站认证、芒康ssl等。为千余家企事业单位解决了网站和推广的问题。提供周到的售前咨询和贴心的售后服务,是有科学管理、有技术的芒康网站制作公司

   |

   |

   |

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

   | |

   | |

   | |

  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)


分享标题:Mysql-mmm集群部署
网页网址:http://bjjierui.cn/article/pghggj.html

其他资讯