一、需求说明最近一直在学习mysql-mmm,想以后这个架构也能用在我们公司的业务上,我们公司的业务是单机多实例部署,所以也想把mysql-mmm部署成这样,功夫不负有
三、部署
1、mysql和mysql-mmm的安装及mysql的主从配置请查看前面的博文:,美国空间,网站空间,这里只介绍mmm多实例配置。
2、db1上:
vi /etc/mysql-mmm/mmm_common_navy2.conf(navy2的配置文件)
vi /etc/mysql-mmm/mmm_common_navy2.confactive_master_rolewritercluster_interfaceeth1agent_port9912mysql_port3307pid_path/var/run/mysql-mmm/mmm_agentd_navy2.pidbin_path/usr/libexec/mysql-mmm/replication_userslavereplication_password 123456agent_usermmm_agentagent_password123456ip172.28.26.101mysql_port3307mode masterpeer db2ip172.28.26.102mysql_port3307mode masterpeer db1hosts db1, db2ips172.28.26.107mode exclusivehosts db1, db2ips172.28.26.108mode balanced
vi /etc/mysql-mmm/mmm_common_navy3.conf(navy3的配置文件)
active_master_rolewritercluster_interfaceeth1agent_port9913mysql_port3308pid_path/var/run/mysql-mmm/mmm_agentd_navy3.pidbin_path/usr/libexec/mysql-mmm/replication_userslavereplication_password 123456agent_usermmm_agentagent_password123456ip172.28.26.101mysql_port3308mode masterpeer db2ip172.28.26.102mysql_port3308mode masterpeer db1hosts db1, db2ips172.28.26.109mode exclusivehosts db1, db2ips172.28.26.110mode balanced
vi /etc/mysql-mmm/mmm_agent_navy2.conf(navy2的agent配置文件)
include mmm_common_navy2.confthis db1
vi /etc/mysql-mmm/mmm_agent_navy3.conf(navy3的agent配置文件)
include mmm_common_navy3.confthis db1
vi /etc/init.d/mysql-mmm-agent-navy2(navy2的agent启动脚本)
#!/bin/sh# chkconfig: - 64 36# description: mmm agent.# processname: mmm_agentd# config: /etc/mysql-mmm/mmm_agent.conf# pidfile: /var/run/mysql-mmm/mmm_agentd.pid# source function library and defaults file.. /etc/rc.d/init.d/functions. /etc/default/mysql-mmm-agent# cluster name (it can be empty for default cases)cluster='navy2'lockfile='/var/lock/subsys/mysql-mmm-agent_navy2'prog='mmm agent daemon'#-----------------------------------------------------------------------# pathsif [ $cluster != ]; thenmmmd_agent_bin=/usr/sbin/mmm_agentd @$clustermmmd_agent_pidfile=/var/run/mysql-mmm/mmm_agentd_$cluster.pidelsemmmd_agent_bin=/usr/sbin/mmm_agentdmmmd_agent_pidfile=/var/run/mysql-mmm/mmm_agentd.pidfistart() {if [ ${enabled} != 1 ]; thenecho $prog is disabled!exit 1fiecho -n starting $prog: if [ -s $mmmd_agent_pidfile ] && kill -0 `cat $mmmd_agent_pidfile` 2> /dev/null; thenecho already running.exit 0fidaemon $mmmd_agent_binretval=$?echo[ $retval = 0 ] && touch $lockfilereturn $retval}stop() {# stop daemon.echo -n stopping $prog: killproc -p $mmmd_agent_pidfile $mmmd_agent_binretval=$?echo[ $retval = 0 ] && rm -f $lockfilereturn $retval}case $1 instart)start;;stop)stop;;status)status -p $mmmd_agent_pidfile $mmmd_agent_binretval=$?;;restart|reload)stopstart;;condrestart)if [ -f $lockfile ]; thenstopstartfi;;*)echo usage: $0 {start|stop|restart|condrestart|status};;esacexit $retval
赋予执行权限:
chmod +x /etc/init.d/mysql-mmm-agent-navy2
vi /etc/init.d/mysql-mmm-agent-navy3(navy3的agent启动脚本)
#!/bin/sh# chkconfig: - 64 36# description: mmm agent.# processname: mmm_agentd# config: /etc/mysql-mmm/mmm_agent.conf# pidfile: /var/run/mysql-mmm/mmm_agentd.pid# source function library and defaults file.. /etc/rc.d/init.d/functions. /etc/default/mysql-mmm-agent## paths#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'#-----------------------------------------------------------------------# pathsif [ $cluster != ]; thenmmmd_agent_bin=/usr/sbin/mmm_agentd @$clustermmmd_agent_pidfile=/var/run/mysql-mmm/mmm_agentd_$cluster.pidelsemmmd_agent_bin=/usr/sbin/mmm_agentdmmmd_agent_pidfile=/var/run/mysql-mmm/mmm_agentd.pidfistart() {if [ ${enabled} != 1 ]; thenecho $prog is disabled!exit 1fiecho -n starting $prog: if [ -s $mmmd_agent_pidfile ] && kill -0 `cat $mmmd_agent_pidfile` 2> /dev/null; thenecho already running.exit 0fidaemon $mmmd_agent_binretval=$?echo[ $retval = 0 ] && touch $lockfilereturn $retval}stop() {# stop daemon.echo -n stopping $prog: killproc -p $mmmd_agent_pidfile $mmmd_agent_binretval=$?echo[ $retval = 0 ] && rm -f $lockfilereturn $retval}case $1 instart)start;;stop)stop;;status)status -p $mmmd_agent_pidfile $mmmd_agent_binretval=$?;;restart|reload)stopstart;;condrestart)if [ -f $lockfile ]; thenstopstartfi;;*)echo usage: $0 {start|stop|restart|condrestart|status};;esacexit $retval
赋予可执行权限:
chmod +x /etc/init.d/mysql-mmm-agent-navy3
启动服务:
/etc/init.d/mysql-mmm-agent-navy2 start/etc/init.d/mysql-mmm-agent-navy3 start
3、db2上:
复制db1上的文件到相应的目录下: