
設定:
Galera 叢集有 3 個節點在 Docker 容器中運作。每個節點前面都有一個 maxscale 代理程式。遠端是一個與 bin-log 複製一起運行的複製從站,其中叢集充當主站(位於 maxscale 代理後面)。叢集中的每個節點都啟用了 bin-log 並且log_slave_updates=ON
.從站上未配置 GTID。
問題
不知何故,DB2(見下文)有另一個 bin-log 文件號。.000016
而不是.000015
像其他兩個伺服器一樣。有趣的是,它們具有相同的位置,因此我假設它們具有相同的內容,因為它們具有相同的創建時間和完全相同的檔案大小(儘管 md5sum 顯示不同的校驗和)。
在某些時候,從站與以下日誌不同步:
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
我真的不能說是否在某個時刻沒有連結。我的假設是,maxscale 代理通常會將所有傳入請求重新導向到第一台伺服器,因為資料庫上根本沒有太多負載。然而,在這個特定時間,請求被重定向到 db-02,這導致了錯誤,因為 data-master-bin.000015 與其他兩台伺服器不同。我能夠START SLAVE
在從屬伺服器上運行,並且複製現在已啟動並再次運行,但我擔心一旦 maxscale 再次重定向到 db-02,它就會中斷。
所以我的問題是:
- 是什麼觸發了 bin-log 檔案索引的增加?
- 如何使 bin-log 檔案在 3 個叢集節點上恢復同步?
配置:
每個節點上的 db-server .cnf:
[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
每台伺服器上的代理 .cnf
[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
資料庫1
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
...
資料庫2
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
...
我正在使用瑪麗亞資料庫10.4
答案1
我透過將伺服器設定為僅緩解了該問題db-01
。這樣,bin日誌就只剩下一樣了。我確信應該有更好的方法來處理這個問題。
[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