MySQLMMM安装指南(MultiMaster Replication Manager for MySQL)

最基本的MMM安装必须至少需要2个数据库服务器和一个监控服务器下面要配置的MySQL Cluster环境包含四台数据库服务器和一台监控服务器,如下: function ip hostname server id monitoring host 192.

                        <p>最基本的MMM安装必须至少需要2个数据库服务器和一个监控服务器下面要配置的MySQL Cluster环境包含四台数据库服务器和一台监控服务器,如下:</p>

function ip hostname server id monitoring host 192.168.0.10 mon - master 1 192.168.0.11 db1 1 master 2 192.168.0.12 db2 2 slave 1 192.168.0.13 db3 3 slave 2 192.168.0.14 db4 4

如果是个人学习安装,一下子找5台机器不太容易,可以虚拟机就可以完成。

 配置完成后,使用下面的虚拟IP访问MySQL Cluster,他们通过MMM分配到不同的服务器。

ip role description 192.168.0.100 writer 应用程序应该连接到这个ip进行写操作 192.168.0.101 reader 应用程序应该链接到这些ip中的一个进行读操作 192.168.0.102 reader 192.168.0.103 reader 192.168.0.104 reader

结构图如下:

2. Basic configuration of master 1 First we install MySQL on all hosts: aptitude install mysql-serverThen we edit the configuration file /etc/mysql/my.cnf and add the following lines - be sure to use different server ids for all hosts: 复制代码 代码如下: server_id = 1 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 Then remove the following entry: bind-address = 127.0.0.1Set to number of masters: auto_increment_increment = 2Set to a unique, incremented number, less than auto_increment_increment, on each server auto_increment_offset = 1Do not bind of any specific IP, use 0.0.0.0 instead: bind-address = 0.0.0.0Afterwards we need to restart MySQL for our changes to take effect: /etc/init.d/mysql restart 3. Create usersNow we can create the required users. We'll need 3 different users:

function description privileges monitor user used by the mmm monitor to check the health of the MySQL servers REPLICATION CLIENT agent user used by the mmm agent to change read-only mode, replication master, etc. SUPER, REPLICATION CLIENT, PROCESS relication user used for replication REPLICATION SLAVE