1 Install MySQL
Please refer to 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 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::D iff Class::singleton DBI dbd::mysql Log::D ispatch log::log4perl mail::send Net::P ing Proc::D aemon Tim E::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>
Monitor_user Mmm_monitor
Monitor_password Mmm_monitor
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 to 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
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::D aemon
[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
One. 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/l Ib64/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::D aemon
[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
Check fail
[Root@oracle mysql-mmm]# Ping 10.88.49.130
PING 10.88.49.130 (10.88.49.130) 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
Add debug 1 to agent.conf and monitor.conf, respectively.
Then look at the output log
[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, can, wait some, and check its new roles!
[root@localhost mysql-mmm]# mmm_control set_online DB2
Ok:state of ' DB2 ' changed to online. Now, can, wait some, and check its new roles!
[root@localhost mysql-mmm]# mmm_control set_online db3
ok:state of ' db3 ' changed to online. Now, can, wait some, 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) bytes of data.
Bytes from 10.88.49.134:icmp_seq=3 ttl=64 time=0.265 ms
Bytes from 10.88.49.134:icmp_seq=6 ttl=64 time=0.699 ms
Bytes from 10.88.49.134:icmp_seq=9 ttl=64 time=0.482 ms
Bytes from 10.88.49.134:icmp_seq=12 ttl=64 time=0.405 ms
Bytes from 10.88.49.134:icmp_seq=15 ttl=64 time=0.430 ms
Check All
[root@localhost ~]# Mmm_control checks
DB2 ping [last Change:2013/02/19 12:41:45] OK
DB2 my SQL [last Change:2013/02/19 12:41:45] OK
DB2 rep_threads [last CHANGE:2013/02/19 12:41:45] OK
DB2 Rep_backlog [las T 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 ch ANGE:2013/02/19 12:41:45] OK
db3 rep_threads [last Change:2013/02/19 12:41:45] OK
db3 rep_backlog [Last Change:20 13/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/0 2/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
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, click Master_host is ' 10.88.49.118 '
[root@oracle ~]# service mysqld56 stopshutting 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 Ho St ' 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 orpha Ned 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'll change its master_host
[roo T@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, while 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 on 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, can, wait some, 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_c Ontrol 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)
to 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)
DB2 are awaiting_recovery, so need set online
[Root@localhost mysql-mmm]# Mmm_control set_online DB2
Ok:state of ' DB2 ' changed to ONLINE. Now, can, wait some, 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)
DB2 is online
15.5 Change writer to DB2
Mmm_control Move_role writer DB2
Related articles:
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