mysql_MMM服務器的搭建

配置方案


    主機         地址              角色       虛擬IP    

     db2       172.16.24.7        master      172.16.24.77

     db3       172.16.24.8        master      172.16.24.88

     db4       172.16.24.9        slave       172.16.24.99

     db1       172.16.24.6         MMM

(注:四臺主機都要裝上mysql)

一、配置mysql主主複製

1)編輯配置文件(主機172.16.24.7)

[root@localhost ~]# vim /etc/my.cnf

wKiom1NjYZHTpeD3AAFypVle2fc851.jpg

wKioL1NjYXmDL58aAACKAqRPaDc316.jpg

2)編輯配置文件(172.16.24.8)

[root@localhost ~]# vim /etc/my.cnf

wKiom1NjYgTCzfAiAAFulVx4wh4741.jpg

wKioL1NjYezRWOCYAACAMy8fMpY491.jpg

3)編輯配置文件(172.16.24.9)

server-id       = 3

log-bin=mysql-bin

log-slave-updates

4)編輯配置文件(172.16.24.6)

server-id       = 4

log-bin=mysql-bin

log-slave-updates

5)、創建具有複製權限的mysql用戶(172.16.24.7、172.16.24.8)

server1 (172.16.24.7)

mysql> grant replication slave on *.* to 'myuser'@'172.16.24.8' identified by 'mypass';

mysql> grant replication slave on *.* to 'myuser'@'172.16.24.9' identified by 'mypass';

mysql> flush privileges;

server2(172.16.24.8)

mysql> grant replication slave on *.* to 'myuser'@'172.16.24.7' identified by 'mypass';

mysql> grant replication slave on *.* to 'myuser'@'172.16.24.9' identified by 'mypass';

mysql> flush privileges;




二、主主複製數據(172.16.24.7、172.16.24.8)

1)同步數據(db3同步db2的數據)

server1:(172.16.24.7)

mysql> show master status;

+------------------+----------+--------------+------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000003 |      346 |              |                  |

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)

server2:(172.16.24.8)

mysql> change master to MASTER_HOST='172.16.24.7',MASTER_USER='myuser',MASTER_PASSWORD='mypass',MASTER_LOG_FILE='mysql-bin.000003',MASTER_LOG_POS=346;


mysql> start slave;

Query OK, 0 rows affected (0.01 sec)


mysql> show slave status\G

*************************** 1. row ***************************

              Slave_IO_State: Waiting for master to send event

                 Master_Host: 172.16.24.7

                 Master_User: myuser

                 Master_Port: 3306

               Connect_Retry: 60

             Master_Log_File: mysql-bin.000003

         Read_Master_Log_Pos: 346

              Relay_Log_File: localhost-relay-bin.000002

               Relay_Log_Pos: 253

       Relay_Master_Log_File: mysql-bin.000003

            Slave_IO_Running: Yes

           Slave_SQL_Running: Yes

2)同步數據(db2同步db3的數據)

server2:(172.16.24.8)

mysql> show master status;

+------------------+----------+--------------+------------------+

| File             | Position | Binlog_Do_DB | Binlog_Ignore_DB |

+------------------+----------+--------------+------------------+

| mysql-bin.000003 |      505 |              |                  |

+------------------+----------+--------------+------------------+

1 row in set (0.00 sec)

server1:(172.16.24.7)

mysql> change master to MASTER_HOST='172.16.24.8',MASTER_USER='myuser',MASTER_PASSWORD='mypass',MASTER_LOG_FILE='mysql-bin.000003',MASTER_LOG_POS=505;

Query OK, 0 rows affected (0.08 sec)


mysql> start slave;

Query OK, 0 rows affected (0.00 sec)


mysql> show slave status\G

*************************** 1. row ***************************

              Slave_IO_State: Waiting for master to send event

                 Master_Host: 172.16.24.8

                 Master_User: myuser

                 Master_Port: 3306

               Connect_Retry: 60

             Master_Log_File: mysql-bin.000003

         Read_Master_Log_Pos: 505

              Relay_Log_File: localhost-relay-bin.000002

               Relay_Log_Pos: 253

       Relay_Master_Log_File: mysql-bin.000003

            Slave_IO_Running: Yes

           Slave_SQL_Running: Yes

             Replicate_Do_DB:

         Replicate_Ignore_DB:

三、安裝mysql-mmm及配

1)安裝mysql-mmm(四個主要都要安裝)

[root@localhost ~]# yum install mysql-mmm*

wKioL1NkVlWh1JAYAACG7WVk9xU730.jpg

2)修改配置文件(172.16.24.6)

[root@localhost ~]# vim /etc/mysql-mmm/mmm_common.conf  

<host default>

   cluster_interface       eth0

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

   bin_path                /usr/libexec/mysql-mmm/

   replication_user        slave

   replication_password    slave

   agent_user              mmm_agent

   agent_password          mmm_agent

</host>


<host db2>

   ip      172.16.24.7

   mode    master

   peer    db3

</host>


<host db3>

   ip      172.16.24.8

   mode    master

   peer    db2

</host>


<host db4>

   ip      172.16.24.9

   mode    slave

</host>

<role writer>

   hosts   db2, db3

   ips     172.16.24.77

   mode    exclusive

</role>


<role reader>

   hosts   db2,db3,db4

   ips     172.16.24.77,172.16.24.88,172.16.24.99

   mode    balanced

</role>


3)發送到其它3臺主機

[root@localhost mysql-mmm]# scp mmm_common.conf 172.16.24.7:/etc/mysql-mmm/  

[root@localhost mysql-mmm]# scp mmm_common.conf 172.16.24.8:/etc/mysql-mmm/

[root@localhost mysql-mmm]# scp mmm_common.conf 172.16.24.9:/etc/mysql-mmm/

4)添加agentd使用的mysql用戶,db2,db3,db4都要添加

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

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

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

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

5)修改的/etc/mysql-mmm/mmm_agent.conf 配置文件(四臺主機都要改,要跟你的主機名對上)

db2:(172.16.24.7)

[root@localhost ~]# cat /etc/mysql-mmm/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

db3:(172.16.24.8)

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

其它略…………………

6)啓動mysql-mmm-agent(172.16.24.7,172.16.24.8,172.16.24.9)

[root@localhost ~]# /etc/init.d/mysql-mmm-agent start

Starting MMM Agent Daemon:                                 [  OK  ]

7)啓動mysql-mmm-monitor(172.16.24.6)

[root@localhost ~]# /etc/init.d/mysql-mmm-monitor start

Starting MMM Monitor Daemon:                               [  OK  ]

到此配置結束


發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章