
Aufstellen:
Galera-Cluster mit 3 Knoten, die in Docker-Containern laufen. Vor jedem Knoten steht ein Maxscale-Proxy. Remote läuft ein Replikations-Slave mit Binärlog-Replikation, wobei der Cluster als Master fungiert (hinter dem Maxscale-Proxy). Jeder Knoten im Cluster hat Binärlog aktiviert und log_slave_updates=ON
GTID ist auf dem Slave nicht konfiguriert.
Problem
Aus irgendeinem Grund hat DB2 (siehe unten) eine andere Binärprotokolldateinummer .000016
als .000015
die anderen beiden Server. Interessanterweise haben sie die gleiche Position, daher gehe ich davon aus, dass sie den gleichen Inhalt haben, da sie dieselbe Erstellungszeit und genau dieselbe Dateigröße haben (obwohl md5sum unterschiedliche Prüfsummen anzeigt).
Irgendwann geriet der Slave mit den folgenden Protokollen außer Synchronisation:
2022-06-08 0:27:20 9 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'data-master-bin.000015' at position 3374796
2022-06-08 0:28:20 9 [ERROR] Slave I/O: error reconnecting to master '[email protected]:some_port' - retry-time: 60 maximum-retries: 86400 message: Can't connect to MySQL server on 'url.to.server' (110 "Connection timed out"), Internal MariaDB error code: 2003
2022-06-08 0:29:20 9 [Note] Slave: connected to master '[email protected]:some_port',replication resumed in log 'data-master-bin.000015' at position 3374796
2022-06-08 0:29:20 9 [ERROR] Error reading packet from server: binlog truncated in the middle of event; consider out of disk space on master; the first event 'data-master-bin.000015' at 3374796, the last event read from 'data-master-bin.000015' at 3374796, the last byte read from 'data-master-bin.000015' at 3374815. (server_errno=1236)
2022-06-08 0:29:20 9 [ERROR] Slave I/O: Got fatal error 1236 from master when reading data from binary log: 'binlog truncated in the middle of event; consider out of disk space on master; the first event 'data-master-bin.000015' at 3374796, the last event read from 'data-master-bin.000015' at 3374796, the last byte read from 'data-master-bin.000015' at 3374815.', Internal MariaDB error code: 1236
2022-06-08 0:29:20 9 [Note] Slave I/O thread exiting, read up to log 'data-master-bin.000015', position 3374796
Ich kann nicht wirklich sagen, ob es irgendwann keine Verbindung gab. Ich gehe davon aus, dass der Maxscale-Proxy normalerweise alle eingehenden Anfragen an den ersten Server umleitet, da die DBs nicht stark ausgelastet sind. Zu diesem Zeitpunkt wurde die Anfrage jedoch an DB-02 umgeleitet, was den Fehler verursachte, da sich dort data-master-bin.000015 von den anderen beiden Servern unterscheidet. Ich konnte es START SLAVE
auf dem Slave ausführen und die Replikation ist jetzt wieder einsatzbereit, aber ich befürchte, dass sie abbricht, sobald Maxscale wieder an DB-02 umleitet.
Meine Fragen sind also:
- Was löst eine Erhöhung des Binärprotokolldateiindex aus?
- Wie kann ich die Binärprotokolldateien auf den drei Clusterknoten wieder synchronisieren?
Konfigurationen:
db-server .cnf auf jedem Knoten:
[mysqld]
log_bin
server_id=1
log_slave_updates=ON
log-basename=data-master
#Configure GTID
wsrep_gtid_mode=ON
wsrep_gtid_domain_id=1
Proxy .cnf auf jedem Server
[Read-Only-Service]
type=service
router=readconnroute
servers=db-01, db-02, db-03
user=maxscale
password=******
router_options=synced
[Replication-Listener]
type=listener
service=Read-Only-Service
protocol=MariaDBClient
port=/*some-port*/
ssl=required
ssl_cert=/path/to/server-cert.pem
ssl_key=/path/to/server-key.pem
ssl_ca_cert=/path/to/ca-cert.pem
DB1
MariaDB [(none)]> SHOW MASTER STATUS;
+------------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------------+----------+--------------+------------------+
| data-master-bin.000015 | 3534812 | | |
+------------------------+----------+--------------+------------------+
1 row in set (0.000 sec)
ls -alc --fu /var/lib/mysql
...
413 2021-12-02 10:06:08.187023308 +0000 data-master-bin.000009
387 2021-12-02 10:09:23.020291420 +0000 data-master-bin.000010
8883991 2022-03-02 16:53:11.689571461 +0000 data-master-bin.000011
1260112 2022-03-10 13:10:08.730056029 +0000 data-master-bin.000012
466 2022-03-10 13:10:29.106313267 +0000 data-master-bin.000013
5967037 2022-04-27 16:41:46.021414396 +0000 data-master-bin.000014
3672324 2022-06-13 22:03:54.919102767 +0000 data-master-bin.000015
175 2022-04-27 16:42:46.150317967 +0000 data-master-bin.index
...
DB2
MariaDB [(none)]> show master status;
+------------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------------+----------+--------------+------------------+
| data-master-bin.000016 | 3534812 | | |
+------------------------+----------+--------------+------------------+
1 row in set (0.000 sec)
ls -alc --fu /var/lib/mysql
...
413 2022-03-10 13:10:34.036661850 +0000 data-master-bin.000014
5966988 2022-04-27 16:44:37.871084681 +0000 data-master-bin.000015
3672324 2022-06-13 22:03:54.935182267 +0000 data-master-bin.000016
75 2022-04-27 16:45:21.228903025 +0000 data-master-bin.index
...
DB3
MariaDB [(none)]> SHOW Master status;
+------------------------+----------+--------------+------------------+
| File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
+------------------------+----------+--------------+------------------+
| data-master-bin.000015 | 3534812 | | |
+------------------------+----------+--------------+------------------+
1 row in set (0.000 sec)
ls -alc --fu /var/lib/mysql
...
413 2022-03-10 13:10:12.637403075 +0000 data-master-bin.000013
5966988 2022-04-27 16:46:33.269169792 +0000 data-master-bin.000014
3672324 2022-06-13 22:03:54.929455002 +0000 data-master-bin.000015
75 2022-04-28 00:37:55.597345308 +0000 data-master-bin.index
...
Ich verwende Maria DB 10.4
Antwort1
Ich habe das Problem gemildert, indem ich den Server auf nur eingestellt habe db-01
. Dadurch ist das Bin-Protokoll nur dasselbe. Ich bin sicher, dass es einen besseren Weg geben sollte, dieses Problem zu handhaben.
[Read-Only-Service]
type=service
router=readconnroute
servers=db-01
user=maxscale
password=******
router_options=synced
[Replication-Listener]
type=listener
service=Read-Only-Service
protocol=MariaDBClient
port=/*some-port*/
ssl=required
ssl_cert=/path/to/server-cert.pem
ssl_key=/path/to/server-key.pem
ssl_ca_cert=/path/to/ca-cert.pem