> 데이터 베이스 > MySQL 튜토리얼 > mysql-mmm集群(多实例)

mysql-mmm集群(多实例)

WBOY
풀어 주다: 2016-06-07 17:42:13
원래의
1220명이 탐색했습니다.

一、需求说明最近一直在学习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.conf active_master_role writer cluster_interface eth1 agent_port 9912 mysql_port 3307 pid_path /var/run/mysql-mmm/mmm_agentd_navy2.pid bin_path /usr/libexec/mysql-mmm/ replication_user slave replication_password 123456 agent_user mmm_agent agent_password 123456 ip 172.28.26.101 mysql_port 3307 mode master peer db2 ip 172.28.26.102 mysql_port 3307 mode master peer db1 hosts db1, db2 ips 172.28.26.107 mode exclusive hosts db1, db2 ips 172.28.26.108 mode balanced

vi /etc/mysql-mmm/mmm_common_navy3.conf(navy3的配置文件)

active_master_role writer cluster_interface eth1 agent_port 9913 mysql_port 3308 pid_path /var/run/mysql-mmm/mmm_agentd_navy3.pid bin_path /usr/libexec/mysql-mmm/ replication_user slave replication_password 123456 agent_user mmm_agent agent_password 123456 ip 172.28.26.101 mysql_port 3308 mode master peer db2 ip 172.28.26.102 mysql_port 3308 mode master peer db1 hosts db1, db2 ips 172.28.26.109 mode exclusive hosts db1, db2 ips 172.28.26.110 mode balanced

vi /etc/mysql-mmm/mmm_agent_navy2.conf(navy2的agent配置文件)

include mmm_common_navy2.conf this db1

vi /etc/mysql-mmm/mmm_agent_navy3.conf(navy3的agent配置文件)

include mmm_common_navy3.conf this 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' #----------------------------------------------------------------------- # Paths if [ "$CLUSTER" != "" ]; then MMMD_AGENT_BIN="/usr/sbin/mmm_agentd @$CLUSTER" MMMD_AGENT_PIDFILE="/var/run/mysql-mmm/mmm_agentd_$CLUSTER.pid" else MMMD_AGENT_BIN="/usr/sbin/mmm_agentd" MMMD_AGENT_PIDFILE="/var/run/mysql-mmm/mmm_agentd.pid" fi start() { if [ "${ENABLED}" != "1" ]; then echo "$prog is disabled!" exit 1 fi echo -n "Starting $prog: " if [ -s $MMMD_AGENT_PIDFILE ] && kill -0 `cat $MMMD_AGENT_PIDFILE` 2> /dev/null; then echo " already running." exit 0 fi daemon $MMMD_AGENT_BIN RETVAL=$? echo [ $RETVAL = 0 ] && touch $LOCKFILE return $RETVAL } stop() { # Stop daemon. echo -n "Stopping $prog: " killproc -p $MMMD_AGENT_PIDFILE $MMMD_AGENT_BIN RETVAL=$? echo [ $RETVAL = 0 ] && rm -f $LOCKFILE return $RETVAL } case "$1" in start) start ;; stop) stop ;; status) status -p $MMMD_AGENT_PIDFILE $MMMD_AGENT_BIN RETVAL=$? ;; restart|reload) stop start ;; condrestart) if [ -f $LOCKFILE ]; then stop start fi ;; *) echo "Usage: $0 {start|stop|restart|condrestart|status}" ;; esac exit $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' #----------------------------------------------------------------------- # Paths if [ "$CLUSTER" != "" ]; then MMMD_AGENT_BIN="/usr/sbin/mmm_agentd @$CLUSTER" MMMD_AGENT_PIDFILE="/var/run/mysql-mmm/mmm_agentd_$CLUSTER.pid" else MMMD_AGENT_BIN="/usr/sbin/mmm_agentd" MMMD_AGENT_PIDFILE="/var/run/mysql-mmm/mmm_agentd.pid" fi start() { if [ "${ENABLED}" != "1" ]; then echo "$prog is disabled!" exit 1 fi echo -n "Starting $prog: " if [ -s $MMMD_AGENT_PIDFILE ] && kill -0 `cat $MMMD_AGENT_PIDFILE` 2> /dev/null; then echo " already running." exit 0 fi daemon $MMMD_AGENT_BIN RETVAL=$? echo [ $RETVAL = 0 ] && touch $LOCKFILE return $RETVAL } stop() { # Stop daemon. echo -n "Stopping $prog: " killproc -p $MMMD_AGENT_PIDFILE $MMMD_AGENT_BIN RETVAL=$? echo [ $RETVAL = 0 ] && rm -f $LOCKFILE return $RETVAL } case "$1" in start) start ;; stop) stop ;; status) status -p $MMMD_AGENT_PIDFILE $MMMD_AGENT_BIN RETVAL=$? ;; restart|reload) stop start ;; condrestart) if [ -f $LOCKFILE ]; then stop start fi ;; *) echo "Usage: $0 {start|stop|restart|condrestart|status}" ;; esac exit $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上的文件到相应的目录下:

관련 라벨:
원천:php.cn
본 웹사이트의 성명
본 글의 내용은 네티즌들의 자발적인 기여로 작성되었으며, 저작권은 원저작자에게 있습니다. 본 사이트는 이에 상응하는 법적 책임을 지지 않습니다. 표절이나 침해가 의심되는 콘텐츠를 발견한 경우 admin@php.cn으로 문의하세요.
인기 튜토리얼
더>
최신 다운로드
더>
웹 효과
웹사이트 소스 코드
웹사이트 자료
프론트엔드 템플릿