189 8069 5689

MySQL数据管理7

部署MySQL高可集群 mysql-mmm + mysql主从同步

创新互联主要从事成都网站制作、成都网站设计、外贸营销网站建设、网页设计、企业做网站、公司建网站等业务。立足成都服务榆次,10多年网站建设经验,价格优惠、服务专业,欢迎来电咨询建站服务:18982081108

环境准备  (四台数据库服务器 12   11    10    9 )

systemctl  stop firewalld

setenforce  0

配置YUM源

yum -y  install  gcc  gcc-c++   perl-*

systemctl   start  mysqld

++++++++++++++++++++++++++++++

一 配置mysql主从同步(12   11    10    9 )

9 和  10   配置为主主结构

12  和  11  配置为 10 的从数据库服务器

要求:客户端访问数据库服务器9时 创建的库表记录 在 11 和12 

上也要有。

用户授权:

1 有同步数据权限的用户(9 和 10)

grant  replication  slave  on  *.*   to  slaveuser@"%"  

identified by "123456";

把9 和  10   配置为主主结构

9

vim /etc/my.cnf

[mysqld]

server_id=9

log_bin=master9

binlog_format="mixed"

:wq

10

vim /etc/my.cnf

[mysqld]

server_id=10

log_bin=master10

binlog_format="mixed"

log_slave_updates

:wq

9

mysql> change master  to  

master_host="192.168.4.10",master_user="slaveuser",

master_password="123456",master_log_file="master10

.000001",master_log_pos=154;

mysql> show slave status\G;

10

mysql> change master  to  

master_host="192.168.4.9",master_user="slaveuser",m

aster_password="123456",master_log_file="master9.00

0001",master_log_pos=154;

mysql> show slave status\G;

12  和  11  配置为 10 的从数据库服务器

11

vim /etc/my.cnf

[mysqld]

server_id=11

:wq

12

vim /etc/my.cnf

[mysqld]

server_id=12

:wq

11 和 12 

mysql> change master  to  

master_host="192.168.4.10",master_user="slaveuser",

master_password="123456",master_log_file="master10

.000001",master_log_pos=154;

mysql> show slave status\G;

测试注册同步配置:

9

mysql> create  database gamedb;

mysql>grant all on gamedb.*  to  stu10@"%" identified 

by "123456";

254

mysql  -h292.168.4.9  -ustu10  -p123456  gamedb

mysql> create  table  t1(id int);

mysql> insert into  t1  values(100);

在其他3台数据库服务器上能够查看记录和授权用户

select  user,host  from mysql.user  where  user="stu10";

select  * from gamedb.t1;

二、配置mysql-mmm

mysql-mmm软件介绍

mmm_monitor 监控服务 运行在监控端

mmm_agentd  代理服务  运行在数据库服务器上

ip规划

写vip地址 192.168.4.100 (9  、10)

读vip地址 192.168.4.101/102 (11  、12)

配置监控服务器8

systemctl  stop firewalld

setenforce  0

配置YUM源

yum -y  install  gcc  gcc-c++   perl-*

装包 (12  、 11   、 10 、 9 、8)

5  unzip mysql-mmm.zip 

cd mysql-mmm/

tar -zxvf mysql-mmm-2.2.1.tar.gz

cd mysql-mmm-2.2.1/

make install

配置文件说明

ls /etc/mysql-mmm/

mmm_mon.conf   mmm_monitor 监控服务的主配置文件

mmm_agent.conf   mmm_agentd  代理服务

mmm_common.conf  公共文件( 监控服务器和数据库服务器

都要有)

修改配置文件

1、修改4台数据库服务器上mmm_agentd  代理服务的主配置

文件

vim  /etc/mysqlmmm/mmm_agent.conf 

include mmm_common.conf

this 主机名  #自定义

:wq

2 修改监控服务器上的mmm_monitor 监控服务的主配置文件

3 修改公共文件mmm_common.conf  公共文件

4 在4台数据库服务器上根据mmm_common.conf配置文件中

的设置添加对应的授权用户。

mysql>grant  replication  client  on *.*  to      

monitor@"%"   identified by    "123456";

mysql>grant  replication client,process,super on *.*  to    

 agent@“%" identified by   "123456";

四、启动服务

4.2 启动数据库服务器上agnetd服务

2  rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm 

  4  tar -zxvf Algorithm-Diff-1.1902.tar.gz 

  6  cd Algorithm-Diff-1.1902/

  8  perl Makefile.PL

  9  make

  10  make install

   13  tar -zxvf Proc-Daemon-0.03.tar.gz 

   14  cd Proc-Daemon-0.03/

   16  perl Makefile.PL 

   17  make

   18  make install

21  gunzip Net-ARP-1.0.8.tgz 

23  tar -xvf Net-ARP-1.0.8.tar 

25  cd Net-ARP-1.0.8/

27  perl Makefile.PL 

28  make 

29  make install

31  /etc/init.d/mysql-mmm-agent status

 32  /etc/init.d/mysql-mmm-agent start

 33  netstat -utnalp  | grep :9989

ls /var/log/mysql-mmm/mmm_agentd.log

4.3 启动监控服务器上monitor服务

  2  rpm -ivh perl-Log-Log4perl-1.26-1.el6.rf.noarch.rpm 

  4  tar -zxvf Algorithm-Diff-1.1902.tar.gz 

  6  cd Algorithm-Diff-1.1902/

  8  perl Makefile.PL

  9  make

  10  make install

   13  tar -zxvf Proc-Daemon-0.03.tar.gz 

   14  cd Proc-Daemon-0.03/

   16  perl Makefile.PL 

   17  make

   18  make install

  27  /etc/init.d/mysql-mmm-monitor status

   28  /etc/init.d/mysql-mmm-monitor start

   29  netstat -utnalp  | grep :9988

   30  ls /var/log/mysql-mmm/mmm_mond.log 

登录监控服务器8的管理页面查看数据库服务器的状态

# mmm_control help

# mmm_control show

# mmm_control  set_online  master9

# mmm_control  set_online  master10

# mmm_control  set_online  master11

# mmm_control  set_online  master12

# mmm_control show

在数据库服务器本机查看获取的虚拟ip地址

#ip  addr  show  | grep  192.168.4.100

  

测试配置

254客户端访问

ping  192.168.4.100

mysql  -h292.168.4.100   -ustu10  -p123456   gamedb


名称栏目:MySQL数据管理7
网页路径:http://cdxtjz.cn/article/gjhsip.html

其他资讯