部署mysql高可集群 MysqL-mmm + MysqL主从同步
systemctl stop firewalld
setenforce 0
配置YUM源
yum -y install gcc gcc-c++ perl-*
++++++++++++++++++++++++++++++
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);
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 监控服务的主配置文件
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
# 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 addr show | grep 192.168.4.100
测试配置
254客户端访问
ping 192.168.4.100
MysqL -h292.168.4.100 -ustu10 -p123456 gamedb
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。