1. 程式人生 > >MYSQL MMM部署實錄

MYSQL MMM部署實錄

star role 關系 mman too yum line rop rgb

king01與king02互為主從關系,king03作為king01的slave


king01,king02,king03安裝mmm_agent


[root@king01 ~]# cd /usr/local/src

[root@king01 src]# rpm -ivh epel-release-6-8.noarch.rpm

[root@king01 ~]# yum -y install mysql-mmm-agent

[root@king01 ~]# rpm -qa | grep mysql-mmm-agent

mysql-mmm-agent-2.2.1-2.el6.noarch


[root@king02 ~]# cd /usr/local/src

[root@king02 src]# rpm -ivh epel-release-6-8.noarch.rpm

[root@king02 ~]# yum -y install mysql-mmm-agent

[root@king02 ~]# rpm -qa | grep mysql-mmm-agent

mysql-mmm-agent-2.2.1-2.el6.noarch


[root@king03 ~]# cd /usr/local/src

[root@king03 src]# rpm -ivh epel-release-6-8.noarch.rpm

[root@king03 ~]# yum -y install mysql-mmm-agent

[root@king03 ~]# rpm -qa | grep mysql-mmm-agent

mysql-mmm-agent-2.2.1-2.el6.noarch


[root@king01 ~]# mysql -uroot -pabcd.1234

mysql> grant replication client on *.* to 'mmm_monitor'@'%' identified by 'mmm_monitor';

mysql> grant super,replication client,process on *.* to 'mmm_agent'@'%' identified by 'mmm_agent';


[root@king01 ~]# cd /etc/mysql-mmm/

[root@king01 mysql-mmm]# vi mmm_common.conf

active_master_role writer


<host default>

cluster_interface eth0

pid_path /var/run/mysql-mmm/mmm_agentd.pid

bin_path /usr/libexec/mysql-mmm/

replication_user repl

replication_password repl

agent_user mmm_agent

agent_password mmm_agent

</host>


<host db1>

ip 192.168.1.201

mode master

peer db2

</host>


<host db2>

ip 192.168.1.202

mode master

peer db1

</host>


<host db3>

ip 192.168.1.203

mode slave

</host>


<role writer>

hosts db1, db2

ips 192.168.1.200

mode exclusive

</role>


<role reader>

hosts db1, db2, db3

ips 192.168.1.201,192.168.1.202,192.168.1.203

mode balanced

</role>


[root@king01 mysql-mmm]# scp mmm_common.conf [email protected]:/etc/mysql-mmm/

[root@king01 mysql-mmm]# scp mmm_common.conf [email protected]:/etc/mysql-mmm/


[root@king01 mysql-mmm]# vi mmm_agent.conf

include mmm_common.conf

# The 'this' variable refers to this server. Proper operation requires

# that 'this' server (db1 by default), as well as all other servers, have the

# proper IP addresses set in mmm_common.conf.

this db1


[root@king01 ~]# cd /etc/default/

[root@king01 default]# vi mysql-mmm-agent

# mysql-mmm-agent defaults

ENABLED=1


[root@king01 ~]# cd /etc/init.d

[root@king01 init.d]# ./mysql-mmm-agent start

[root@king01 init.d]# ./mysql-mmm-agent status

mmm_agentd (pid 2915) is running...


[root@king02 ~]# cd /etc/mysql-mmm/

[root@king02 mysql-mmm]# vi mmm_agent.conf

include mmm_common.conf

# The 'this' variable refers to this server. Proper operation requires

# that 'this' server (db1 by default), as well as all other servers, have the

# proper IP addresses set in mmm_common.conf.

this db2


[root@king02 ~]# cd /etc/default/

[root@king02 default]# vi mysql-mmm-agent

# mysql-mmm-agent defaults

ENABLED=1


[root@king02 ~]# cd /etc/init.d

[root@king02 init.d]# ./mysql-mmm-agent start

[root@king02 init.d]# ./mysql-mmm-agent status

mmm_agentd (pid 3907) is running...


[root@king03 ~]# cd /etc/mysql-mmm/

[root@king03 mysql-mmm]# vi mmm_agent.conf

include mmm_common.conf

# The 'this' variable refers to this server. Proper operation requires

