10.10.10.20:监控端

10.10.10.21:主

10.10.10.22:主

10.10.10.23:从

10.10.10.24:从

yum -y install mysql mysql-server

service mysqld start

yum -y install mysql-mmm*

useradd --comment "MMM Script owner" --shell /sbin/nologin mmmd

yum -y install perl-Time-HiRes*


GRANT REPLICATION CLIENT ON *.* TO 'mmm_monitor'@'10.10.10.%' IDENTIFIED BY 'monitor_password';

GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO 'mmm_agent'@'10.10.10.%'   IDENTIFIED BY 'agent_password';

GRANT REPLICATION SLAVE ON *.* TO 'replication'@'10.10.10.%' IDENTIFIED BY 'replication_password';



CHANGE MASTER TO master_host='10.10.10.21', master_port=3306, master_user='replication',master_password='replication_password', master_log_file='mysql-bin.000001', master_log_pos=98;

 

CHANGE MASTER TO master_host = '10.10.10.22', master_port=3306, master_user='replication',master_password='replication_password', master_log_file='mysql-bin.000001', master_log_pos=1146;


[root@node4 ~]# egrep -v "^#|^$" /etc/mysql-mmm/mmm_common.conf 

active_master_role          writer

<host default>

    cluster_interface       eth0

    pid_path                /var/run/mmmd_agent.pid

    bin_path                /usr/lib/mysql-mmm/

    replication_user        replication

    replication_password    replication_password

    agent_user              mmm_agent

    agent_password          agent_password

</host>

<host db1>

    ip                      10.10.10.21

    mode                    master

    peer                    db2

</host>

<host db2>

    ip                      10.10.10.22

    mode                    master

    peer                    db1

</host>

<host db3>

    ip                      10.10.10.23

    mode                    slave

</host>

<host db4>

    ip                      10.10.10.24

    mode                    slave

</host>

<role writer>

    hosts                   db1, db2

    ips                     10.10.10.100

    mode                    exclusive

</role>

<role reader>

    hosts                   db1, db2, db3, db4

    ips                     10.10.10.101,10.10.10.102

    mode                    balanced

</role>

[root@node4 ~]# 

[root@node4 ~]# egrep -v "^#|^$" /etc/mysql-mmm/mmm_agent.conf 

include mmm_common.conf

this db4


[root@localhost ~]# egrep -v "^#|^$|^\s+#" /etc/mysql-mmm/mmm_mon.conf 

include mmm_common.conf  

  

<monitor>  

    ip                  10.10.10.20  

    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            10.10.10.1,10.10.10.21,10.10.10.22,10.10.10.22,10.10.10.23,10.10.10.24 

    auto_set_online     60  

  

</monitor>  

  

<host default>  

    monitor_user        mmm_monitor  

    monitor_password    monitor_password  

</host>  

  

debug 0  

[root@localhost ~]# 


[root@localhost ~]# mmm_control show

  db1(10.10.10.21) master/ONLINE. Roles: 

  db2(10.10.10.22) master/ONLINE. Roles: writer(10.10.10.100)

  db3(10.10.10.23) slave/ONLINE. Roles: reader(10.10.10.101)

  db4(10.10.10.24) slave/ONLINE. Roles: reader(10.10.10.102)


[root@localhost ~]# 


[root@node4 ~]# egrep -v "^#|^$" /etc/my.cnf 

[mysqld]

datadir=/var/lib/mysql

socket=/var/lib/mysql/mysql.sock

user=mysql

server_id           = 4

log_bin             = /var/log/mysql/mysql-bin.log 

log_bin_index       = /var/log/mysql/mysql-bin.log.index 

relay_log           = /var/log/mysql/mysql-relay-bin 

relay_log_index     = /var/log/mysql/mysql-relay-bin.index 

expire_logs_days    = 10 

max_binlog_size     = 100M 

log_slave_updates   = 1

auto_increment_increment = 2

auto_increment_offset = 1

skip-name-resolve

[mysqld_safe]

log-error=/var/log/mysqld.log

pid-file=/var/run/mysqld/mysqld.pid

[root@node4 ~]#