设为首页 收藏本站
查看: 480|回复: 0

[经验分享] mysql高可用方案之mmm架构

[复制链接]
累计签到:1 天
连续签到:1 天
发表于 2014-12-12 08:29:01 | 显示全部楼层 |阅读模式
环境规划:
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]#


运维网声明 1、欢迎大家加入本站运维交流群:群②:261659950 群⑤:202807635 群⑦870801961 群⑧679858003
2、本站所有主题由该帖子作者发表,该帖子作者与运维网享有帖子相关版权
3、所有作品的著作权均归原作者享有,请您和我们一样尊重他人的著作权等合法权益。如果您对作品感到满意,请购买正版
4、禁止制作、复制、发布和传播具有反动、淫秽、色情、暴力、凶杀等内容的信息,一经发现立即删除。若您因此触犯法律,一切后果自负,我们对此不承担任何责任
5、所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其内容的准确性、可靠性、正当性、安全性、合法性等负责,亦不承担任何法律责任
6、所有作品仅供您个人学习、研究或欣赏,不得用于商业或者其他用途,否则,一切后果均由您自己承担,我们对此不承担任何法律责任
7、如涉及侵犯版权等问题,请您及时通知我们,我们将立即采取措施予以解决
8、联系人Email:admin@iyunv.com 网址:www.yunweiku.com

所有资源均系网友上传或者通过网络收集,我们仅提供一个展示、介绍、观摩学习的平台,我们不对其承担任何法律责任,如涉及侵犯版权等问题,请您及时通知我们,我们将立即处理,联系人Email:kefu@iyunv.com,QQ:1061981298 本贴地址:https://www.yunweiku.com/thread-37897-1-1.html 上篇帖子: Centos 编译安装mysql 5.6.21 下篇帖子: MySQL主从复制与读写分离 mysql
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则

扫码加入运维网微信交流群X

扫码加入运维网微信交流群

扫描二维码加入运维网微信交流群,最新一手资源尽在官方微信交流群!快快加入我们吧...

扫描微信二维码查看详情

客服E-mail:kefu@iyunv.com 客服QQ:1061981298


QQ群⑦:运维网交流群⑦ QQ群⑧:运维网交流群⑧ k8s群:运维网kubernetes交流群


提醒:禁止发布任何违反国家法律、法规的言论与图片等内容;本站内容均来自个人观点与网络等信息,非本站认同之观点.


本站大部分资源是网友从网上搜集分享而来,其版权均归原作者及其网站所有,我们尊重他人的合法权益,如有内容侵犯您的合法权益,请及时与我们联系进行核实删除!



合作伙伴: 青云cloud

快速回复 返回顶部 返回列表