MySQL高可用MMM方案安装部署分享_Mysql

1 install mysql

  请参考http://www.jb51.net/article/47094.htm

2. Basic configuration of master 1

3. Create users
GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'%' IDENTIFIED BY 'mmm_monitor';
GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'%' IDENTIFIED BY 'mmm_agent';
GRANT REPLICATION SLAVE ON *.* TO 'repl'@'10.88.49.%' IDENTIFIED BY 'repl';
grant insert,create,delete,update,select on *.* to 'tim'@'%' identified by 'tim';
Note: Don not use a replication_password longer than 32 characters

4. Synchronisation of data between both databases

5. Setup replication
set m-s:
change master to master_host='10.88.49.119',master_log_file='mysql56-bin.000026',master_log_pos=332, master_user='repl',master_password='repl';

6. Install mmm
6.1 download mmm.tar.gz
wget http://mysql-mmm.org/_media/:mmm2:mysql-mmm-2.2.1.tar.gz
6.2 mv :mmm2:mysql-mmm-2.2.1.tar.gz mysql-mmm-2.2.1.tar.gz
tar -xvf mysql-mmm-2.2.1.tar.gz
cd mysql-mmm-2.2.1
make
cmake
[] don not require make and make install, there have *.conf in /etc/mysql-mmm folder.

7. install lib package
yum install -y perl-*
yum install -y libart_lgpl.x86_64
yum install -y mysql-mmm.noarch fail
yum install -y rrdtool.x86_64
yum install -y rrdtool-perl.x86_64
7.1 []another way to install lib package in network
cpan -i Algorithm::Diff Class::Singleton DBI DBD::mysql Log::Dispatch Log::Log4perl Mail::Send Net::Ping Proc::Daemon Time::HiRes Params::Validate Net::ARP

8. Config MMM of DB host
vim /etc/mysql-mmm/mmm_common.conf
Don not forget to copy this file to all other hosts (including the monitoring host).
#Bugsfor$
scp /etc/mysql-mmm/mmm_common.conf 10.88.49.119:/etc/mysql-mmm/
scp /etc/mysql-mmm/mmm_common.conf 10.88.49.122:/etc/mysql-mmm/
scp /etc/mysql-mmm/mmm_common.conf 10.88.49.123:/etc/mysql-mmm/

On the database hosts we need to edit /etc/mysql-mmm/mmm_agent.conf. Change “db1” accordingly on the other hosts:
chkconfig --add mysql-mmm-agent

9. Config Monitor
On the monitor host(10.88.49.123) we need to edit /etc/mysql-mmm/mmm_mon.conf:
include mmm_common.conf
<monitor>
ip 127.0.0.1
pid_path /var/run/mmm_mond.pid
bin_path /usr/lib/mysql-mmm/
status_path /var/lib/misc/mmm_mond.status
auto_set_online 5
ping_ips 10.88.49.254,10.88.49.130,10.88.49.131,10.88.49.132,10.88.49.133,10.88.49.134
</monitor>
<host default>
monitor_user mmm_monitor
monitor_password mmm_monitor
</host>
debug 0
ping_ips are some ips that are pinged to determine whether the network connection of the monitor is ok. I used my switch of GATEWAY (10.88.49.254) and the four database server.follow this
[root@oracle mysql-mmm]# cat /etc/sysconfig/network-scripts/ifcfg-eth0
DEVICE=eth0
IPADDR=10.88.49.118
NETWASK=255.255.254.0
GATEWAY=10.88.49.254
DNS1=10.106.185.143
DNS2=10.106.185.138
ONBOOT=yes
BOOTPROTO=none
TYPE=Ethernet
HWADDR=00:15:5D:01:6A:0C

10. Start in database hosts
chkconfig --add mysql-mmm-agent
[root@oracle ~]# mysql-mmm-agent start
-bash: mysql-mmm-agent: command not found
[root@oracle ~]# service mysql-mmm-agent start
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Starting MMM Agent daemon... Can not locate Proc/Daemon.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/sbin/mmm_agentd line 7.
BEGIN failed--compilation aborted at /usr/sbin/mmm_agentd line 7.
[root@oracle ~]# cpan Proc::Daemon
[root@oracle ~]# cpan Log::Log4perl
[root@oracle ~]# /etc/init.d/mysql-mmm-agent start
Daemon bin: '/usr/sbin/mmm_agentd'
Daemon pid: '/var/run/mmm_agentd.pid'
Starting MMM Agent daemon... Ok

