双主复制配置

两台机器,系统版本CentOS6.5,主机名分别是master和slave,IP地址分别是192.168.8.57和192.168.8.58
1、分别在两个节点创建复制用户
在主动节点:
grant replication slave on *.* to 'repl'@'192.168.8.58' identified by 'mysql';
在被动节点:
grant replication slave on *.* to 'repl'@'192.168.8.57' identified by 'mysql';

2、修改数据库配置文件
在主动节点添加如下配置:
server-id = 1
log-bin = /mysql/data/mysql-bin-3306
relay-log = relay-log
read-only = false
log-slave-updates
skip-slave-start

在被动节点添加如下配置:
server-id = 2
log-bin = /mysql/data/mysql-bin-3306
relay-log = relay-log
read-only = true
log-slave-updates

3、配置复制流
配置第一个复制流:
change master to
master_host='192.168.8.57',
master_port=3306,
master_user='repl',
master_password='mysql',
master_log_file='mysql-bin.000001',
master_log_pos=154,
master_connect_retry=10;

配置第二个复制流:
change master to
master_host='192.168.8.58',
master_port=3306,
master_user='repl',
master_password='mysql',
master_log_file='mysql-bin.000002',
master_log_pos=154,
master_connect_retry=10;

4、双向复制验证

上一篇:Redis基础-主从库模式


下一篇:Mysql8.0 主从复制