Master-Master-Replikation

Dieser Artikel zeigt, wie man mit 2 (oder mehr) MySQL-Servern eine echte Master-Master-Replikation aufsetzt, um die Server HA-tauglich zu machen.

Es gibt 2 Server: 

Als Heartbeat-IP kann man irgendeine IP verwenden, da MySQL automatisch auf allen konfigurierten IP-Adressen lauscht.

[mysqld]
...
server-id=1
log-bin
...
mysql> grant replication slave on *.* to 'replication'@192.168.1.11 identified by 'slave';
[mysqld]
...
server-id=2
master-host = 192.168.128.1
master-user = replication
master-password = slave
master-port = 3306
...
mysql> show slave status\G;

*************************** 1. row ***************************
 
Slave_IO_State:	Waiting for master to send event
Master_Host:	192.168.1.10
Master_User:	replica
Master_Port:	3306
...
Slave_IO_Running:	Yes
Slave_SQL_Running:	Yes
...
1 row in set (0.00 sec)
mysql> show master status;

+------------------------+----------+--------------+------------------+
| File                   | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------------+----------+--------------+------------------+
|MysqlMYSQL01-bin.000016 |      132 |              | foobar           |
+------------------------+----------+--------------+------------------+
1 row in set (0.00 sec)
[mysqld]
...
server-id=2
log-bin
binlog-ignore-db=mysql
master-host = 192.168.1.10
master-user = replication
master-password = slave
master-port = 3306
mysql> grant replication slave on *.* to 'replication'@192.168.1.10 identified by 'slave';
[mysqld]
...
master-host = 192.168.128.2
master-user = replication
master-password = slave
master-port = 3306
...
Slave_IO_Running:	Yes
Slave_SQL_Running:	Yes

Revision #2
Created 27 July 2021 13:00:04 by magenbrot
Updated 27 July 2021 13:00:51 by magenbrot