11. Start in monitor hosts
chkconfig --add mysql-mmm-monitor
[root@localhost mysql-mmm-2.2.1]# service mysql-mmm-monitor start
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Starting MMM Monitor daemon: Can not locate Proc/Daemon.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/sbin/mmm_mond line 11.
BEGIN failed--compilation aborted at /usr/sbin/mmm_mond line 11.
failed
[root@oracle ~]# cpan Proc::Daemon
[root@oracle ~]# cpan Log::Log4perl
[root@localhost mysql-mmm-2.2.1]# service mysql-mmm-monitor start
Daemon bin: '/usr/sbin/mmm_mond'
Daemon pid: '/var/run/mmm_mond.pid'
Starting MMM Monitor daemon: Ok

12. Check fail
[root@oracle mysql-mmm]# ping 10.88.49.130
PING 10.88.49.130 (10.88.49.130) 56(84) bytes of data.
From 10.88.49.118 icmp_seq=2 Destination Host Unreachable
From 10.88.49.118 icmp_seq=3 Destination Host Unreachable
From 10.88.49.118 icmp_seq=4 Destination Host Unreachable
From 10.88.49.118 icmp_seq=6 Destination Host Unreachable
From 10.88.49.118 icmp_seq=7 Destination Host Unreachable
From 10.88.49.118 icmp_seq=8 Destination Host Unreachable

12.1 debug error info
在agent.conf 和 monitor.conf 分别加上 debug 1
然后看输出的日志

[root@localhost mysql-mmm]# mmm_control show
db1(10.88.49.118) master/AWAITING_RECOVERY. Roles:
db2(10.88.49.119) master/AWAITING_RECOVERY. Roles:
db3(10.88.49.122) slave/AWAITING_RECOVERY. Roles:
[root@localhost mysql-mmm]# mmm_control set_online db1
OK: State of 'db1' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control set_online db2
OK: State of 'db2' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control set_online db3
OK: State of 'db3' changed to ONLINE. Now you can wait some time and check its new roles!

12.2 ping vip fail
2013/02/19 10:00:15 FATAL Couldn't configure IP '10.88.49.131' on interface 'eth1': undef
2013/02/19 10:00:15 DEBUG Executing /usr/lib/mysql-mmm//agent/mysql_allow_write
Can't locate Net/ARP.pm in @INC (@INC contains: /usr/local/lib64/perl5 /usr/local/share/perl5 /usr/lib64/perl5/vendor_perl /usr/share/perl5/vendor_perl /usr/lib64/perl5 /usr/share/perl5 .) at /usr/share/perl5/vendor_perl/MMM/Agent/Helpers/Network.pm line 11.
[1.1]
cpan Net/ARP.pm
yum install libuuid* Error
[2.1] if [1.1] fail , try this
[root@localhost mysql-mmm]# perl -MCPAN -e shell
cpan> install Net::ARP
[ok]

12.3 fail info :
2013/02/19 10:25:23 INFO Added: reader(10.88.49.131), writer(10.88.49.130)
2013/02/19 10:25:23 DEBUG Executing /usr/lib/mysql-mmm//agent/configure_ip eth1 10.88.49.131
Device "eth1" does not exist.
2013/02/19 10:25:23 FATAL Couldn't configure IP '10.88.49.131' on interface 'eth1': ERROR: Could not check if ip 10.88.49.131 is configured on eth1:
2013/02/19 10:25:23 DEBUG Executing /usr/lib/mysql-mmm//agent/sync_with_master
2013/02/19 10:25:23 DEBUG Executing /usr/lib/mysql-mmm//agent/mysql_allow_write
2013/02/19 10:25:23 DEBUG Executing /usr/lib/mysql-mmm//agent/configure_ip eth1 10.88.49.130
Device "eth1" does not exist.
2013/02/19 10:25:23 FATAL Couldn't configure IP '10.88.49.130' on interface 'eth1': ERROR: Could not check if ip 10.88.49.130 is configured on eth1:
2013/02/19 10:25:23 DEBUG Fetching uptime from /proc/uptime
2013/02/19 10:25:23 DEBUG Uptime is 158489.10
2013/02/19 10:25:23 DEBUG Daemon: Answer = 'OK: Status applied successfully!'
[ok] cluster_interface should set the

