标签:style color microsoft black
(2)配置Master-Master复制
在db1(master1)、db2(master2)、db3(slave)上编译my.conf
#vi /etc/my.cnf
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
#下面为新添加的内容
default-storage-engine = innodb
replicate-ignore-db = mysql
binlog-ignore-db = mysql
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-bin.relay
relay_log_index = /var/log/mysql/mysql-bin.relay.index
expire_logs_days = 10
max_binlog_size = 100M
log_slave_updates = 1
注意:
1)server-id在每台服务器上的值都是不一样,在这里依次为1、2、3、4。
2)因为在这里把log文件配置到了/var/log/mysql下,而mysql默认的目录是在/var/lib/mysql,所以首先要新建mysql文件夹,Mkdir /var/log/mysql,然后用chown -R mysql.mysql /var/log/mysql mysql命令将mysql的所有者修改为用户mysql。其次要保证,mysql文件夹的权限755(即-rwxr-xr-x)。
如果没有修改权限和所有者,重启服务时就会在错误日志中出现找不到mysql-bin.log或者mysql-bin.log.index的错误(/usr/libexec/mysqld: File ‘/var/log/mysql/mysql-bin.log.index‘ not found (Errcode: 13))。
完成编译后重启MYSQL服务
检查复制状态,如下图:
show master status;
检查日志是否生成道新目录,如下
# ls /var/log/mysql
使用mysql-mmm时一共需要三个用户: replication、mmm_agent和mmm_monitor(管理服务器上用来监控cluster状态的用户,所以可以限定只能从管理服务器登录)。使用下面三条命令新建这三个用户并分配相应的权限
GRANT REPLICATION CLIENT ON *.* TO ‘mmm_monitor‘@‘10.0.0.%‘ IDENTIFIED BY ‘monitor‘;
GRANT SUPER, REPLICATION CLIENT, PROCESS ON *.* TO ‘mmm_agent‘@‘10.0.0.%‘ IDENTIFIED BY ‘agent‘;
GRANT REPLICATION SLAVE ON *.* TO ‘replication‘@‘10.0.0.%‘ IDENTIFIED BY ‘replication‘;
接下来再db1和db2分别执行下面命令修改复制账户和密码。并启动SLAVE进程。
change master to master_host=‘10.0.0.4‘, master_port=3306, master_user=‘replication‘, master_password=‘replication‘;start slave;
change master to master_host=‘10.0.0.5‘, master_port=3306, master_user=‘replication‘, master_password=‘replication‘;start slave;
检查复制状态,如下图:
show slave status\G
本文出自 “李珣博客-微软技术与云” 博客,请务必保留此出处http://lixun.blog.51cto.com/4198640/1629178
Microsoft Azure部署MYSQL-MMM(2)配置主主复制
标签:style color microsoft black
原文地址:http://lixun.blog.51cto.com/4198640/1629178