MySQL双主架构

MySQL双主架构



yum install -y mysql-server

# my.cnf
log-bin=mysql-bin
server-id=1
relay_log = mysql-relay-bin
log_slave_updates = 1
sync_binlog = 1
auto-increment-offset = 1
auto-increment-increment = 2

# FLUSH TABLES WITH READ LOCK;
# UNLOCK TABLES;
# stop slave;
# reset slave;
# reset master;

GRANT REPLICATION SLAVE, REPLICATION CLIENT ON *.* TO 'slave'@'172.21.23.%' IDENTIFIED BY '123456';

CHANGE MASTER TO MASTER_HOST='172.21.23.69',
MASTER_USER='slave',
MASTER_PASSWORD='123456',
MASTER_LOG_FILE='mysql-bin.000001',
MASTER_LOG_POS=0;

iptables -I INPUT -p tcp --dport 3306 -j ACCEPT

start slave;
show slave status\G