I. Requirement Description I have been learning mysql-mmm recently. I think this architecture can be used in our company's business in the future. Our company's business is single-host, multi-instance deployment, therefore, I want to deploy mysql-mmm in this way.
I. Requirement Description I have been learning mysql-mmm recently. I think this architecture can be used in our company's business in the future. Our company's business is single-host, multi-instance deployment, therefore, I want to deploy mysql-mmm in this way.
Iii. Deployment
1. For the installation of mysql and mysql-mmm And the master-slave configuration of mysql, see the previous blog post: U.S. space, website space. here only the mmm multi-instance configuration is introduced.
2. db1:
Vi/etc/mysql-mmm/mmm_common_navy2.conf (navy2 configuration file)
Vi/etc/mysql-mmm/mmm_common_navy2.confactive_master_rolewriter Examples/var/run/mysql-mmm/mmm_agentd_navy2.pidbin_path/usr/libexec/mysql-mmm/replication_userslavereplication_password 123456agent_usermmm_agentagent_password123456 Ip172.28.26.101mysql _ port3307mode masterpeer db2 Ip172.28.26.102mysql _ port3307mode masterpeer db1 Hosts db1, db2ips172.28.26.mode mode exclusive Hosts db1, db2ips172.28.26.108mode balanced
Vi/etc/mysql-mmm/mmm_common_navy3.conf (configuration file of navy3)
Active_master_rolewriter Examples/var/run/mysql-mmm/mmm_agentd_navy3.pidbin_path/usr/libexec/mysql-mmm/replication_userslavereplication_password 123456agent_usermmm_agentagent_password123456 Ip172.28.26.101mysql _ port3308mode masterpeer db2 Ip172.28.26.102mysql _ port3308mode masterpeer db1 Hosts db1, db2ips172.28.26.mode mode exclusive Hosts db1, db2ips172.28.26.110mode balanced
Vi/etc/mysql-mmm/mmm_agent_navy2.conf (navy2 agent configuration file)
Include mmm_common_navy2.confthis db1
Vi/etc/mysql-mmm/mmm_agent_navy3.conf (the agent configuration file of navy3)
Include mmm_common_navy3.confthis db1
Vi/etc/init. d/mysql-mmm-agent-navy2 (navy2 agent Startup Script)
#! /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 = 'nav2' LOCKFILE = '/var/lock/subsys/mysql-mmm-agent_navy2' prog = 'mmm Agent daemon '#- ---------------------------------------------------------------------- # Pathsif ["$ CLUSTER "! = ""]; ThenMMMD_AGENT_BIN = "/usr/sbin/mmm_agentd @ $ CLUSTER" MMMD_AGENT_PIDFILE = "/var/run/mysql-mmm/mmm_agentd _ $ CLUSTER. pid "elseMMMD_AGENT_BIN ="/usr/sbin/mmm_agentd "MMMD_AGENT_PIDFILE ="/var/run/mysql-mmm/mmm_agentd.pid "fistart () {if [" $ {ENABLED }"! = "1"]; thenecho "$ prog is disabled! "Exit 1 fiecho-n" Starting $ prog: "if [-s $ MMMD_AGENT_PIDFILE] & kill-0 'cat $ MMMD_AGENT_PIDFILE '2>/dev/null; thenecho "already running. "exit 0 fidaemon $ 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
Grant execution permission:
Chmod + x/etc/init. d/mysql-mmm-agent-navy2
Vi/etc/init. d/mysql-mmm-agent-navy3 (agent Startup Script For navy3)
#! /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' # emerge # Pathsif ["$ CLUSTER "! = ""]; ThenMMMD_AGENT_BIN = "/usr/sbin/mmm_agentd @ $ CLUSTER" MMMD_AGENT_PIDFILE = "/var/run/mysql-mmm/mmm_agentd _ $ CLUSTER. pid "elseMMMD_AGENT_BIN ="/usr/sbin/mmm_agentd "MMMD_AGENT_PIDFILE ="/var/run/mysql-mmm/mmm_agentd.pid "fistart () {if [" $ {ENABLED }"! = "1"]; thenecho "$ prog is disabled! "Exit 1 fiecho-n" Starting $ prog: "if [-s $ MMMD_AGENT_PIDFILE] & kill-0 'cat $ MMMD_AGENT_PIDFILE '2>/dev/null; thenecho "already running. "exit 0 fidaemon $ 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
Grant executable permissions:
Chmod + x/etc/init. d/mysql-mmm-agent-navy3
Start the service:
/Etc/init. d/mysql-mmm-agent-navy2 start/etc/init. d/mysql-mmm-agent-navy3 start
3. db2:
Copy the files on db1 to the corresponding directory: