1 Active_master_role writer 2
vi/etc/mysql-mmm/mmm_agent_navy2.conf (Agent configuration file for navy2)
1 include Mmm_common_navy2.conf2 this DB1
vi/etc/mysql-mmm/mmm_agent_navy3.conf (Agent configuration file for navy3)
1 include Mmm_common_navy3.conf2 this DB1
Vi/etc/init.d/mysql-mmm-agent-navy2 (navy2 agent startup script)
1 #!/bin/sh 2 # Chkconfig:-3 # description:mmm Agent. 4 # processname:mmm_agentd 5 # Config:/etc/mysql-mmm/mmm_agent.conf 6 # Pidfile:/var/run/mysql-mmm/mmm_agentd.pid 7 # S Ource function library and defaults file. 8. /etc/rc.d/init.d/functions 9. /etc/default/mysql-mmm-agent10 # Cluster Name (it can be empty for default cases) one cluster= ' navy2 ' lockfile= '/var/lock/ Subsys/mysql-mmm-agent_navy2 ' prog= ' mmm Agent Daemon ' #------------------------------------------------------- ----------------# PATHS16 If ["$CLUSTER"! = ""]; Then17 mmmd_agent_bin= "/usr/sbin/mmm_agentd @ $CLUSTER" mmmd_agent_pidfile= "/var/run/mysql-mmm/mmm_agentd_$ Cluster.pid "Else20 mmmd_agent_bin="/usr/sbin/mmm_agentd "mmmd_agent_pidfile=/var/run/mysql-mmm/mmm_" Agentd.pid "fi23 start () {if [" ${enabled} "! =" 1 "]; Then25 echo" $prog is disabled! " + Exit 127 fi28 echo-n "Starting $prog:" If [-S $MMMD _agent_pidfile] && kill-0 ' cat $MMMD _agent_pidfile ' 2 >/dev/null; Thenecho "already running." Exit 032 fi33 Daemon $MMMD _agent_bin34 retval=$?35 echo36 [$RETVAL = 0] && touch $LOCKFILE Notoginseng return $RETVAL 38 }39 Stop () {daemon.41 # stop Echo-n "stopping $prog:" Killproc-p $MMMD _agent_pidfile $MMMD _agent_bin43 retval=$?4 4 echo45 [$RETVAL = 0] && rm-f $LOCKFILE return $RETVAL}48 case "$" in49 start) start51; -stop)-stop54;; (status) status-p $MMMD _agent_pidfile $MMMD _agent_bin57 retval=$?58; restart|reload) stop61 start62; Condrestart) If [-F $LOCKFILE]; Then65 stop66 start67 fi68; *) echo "Usage: $ start|stop|restart|condrestart|status}" 71;; Esac73 Exit $RETVAL
Give Execute permission:
1 chmod +x/etc/init.d/mysql-mmm-agent-navy2
Vi/etc/init.d/mysql-mmm-agent-navy3 (navy3 agent startup script)
1 #!/bin/sh 2 # Chkconfig:-3 # description:mmm Agent. 4 # processname:mmm_agentd 5 # Config:/etc/mysql-mmm/mmm_agent.conf 6 # Pidfile:/var/run/mysql-mmm/mmm_agentd.pid 7 # S Ource function library and defaults file. 8. /etc/rc.d/init.d/functions 9. /etc/default/mysql-mmm-agent10 # # Paths11 #MMMD_AGENT_BIN = "/usr/sbin/mmm_agentd" #MMMD_AGENT_PIDFILE = "/var/run/ Mysql-mmm/mmm_agentd.pid "#LOCKFILE = '/var/lock/subsys/mysql-mmm-agent ' #prog = ' mmm agent Daemon ' # Cluster name ( It can be empty for default cases) cluster= ' navy3 ' lockfile= '/var/lock/subsys/mysql-mmm-agent_navy3 ' prog= ' mmm Agent Daemon ' #-----------------------------------------------------------------------# PATHS21 if ["$CLUSTER"! = "" ]; Then22 mmmd_agent_bin= "/usr/sbin/mmm_agentd @ $CLUSTER" mmmd_agent_pidfile= "/var/run/mysql-mmm/mmm_agentd_$ Cluster.pid "Else25 mmmd_agent_bin="/usr/sbin/mmm_agentd "mmmd_agent_pidfile=/var/run/mysql-mmm/mmm_" Agentd.pid "fi28 start () {if [" ${enabled} "! = "1"]; Then30 echo "$prog is disabled!" To exit Fi33 echo-n "starting $prog:" If [-S $MMMD _agent_pidfile] && kill-0 ' cat $MMMD _agent_pidfile ' 2 >/dev/null; Then35 echo "already running." 037 fi38 daemon $MMMD _agent_bin39 retval=$?40 echo41 [$RETVAL = 0] && Touch $LOCKFILE return $RETVAL 43 }44 Stop () {daemon.46 # echo-n "Stopping $prog:" Killproc-p $MMMD _agent_pidfile $MMMD _agent_bin48 retval=$?4 9 echo50 [$RETVAL = 0] && rm-f $LOCKFILE return $RETVAL}53 case "$" in54 start) start56; (stop59); (status) status-p $MMMD _agent_pidfile $MMMD _agent_bin62 retval=$?63; restart|reload) stop66 start67; Condrestart) If [-F $LOCKFILE]; Then70 stop71 start72 fi73; *) echo "Usage: $ start|stop|restart|condrestart|status}" 76;; ESAC78 Exit $RETVAL
Give executable permission:
1 chmod +x/etc/init.d/mysql-mmm-agent-navy3
Start the service:
1/etc/init.d/mysql-mmm-agent-navy2 start2/etc/init.d/mysql-mmm-agent-navy3 Start
3, DB2: Copy the files on the DB1 to the corresponding directory:1 scp/etc/mysql-mmm/mmm_common_navy2.conf 172.28.26.102:/etc/mysql-mmm/2 scp/etc/mysql-mmm/mmm_common_navy3.conf 172.28.26.102:/ETC/MYSQL-MMM/3 scp/etc/mysql-mmm/mmm_agent_navy2.conf 172.28.26.102:/ETC/MYSQL-MMM/4 scp/etc/ mysql-mmm/mmm_agent_navy3.conf 172.28.26.102:/ETC/MYSQL-MMM/5 scp/etc/init.d/mysql-mmm-agent-navy2 172.28.26.102 :/ETC/INIT.D/6 scp/etc/init.d/mysql-mmm-agent-navy3 172.28.26.102:/etc/init.d/
To modify the agent configuration file:
1 sed-i ' s/this db1/this db2/'/etc/mysql-mmm/mmm_agent_navy2.conf2 sed-i ' s/this db1/this db2/'/etc/mysql-mmm/mmm_agen T_navy3.conf
Give executable permission
1 chmod +x/etc/init.d/mysql-mmm-agent-navy22 chmod +x/etc/init.d/mysql-mmm-agent-navy3
Start the service:
1/etc/init.d/mysql-mmm-agent-navy2 start2/etc/init.d/mysql-mmm-agent-navy3 Start
4. On monitor, copy the configuration file on DB1:1 scp/etc/mysql-mmm/mmm_common_navy2.conf 172.28.26.103:/etc/mysql-mmm/2 scp/etc/mysql-mmm/mmm_common_navy3.conf 172.28.26.103:/etc/mysql-mmm/
Vi/etc/mysql-mmm/mmm_mon_navy2.conf
1 include mmm_common_navy2.conf 2 <monitor> 3 IP 127.0.0.1 4 port 9992 5 Pid_path /var/run/mysql-mmm/ Mmm_mond_navy2.pid 6 Bin_path /usr/libexec/mysql-mmm 7 status_path /var/lib/mysql-mmm/mmm_mond_ Navy2.status 8 ping_ips 172.28.26.101,172.28.26.102 9 auto_set_online 1010 # wait_for_other_master 211 # The Kill_host_bin does not exist by default, though the monitor will12 # to throw a warning about it missing. See the sections 5.10 "Kill Host13 # Functionality" in the PDF documentation.14 #15 # kill_host_bin /usr/libexec/mysql- Mmm/monitor/kill_host16 #17 </monitor>18
Vi/etc/mysql-mmm/mmm_mon_navy3.conf
1 include mmm_common_navy3.conf 2 <monitor> 3 IP 127.0.0.1 4 port 9993 5 Pid_path /var/run/mysql-mmm/ Mmm_mond_navy3.pid 6 Bin_path /usr/libexec/mysql-mmm 7 status_path /var/lib/mysql-mmm/mmm_mond_ Navy3.status 8 ping_ips 172.28.26.101,172.28.26.102 9 auto_set_online 1010 # wait_for_other_master 211 # The Kill_host_bin does not exist by default, though the monitor will12 # to throw a warning about it missing. See the sections 5.10 "Kill Host13 # Functionality" in the PDF documentation.14 #15 # kill_host_bin /usr/libexec/mysql- Mmm/monitor/kill_host16 #17 </monitor>18
Vi/etc/mysql-mmm/mmm_mon_log_navy2.conf
1 #log4perl. Logger = FATAL, Mmmlog, mailfatal 2 Log4perl.logger = FATAL, mmmlog 3 Log4perl.appender.MMMLog = Log::log4perl :: appender::file 4 log4perl.appender.MMMLog.Threshold = INFO 5 Log4perl.appender.MMMLog.filename =/var/log/mysql-mmm/ Mmm_mond_navy2.log 6 log4perl.appender.MMMLog.recreate = 1 7 log4perl.appender.MMMLog.layout = Patternlayout 8 Log4perl.appender.MMMLog.layout.ConversionPattern =%d%5p%m%n 9 #log4perl. appender.mailfatal = Log::D ispatch::email: : MailSender10 #log4perl. appender.MailFatal.Threshold = FATAL11 #log4perl. appender.MailFatal.from = [email protected] #log4perl. appender.MailFatal.to = root13 #log4perl. appender.MailFatal.buffered = 014 # Log4perl.appender.MailFatal.subject = FATAL Error in Mysql-mmm-monitor15 #log4perl. Appender.MailFatal.layout = PatternLayout16 #log4perl. Appender.MailFatal.layout.ConversionPattern =%d%m%n
Vi/etc/mysql-mmm/mmm_mon_log_navy3.conf
1 #log4perl. Logger = FATAL, Mmmlog, mailfatal 2 Log4perl.logger = FATAL, mmmlog 3 Log4perl.appender.MMMLog = Log::log4perl :: appender::file 4 log4perl.appender.MMMLog.Threshold = INFO 5 Log4perl.appender.MMMLog.filename =/var/log/mysql-mmm/ Mmm_mond_navy3.log 6 log4perl.appender.MMMLog.recreate = 1 7 log4perl.appender.MMMLog.layout = Patternlayout 8 Log4perl.appender.MMMLog.layout.ConversionPattern =%d%5p%m%n 9 #log4perl. appender.mailfatal = Log::D ispatch::email: : MailSender10 #log4perl. appender.MailFatal.Threshold = FATAL11 #log4perl. appender.MailFatal.from = [email protected] #log4perl. appender.MailFatal.to = root13 #log4perl. appender.MailFatal.buffered = 014 # Log4perl.appender.MailFatal.subject = FATAL Error in Mysql-mmm-monitor15 #log4perl. Appender.MailFatal.layout = PatternLayout16 #log4perl. Appender.MailFatal.layout.ConversionPattern =%d%m%n
Vi/etc/init.d/mysql-mmm-monitor-navy2
1 #!/bin/sh 2 # 3 # Mysql-mmm-monitor This shell script takes care of starting and stopping 4 # the M MM Monitoring daemon. 5 # 6 # Chkconfig:-7 # Description:mmm Monitor. 8 # Processname:mmm_mond 9 # config:/etc/mysql-mmm/mmm_mon.conf10 # pidfile:/var/run/mysql-mmm/mmm_mond.pid11 # Source function library and Defaults file.12. /etc/rc.d/init.d/functions13. /etc/default/mysql-mmm-monitor14 # Cluster Name (it can be empty for default cases) cluster= ' navy2 ' lockfile= '/var/loc K/subsys/mysql-mmm-monitor_navy2 ' prog= ' mmm monitor Daemon ' if ["$CLUSTER"! = ""]; Then19 mmmd_mon_bin= "/usr/sbin/mmm_mond @ $CLUSTER" mmmd_mon_pidfile= "/var/run/mysql-mmm/mmm_mond-$CLUSTER. pid" Else22 mmmd_mon_bin= "/usr/sbin/mmm_mond" mmmd_mon_pidfile= "/var/run/mysql-mmm/mmm_mond.pid" fi25 start () {26 if ["${enabled}"! = "1"]; Then27 echo "$prog is disabled!" 129 fi30 Echo-n "Starting $prog:" If [-S $MMMD _mon_pidfile] && kill-0 ' Cat $MMMD _moN_pidfile ' 2>/dev/null; Then32 echo "already running." 034 fi35 daemon $MMMD _mon_bin36 retval=$?37 echo38 [$RETVAL = 0] && Touch $LOCKFILE return $RETVAL 40} $ stop () {# stop daemon.43 echo-n "stopping $prog:" Killproc-p $MMMD _mon_pidfile $MMMD _mon_bin45 retval=$?46 Echo [$RETVAL = 0] && rm-f $LOCKFILE return $RETVAL}50 case "$" in51 start) start53 Stop) stop56; Status-p $MMMD _mon_pidfile $MMMD _mon_bin59 retval=$?60; restart|reload) stop63 Start64; Condrestart) If [-F $LOCKFILE]; then67 stop68 start69 fi70; *) echo "Usage: $ start|stop|restart|condrestart|status}" 73;; Esac75 Exit $RETVAL
Vi/etc/init.d/mysql-mmm-monitor-navy3
1 #!/bin/sh 2 # 3 # Mysql-mmm-monitor This shell script takes care of starting and stopping 4 # the M MM Monitoring daemon. 5 # 6 # Chkconfig:-7 # Description:mmm Monitor. 8 # Processname:mmm_mond 9 # config:/etc/mysql-mmm/mmm_mon.conf10 # pidfile:/var/run/mysql-mmm/mmm_mond.pid11 # Source function library and Defaults file.12. /etc/rc.d/init.d/functions13. /etc/default/mysql-mmm-monitor14 # Cluster Name (it can be empty for default cases) cluster= ' navy3 ' lockfile= '/var/loc K/subsys/mysql-mmm-monitor_navy3 ' prog= ' mmm monitor Daemon ' if ["$CLUSTER"! = ""]; Then19 mmmd_mon_bin= "/usr/sbin/mmm_mond @ $CLUSTER" mmmd_mon_pidfile= "/var/run/mysql-mmm/mmm_mond-$CLUSTER. pid" Else22 mmmd_mon_bin= "/usr/sbin/mmm_mond" mmmd_mon_pidfile= "/var/run/mysql-mmm/mmm_mond.pid" fi25 start () {26 if ["${enabled}"! = "1"]; Then27 echo "$prog is disabled!" 129 fi30 Echo-n "Starting $prog:" If [-S $MMMD _mon_pidfile] && kill-0 ' Cat $MMMD _moN_pidfile ' 2>/dev/null; Then32 echo "already running." 034 fi35 daemon $MMMD _mon_bin36 retval=$?37 echo38 [$RETVAL = 0] && Touch $LOCKFILE return $RETVAL 40} $ stop () {# stop daemon.43 echo-n "stopping $prog:" Killproc-p $MMMD _mon_pidfile $MMMD _mon_bin45 retval=$?46 Echo [$RETVAL = 0] && rm-f $LOCKFILE return $RETVAL}50 case "$" in51 start) start53 Stop) stop56; Status-p $MMMD _mon_pidfile $MMMD _mon_bin59 retval=$?60; restart|reload) stop63 Start64; Condrestart) If [-F $LOCKFILE]; then67 stop68 start69 fi70; *) echo "Usage: $ start|stop|restart|condrestart|status}" 73;; Esac75 Exit $RETVAL
Give executable permission:
1 chmod +x/etc/init.d/mysql-mmm-monitor-navy22 chmod +x/etc/init.d/mysql-mmm-monitor-navy3
To start the monitoring service:
/etc/init.d/mysql-mmm-monitor-navy2 start/etc/init.d/mysql-mmm-monitor-navy3 Start
Results
1 [[Email protected] ~]# Mmm_control show 2 db1 (172.28.26.101) master/online. Roles:writer (172.28.26.104) 3 DB2 (172.28.26.102) master/online. Roles:4 db3 (172.28.26.188) slave/online. Roles:reader (172.28.26.105) 5 DB4 (172.28.26.189) slave/online. Roles:reader (172.28.26.106) 6 [[email protected] ~]# Mmm_control @navy2 Show 7 db1 (172.28.26.101) master/online. Roles:writer (172.28.26.107) 8 DB2 (172.28.26.102) master/online. Roles:reader (172.28.26.108) 9 [[email protected] ~]# Mmm_control @navy3 show10 db1 (172.28.26.101) master/online. Roles:writer (172.28.26.109) DB2 (172.28.26.102) master/online. Roles:reader (172.28.26.110) [[email protected] ~]#
[Go] (Multi-instance) Mysql-mmm cluster