12.4 When connect reader vip,Lost package, info :
[root@localhost mysql-mmm]# ping 10.88.49.134
PING 10.88.49.134 (10.88.49.134) 56(84) bytes of data.
64 bytes from 10.88.49.134: icmp_seq=3 ttl=64 time=0.265 ms
64 bytes from 10.88.49.134: icmp_seq=6 ttl=64 time=0.699 ms
64 bytes from 10.88.49.134: icmp_seq=9 ttl=64 time=0.482 ms
64 bytes from 10.88.49.134: icmp_seq=12 ttl=64 time=0.405 ms
64 bytes from 10.88.49.134: icmp_seq=15 ttl=64 time=0.430 ms

14. Check all
[root@localhost ~]# mmm_control checks
db2 ping [last change: 2013/02/19 12:41:45] OK
db2 mysql [last change: 2013/02/19 12:41:45] OK
db2 rep_threads [last change: 2013/02/19 12:41:45] OK
db2 rep_backlog [last change: 2013/02/19 12:41:45] OK: Backlog is null
db3 ping [last change: 2013/02/19 12:41:45] OK
db3 mysql [last change: 2013/02/19 12:41:45] OK
db3 rep_threads [last change: 2013/02/19 12:41:45] OK
db3 rep_backlog [last change: 2013/02/19 12:41:45] OK: Backlog is null
db1 ping [last change: 2013/02/19 12:41:45] OK
db1 mysql [last change: 2013/02/19 12:41:45] OK
db1 rep_threads [last change: 2013/02/19 12:41:45] OK
db1 rep_backlog [last change: 2013/02/19 12:41:45] OK: Backlog is null

15 Check m<->m<->s change
15.1change writer from 10.88.49.118 to 10.88.49.119 Stop mysqld in db1 10.88.49.118
show slave status on 10.88.49.122, see Master_Host is '10.88.49.118'
[root@oracle ~]# service mysqld56 stop
Shutting down MySQL... SUCCESS!

15.1.1 show info in monitor host log
[root@localhost ~]# tail -f /var/log/mysql-mmm/mmm_mond.log
2013/02/20 10:34:42 INFO Removing all roles from host 'db1':
2013/02/20 10:34:42 INFO Removed role 'reader(10.88.49.134)' from host 'db1'
2013/02/20 10:34:42 INFO Removed role 'writer(10.88.49.130)' from host 'db1'
2013/02/20 10:34:42 INFO Orphaned role 'writer(10.88.49.130)' has been assigned to 'db2'
2013/02/20 10:34:42 INFO Orphaned role 'reader(10.88.49.134)' has been assigned to 'db3'
15.1.2 show info in slave host of 10.88.49.122, slave will change its master_host
[root@localhost ~]# mysql -P3307 -S /data56/mysql.sock -p123456
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.88.49.119

15.1.3 but there are some bad info in monitor host of 10.88.49.123, when you run 'mmm_control show', it may hold on .
2013/02/20 10:37:25 DEBUG Listener: Waiting for connection...
2013/02/20 10:37:28 DEBUG Listener: Waiting for connection...

15.1.4 [] why ?
i have solved this problem, it maybe occur when:
(1): 'peer' paramter is wrong .
(2): 'ping_ips' and 'ips' are wrong

15.2 change writer from 10.88.49.119 to 10.88.49.118
15.2.1 start mysqld in 10.88.49.118, stop mysqld in 10.88.49.119, run 'mmm_control set_online db1' in monitor_host
15.2.2 show slave info in slave_host of 10.88.49.122
[root@localhost ~]# mysql -P3307 -S /data56/mysql.sock -p123456
mysql> show slave status\G
*************************** 1. row ***************************
Slave_IO_State: Waiting for master to send event
Master_Host: 10.88.49.118
15.3 stop mysqld on slave_host of 10.88.49.122
15.3.1 show info in monitor_host
[root@localhost mysql-mmm]# mmm_control show
db1(10.88.49.118) master/ONLINE. Roles: reader(10.88.49.134), reader(10.88.49.135), writer(10.88.49.130)
db2(10.88.49.119) master/ONLINE. Roles: reader(10.88.49.131), reader(10.88.49.132), reader(10.88.49.133)
db3(10.88.49.122) slave/HARD_OFFLINE. Roles:
[] the ips change to mm.

