mysql集群(双主)

时间:2021-02-05 02:33:29

0、安装

所谓双主基本可以理解为两台服务器互为主备,其核心思路与主备配置相同。

服务器A:
内网IP: 10.44.94.219
服务器B:
内网IP: 10.44.94.97

1、配置服务器A

log-bin=mysql-bin.log
server-id=
auto_increment_increment=
auto_increment_offset=
relay_log= mysql-relay-bin.log
log_slave_updates = GRANT REPLICATION SLAVE,RELOAD,SUPER ON *.* TO 'backup'@'10.44.94.97' IDENTIFIED BY 'fredric'; CHANGE MASTER TO MASTER_HOST='10.44.94.97',
MASTER_USER='backup',
MASTER_PORT=,
MASTER_PASSWORD='fredric',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=; START SLAVE;

2、配置服务器B

log-bin=mysql-bin.log
server-id=
auto_increment_increment=
auto_increment_offset=
relay_log= mysql-relay-bin.log
log_slave_updates = GRANT REPLICATION SLAVE,RELOAD,SUPER ON *.* TO 'backup'@'10.44.94.219' IDENTIFIED BY 'fredric'; CHANGE MASTER TO MASTER_HOST='121.40.189.197',
MASTER_USER='backup',
MASTER_PORT=,
MASTER_PASSWORD='fredric',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=; #备注:其中auto_increment_offset分别设置为偶数和奇数递增,以防止冲突