# that 'this' server (db1 by default), as well as all other servers, have the

# proper IP addresses set in mmm_common.conf.

this db3


[root@king03 ~]# cd /etc/default/

[root@king03 default]# vi mysql-mmm-agent

# mysql-mmm-agent defaults

ENABLED=1


[root@king03 ~]# cd /etc/init.d

[root@king03 init.d]# ./mysql-mmm-agent start

[root@king03 init.d]# ./mysql-mmm-agent status

mmm_agentd (pid 2176) is running...


king04安裝mmm_monitor


[root@king04 ~]# cd /usr/local/src

[root@king04 src]# rpm -ivh epel-release-6-8.noarch.rpm

[root@king04 src]# yum -y install mysql-mmm*

[root@king04 src]# rpm -qa | grep mysql-mmm

mysql-mmm-tools-2.2.1-2.el6.noarch

mysql-mmm-agent-2.2.1-2.el6.noarch

mysql-mmm-monitor-2.2.1-2.el6.noarch

mysql-mmm-2.2.1-2.el6.noarch


[root@king01 ~]# cd /etc/mysql-mmm/

[root@king01 mysql-mmm]# scp mmm_common.conf [email protected]:/etc/mysql-mmm/


[root@king04 mysql-mmm]# vi mmm_mon.conf

include mmm_common.conf


<monitor>

ip 127.0.0.1

pid_path /var/run/mysql-mmm/mmm_mond.pid

bin_path /usr/libexec/mysql-mmm

status_path /var/lib/mysql-mmm/mmm_mond.status

ping_ips 192.168.1.1,192.168.1201,192.168.1.202,192.168.1.203

auto_set_online 10


# The kill_host_bin does not exist by default, though the monitor will

# throw a warning about it missing. See the section 5.10 "Kill Host

# Functionality" in the PDF documentation.

#

# kill_host_bin /usr/libexec/mysql-mmm/monitor/kill_host

#

</monitor>


<host default>

monitor_user mmm_monitor

monitor_password mmm_monitor

</host>


debug 0


[root@king04 ~]# cd /etc/init.d/

[root@king04 init.d]# ./mysql-mmm-monitor start

[root@king04 init.d]# ./mysql-mmm-monitor status

mmm_mond (pid 1175) is running...


[root@king04 ~]# mmm_control help

Valid commands are:

help - show this message

ping - ping monitor

show - show status

checks [<host>|all [<check>|all]] - show checks status

set_online <host> - set host <host> online

set_offline <host> - set host <host> offline

mode - print current mode.

set_active - switch into active mode.

set_manual - switch into manual mode.

set_passive - switch into passive mode.

move_role [--force] <role> <host> - move exclusive role <role> to host <host>

(Only use --force if you know what you are doing!)

set_ip <ip> <host> - set role with ip <ip> to host <host>


[root@king04 ~]# mmm_control mode

ACTIVE


[root@king04 ~]# mmm_control show

db1(192.168.1.201) master/ONLINE. Roles: reader(192.168.1.201), writer(192.168.1.200)

db2(192.168.1.202) master/ONLINE. Roles: reader(192.168.1.202)

db3(192.168.1.203) slave/ONLINE. Roles: reader(192.168.1.203)


[root@king04 ~]# mmm_control checks all

db2 ping [last change: 2018/02/11 06:10:13] OK

db2 mysql [last change: 2018/02/11 06:10:13] OK

db2 rep_threads [last change: 2018/02/11 06:10:13] OK

db2 rep_backlog [last change: 2018/02/11 06:10:13] OK: Backlog is null

db3 ping [last change: 2018/02/11 06:10:13] OK

db3 mysql [last change: 2018/02/11 06:10:13] OK

db3 rep_threads [last change: 2018/02/11 06:10:13] OK

db3 rep_backlog [last change: 2018/02/11 06:10:13] OK: Backlog is null

db1 ping [last change: 2018/02/11 06:10:13] OK

db1 mysql [last change: 2018/02/11 06:10:13] OK

db1 rep_threads [last change: 2018/02/11 06:15:39] OK

db1 rep_backlog [last change: 2018/02/11 06:15:27] OK: Backlog is null










MYSQL MMM部署實錄