15.3.2 start mysqld on slave_host of 10.88.49.122

15.3.3 show info in monitor_host
[root@localhost mysql-mmm]# mmm_control show
db1(10.88.49.118) master/ONLINE. Roles: reader(10.88.49.134), reader(10.88.49.135), writer(10.88.49.130)
db2(10.88.49.119) master/ONLINE. Roles: reader(10.88.49.131), reader(10.88.49.132), reader(10.88.49.133)
db3(10.88.49.122) slave/AWAITING_RECOVERY. Roles:
[] need set online
[root@localhost mysql-mmm]# mmm_control set_online db3
OK: State of 'db3' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control show
db1(10.88.49.118) master/ONLINE. Roles: reader(10.88.49.135), writer(10.88.49.130)
db2(10.88.49.119) master/ONLINE. Roles: reader(10.88.49.131), reader(10.88.49.133)
db3(10.88.49.122) slave/ONLINE. Roles: reader(10.88.49.132), reader(10.88.49.134)

15.4 stop master_host db2 of 10.88.49.119
15.4.1 show info in monitor_host
[root@localhost mysql-mmm]# mmm_control show
db1(10.88.49.118) master/ONLINE. Roles: reader(10.88.49.131), reader(10.88.49.135), writer(10.88.49.130)
db2(10.88.49.119) master/HARD_OFFLINE. Roles:
db3(10.88.49.122) slave/ONLINE. Roles: reader(10.88.49.132), reader(10.88.49.133), reader(10.88.49.134)
see db2 is HARD_OFFLINE

15.4.2 start master_host db2 of 10.88.49.119
[root@localhost mysql-mmm]# mmm_control show
db1(10.88.49.118) master/ONLINE. Roles: reader(10.88.49.131), reader(10.88.49.135), writer(10.88.49.130)
db2(10.88.49.119) master/AWAITING_RECOVERY. Roles:
db3(10.88.49.122) slave/ONLINE. Roles: reader(10.88.49.132), reader(10.88.49.133), reader(10.88.49.134)
see db2 is AWAITING_RECOVERY, so need set online
[root@localhost mysql-mmm]# mmm_control set_online db2
OK: State of 'db2' changed to ONLINE. Now you can wait some time and check its new roles!
[root@localhost mysql-mmm]# mmm_control show
db1(10.88.49.118) master/ONLINE. Roles: reader(10.88.49.135), writer(10.88.49.130)
db2(10.88.49.119) master/ONLINE. Roles: reader(10.88.49.131), reader(10.88.49.132)
db3(10.88.49.122) slave/ONLINE. Roles: reader(10.88.49.133), reader(10.88.49.134)
see db2 is online

15.5 change writer to db2
mmm_control move_role writer db2

相关文章:

http://blog.csdn.net/hguisu/article/details/7349562
http://blog.chinaunix.net/uid-28437434-id-3471237.html
http://mysql-mmm.org/downloads ;
http://mysql-mmm.org/mmm2:guide
http://dev.mysql.com/doc/internals/en/optimizer-primary-optimizations.html

时间: 2024-10-05 20:46:09

MySQL高可用MMM方案安装部署分享_Mysql的相关文章

MySQL高可用MMM方案安装部署分享

1 install mysql 请参考http://www.bitsCN.com/article/47094.htm 2. Basic configuration of master 1 3. Create users GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'%' IDENTIFIED BY 'mmm_monitor'; GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_ag

详解MySQL高可用MMM搭建方案及架构原理_Mysql

先来看看架构,如下图: 部署 1.修改hosts 在所有的服务器中执行相同的操作. vim /etc/hosts 192.168.137.10 master 192.168.137.20 backup 192.168.137.30 slave 192.168.137.40 monitor 2.添加mysql用户 只需要在所有的数据库端执行即可,监控端不需要. GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'192.168.137.%' IDEN

