Mysql: replica circolare master-master

Alcuni appunti presi http://www.azns.it/2011/04/13/due-server-mysql-in-replica-circolare-master-master/ per configurare un mysql in replica circolare master-master in modo da scalare.

Configurazione server 1:

/etc/mysql/conf.d/replica.cnf
[mysqld]
bind-address			= 0.0.0.0
server-id                       = 10
auto_increment_increment        = 10
auto_increment_offset           = 1
master-host                     = server2.dominio.local
master-user                     = replicauser
master-password                 = replicapass
log_bin				= /var/log/mysql/mysql-bin.log
binlog_ignore_db		= mysql

Configurazione server 2:

/etc/mysql/conf.d/replica.cnf
[mysqld]
bind-address			= 0.0.0.0
server-id                       = 20
auto_increment_increment        = 10
auto_increment_offset           = 2
master-host                     = server1.dominio.local
master-user                     = replicauser
master-password                 = replicapass
log_bin				= /var/log/mysql/mysql-bin.log
binlog_ignore_db		= mysql

Riavviare mysql su entrambi i server e impartire il seguente comando da console:

CREATE USER 'replicauser'@'%.san.local' IDENTIFIED BY 'replicapass';
GRANT replication slave ON *.* TO 'replicauser'@'%.dominio.local';
START slave;
SHOW slave STATUS\G;