|
环境规划:
monitor IP:192.168.1.247 host:tong1
db1 IP:192.168.1.248 host:tong2
db2 IP:192.168.1.249 host:tong3
数据库:mysql-5.6.21
1.网络环境布置
tong1监控节点:
[iyunv@tong1 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 10:78:D2:C7:83:03
inet addr:192.168.1.247 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::1278:d2ff:fec7:8303/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4953337 errors:0 dropped:0 overruns:0 frame:0
TX packets:78512 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:346785301 (330.7 MiB) TX bytes:5389268 (5.1 MiB)
[iyunv@tong1 ~]# cat /etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3
[iyunv@tong1 ~]#
tong2数据节点:
[iyunv@tong2 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 10:78:D2:C7:17:E8
inet addr:192.168.1.248 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::1278:d2ff:fec7:17e8/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:4930658 errors:0 dropped:0 overruns:0 frame:0
TX packets:19441 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:315661835 (301.0 MiB) TX bytes:2133138 (2.0 MiB)
[iyunv@tong2 ~]# cat /etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3
[iyunv@tong2 ~]#
tong3数据节点:
[iyunv@tong3 ~]# ifconfig eth0
eth0 Link encap:Ethernet HWaddr 10:78:D2:C8:F7:50
inet addr:192.168.1.249 Bcast:192.168.1.255 Mask:255.255.255.0
inet6 addr: fe80::1278:d2ff:fec8:f750/64 Scope:Link
UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1
RX packets:6864426 errors:0 dropped:0 overruns:0 frame:0
TX packets:99046 errors:0 dropped:0 overruns:0 carrier:0
collisions:0 txqueuelen:1000
RX bytes:694563286 (662.3 MiB) TX bytes:7322797 (6.9 MiB)
[iyunv@tong3 ~]# cat /etc/hosts
192.168.1.247 tong1
192.168.1.248 tong2
192.168.1.249 tong3
[iyunv@tong3 ~]#
2.在监控节点上安装mysql-mmm软件
[iyunv@tong1 ~]# rpm -ivh http://mirrors.sohu.com/fedora-epel/6/x86_64/epel-release-6-8.noarch.rpm
[iyunv@tong1 ~]# cd /etc/yum.repos.d/
[iyunv@tong1 yum.repos.d]# vim epel.repo
将baseurl前面的#号去掉
将enabled=0修改为enabled=1
[iyunv@tong1 yum.repos.d]# vim epel-testing.repo
将baseurl前面的#号去掉
将enabled=0修改为enabled=1
[iyunv@tong1 yum.repos.d]# yum install mysql-mmm* --安装mysql-mmm软件
[iyunv@tong1 yum.repos.d]# mmm_
mmm_agentd mmm_backup mmm_clone mmm_control mmm_mond mmm_restore
[iyunv@tong1 yum.repos.d]# mmm_
3.在tong2和tong3节点安装mysql并做主主架构
主主架构环境:http://tongcheng.blog.iyunv.com/6214144/1588375
4.在tong2和tng3节点创建监控用户
tong2数据节点:
[iyunv@tong2 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.21-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant super,replication slave,replication client on *.* to 'mmm_agent'@'192.168.1.247' identified by 'system';
Query OK, 0 rows affected (0.00 sec)
mysql> grant super,replication slave,replication client on *.* to 'mmm_monitor'@'192.168.1.247' identified by 'system';
Query OK, 0 rows affected (0.00 sec)
mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)
mysql>
tong3数据节点:
[iyunv@tong3 ~]# mysql -u root -p
Enter password:
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 7
Server version: 5.6.21-log MySQL Community Server (GPL)
Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.
Oracle is a registered trademark of Oracle Corporation and/or its
affiliates. Other names may be trademarks of their respective
owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.
mysql> grant super,replication slave,replication client on *.* to 'mmm_agent'@'192.168.1.247' identified by 'system';
Query OK, 0 rows affected (0.00 sec)
mysql> grant super,replication slave,replication client on *.* to 'mmm_monitor'@'192.168.1.247' identified by 'system';
Query OK, 0 rows affected (0.00 sec)
mysql> flush tables;
Query OK, 0 rows affected (0.00 sec)
mysql>
4.在monitor监控节点配置,添加mysql服务器节点
[iyunv@tong1 mysql-mmm]# cd /etc/mysql-mmm/
[iyunv@tong1 mysql-mmm]# vim mmm_agent.conf
this tong1 --主机名
[iyunv@tong1 mysql-mmm]# vim mmm_common.conf
active_master_role writer
<host default>
cluster_interface eth0
pid_path /var/run/mysql-mmm/mmm_agentd.pid
bin_path /usr/libexec/mysql-mmm/
replication_user tong2 --复制的用户名
replication_password system --复制用户名的密码
agent_user mmm_agent --代理的用户名
agent_password system --代理用户密码
</host>
<host tong2> --第一个主服务器的主机名
ip 192.168.1.248 --主服务器的IP地址
mode master --服务器状态为主服务器
peer tong2 --主机名
</host>
<host tong3>
ip 192.168.1.249
mode master
peer tong2
</host>
<role writer>
hosts tong2, tong3 --两个节点都可以写
ips 192.168.1.254 --写的vip地址
mode exclusive
</role>
<role reader>
hosts tong2, tong3 --两个服务器也可以读
ips 192.168.1.253 --读的vip地址
mode balanced
</role>
[iyunv@tong1 mysql-mmm]# vim mmm_mon.conf
include mmm_common.conf
<monitor>
ip 127.0.0.1
pid_path /var/run/mysql-mmm/mmm_mond.pid
bin_path /usr/libexec/mysql-mmm
status_path /var/lib/mysql-mmm/mmm_mond.status
ping_ips 192.168.1.248,192.168.1.249 --检查两个主服务器的IP地址
auto_set_online 60 --检查间隔60秒
</monitor>
<host default>
monitor_user mmm_monitor --监控用户名
monitor_password system --监控用户的密码
</host>
debug 0
5.对两个主服务器的配置
tong2数据节点:
[iyunv@tong2 mysql-mmm]# yum install mysql-mmm-agent
[iyunv@tong2 mysql-mmm]# cd /etc/mysql-mmm/
[iyunv@tong2 mysql-mmm]# vim mmm_agent.conf
this tong2 --主机名
[iyunv@tong2 mysql-mmm]# vim mmm_common.conf
active_master_role writer
<host default>
cluster_interface eth0
pid_path /var/run/mysql-mmm/mmm_agentd.pid
bin_path /usr/libexec/mysql-mmm/
replication_user tong2
replication_password system
agent_user mmm_agent
agent_password system
</host>
<host tong2>
ip 192.168.1.248
mode master
peer tong2
</host>
<host tong3>
ip 192.168.1.249
mode master
peer tong3
</host>
<role writer>
hosts tong2, tong3
ips 192.168.1.254
mode exclusive
</role>
<role reader>
hosts tong2, tong3
ips 192.168.1.253
mode balanced
</role>
[iyunv@tong2 mysql-mmm]# /etc/init.d/mysql-mmm-agent restart
Stopping MMM Agent Daemon: [ OK ]
Starting MMM Agent Daemon: [ OK ]
[iyunv@tong2 mysql-mmm]#
tong3数据节点和tong2数据节点是一样
6.在tong1监控节点查看状态
[iyunv@tong1 mysql-mmm]# mmm_control show
tong2(192.168.1.248) master/ONLINE. Roles: writer(192.168.1.254)
tong3(192.168.1.249) master/ONLINE. Roles: reader(192.168.1.253)
[iyunv@tong1 mysql-mmm]#
|
|