MySQL 高可用MMM安装部署以及故障转移详细资料汇总

  1,      mmm简介 MMM(Master-Masterreplication manager for MySQL)是一套支持双主故障切换和双主日常管理的脚本程序.MMM使用Perl语言开发,主要用来监控和管理MySQL Master-Master(双主)复制,虽然叫做双主复制,但是业务上同一时刻只允许对一个主进行写入,另一台备选主上提供部分读服务,以加速在主主切换时刻备选主的预热,可以说MMM这套脚本程序一方面实现了故障切换的功能,另一方面其内部附加的工具脚本也可以实现多个slave

10款常见MySQL高可用方案选型解读

作者介绍 王松磊,现任职于UCloud,从事MySQL数据库内核研发工作.主要负责UCloud云数据库udb的内核故障排查工作以及数据库新特性的研发工作.   一.概述   我们在考虑MySQL数据库的高可用架构时,主要考虑如下几方面:   如果数据库发生了宕机或者意外中断等故障,能尽快恢复数据库的可用性,尽可能的减少停机时间,保证业务不会因为数据库的故障而中断. 用作备份.只读副本等功能的非主节点的数据应该和主节点的数据实时或者最终保持一致. 当业务发生数据库切换时,切换前后的数据库内容应当一

MySQL高可用方案选型参考

本文由「MySQL中文网」原创,"MySQL中文"公众号是 http://imysql.com 的官方唯一公众号,微信首发. 欢迎关注「MySQL中文」公众号(ID: imysql_wx),我们会不定期推送MySQL相关原创干货. 本次专题是 MySQL高可用方案选型,这个专题想必有很多同学感兴趣. 高可用的意义以及各种不同高可用等级相应的停机时间我就不必多说了,直接进入主题. 可选MySQL高可用方案 MySQL的各种高可用方案,大多是基于以下几种基础来部署的: 基于主从复制: 基于

优酷土豆资深工程师:MySQL高可用之MaxScale与MHA

讲师介绍 侯野优酷土豆资深数据库工程师  擅长Orale.MySQL故障诊断.性能调优,目前专注于MySQL的高可用技术. 曾任职于大连东软.清华紫光.触控科技等公司,服务过华夏银行.中国华能电力集团,担任OracleDBA.Oracle高级咨询顾问.    本次分享主要包括以下内容: 1.MySQL高可用方案 2.为什么选择MHA 3.读写分离方案的寻找以及为什么选择Maxscale 一.MySQL  Failover的方案 常见的Failover方案 MMM MMM缺点: Monitor节点

MySQL高可用在网易的最佳应用与实践

今天分享主要包括三方面内容:一是常见的MySQL高可用架构;二是分布式数据库高可用实践;三是基于keepalive的MySQL高可用改造.第一部分会介绍业界一些经典的MySQL高可用解决方案,第二部分和第三部分分别介绍网易在分布式数据库和单节点MySQL上的高可用运维实践. 一.常见的MySQL高可用架构 MySQL高可用主要涉及两个方面,一是客户端如何切换,如何自动failover,二是多个MySQL节点之间如何做数据同步.业界MySQL高可用的解决方案有很多,总结起来有几类:从客户端自动切换

秒级故障切换!用MHA轻松实现MySQL高可用(一)

作者介绍 郝朝阳,运维工程师,专注于运维自动化的实现.现就职于宜搜科技,负责前端运维工作.虽然多方面开花,却致力于形成自己运维体系思想.     1 MHA简介 MHA是由日本人youshimaton(原就职于DeNA,现就职于FaceBook)开发的比较成熟的MySQL高可用方案.MHA能够在30秒内实现故障切换,并能在故障切换中,最大可能的保证数据一致性.目前淘宝也正在开发相似产品TMHA,目前已支持一主一从.   2 MHA架构 MHA由MHA Manager和MHA Node组成.如下图

MySQL 高可用浅析

MySQL 高可用浅析 对于多数应用来说,MySQL都是作为最关键的数据存储中心的,所以,如何让MySQL提供HA服务,是我们不得不面对的一个问题.当master当机的时候,我们如何保证数据尽可能的不丢失,如何保证快速的获知master当机并进行相应的故障转移处理,都是需要我们好好思考的.这里,笔者将结合这段时间做的MySQL proxy以及toolsets相关工作,说说我们现阶段以及后续会在项目中采用的MySQL HA方案. (题图来自:comprendrechoisir.com) Repli