維運案例分享
OS: CentOS 7u9
DB: MariaDB 10.2
架構需求:
倚賴 MariaDB 10.2 的 multi channel replication 收容 MariaDB 5.X 的舊版資料 ; 進行後續 Migrate 處理
開始正題:
multi channel replication 很好用,但另一層面,當 server-id 變成多對一的時候,要面對的問題層次也高了些
1. 如果 MariaDB 10.2 (Master) -> MariaDB 10.2 (Slave)
如果 gtid-domain-id 從 Master 端就開始相同(重複) 時,Slave 在 gtid_executed 就會有點為難了
不同 channel 帶進來的 gtid_executed 會往前往後跑,導致 Slave Thread 在資料處理層面辨識錯誤
有不小概率會碰上 ERROR 1950: ER_GTID_STRICT_OUT_OF_ORDER
那就關閉 set gtid_strict_mode = off; 試試看吧
2. 如果 MariaDB 5.X (Master) -> MariaDB 10.2 (Slave)
這個時候我們不用擔心 gtid-domain-id 重複,因為還不支援的情況下 replication 只能辨認 server-id
但在這個 issue 下,我們可以先在 mysqld.log 看到提示的 Log
The slave I/O thread stops because m aster and slave have equal MySQL server ids; these ids must be different for rep lication to work (or the --replicate-same-server-id option must be used on slave but this does not always make sense; please check the manual before using it).
麻煩的事 Slave IO Thread 沒打算停,頻繁的 retry 只會造成 relay log 大量產生到無法正常消化的結果 ; EX:
-rw-rw---- 1 mysql mysql 1580 Jan 30 23:31 mysql-relay-bin.586501 -rw-rw---- 1 mysql mysql 2551 Jan 30 23:31 mysql-relay-bin.586502 -rw-rw---- 1 mysql mysql 5154 Jan 30 23:31 mysql-relay-bin.586503 -rw-rw---- 1 mysql mysql 1548 Jan 30 23:31 mysql-relay-bin.586504 -rw-rw---- 1 mysql mysql 8699 Jan 30 23:31 mysql-relay-bin.586505 -rw-rw---- 1 mysql mysql 710 Jan 30 23:31 mysql-relay-bin.586506 -rw-rw---- 1 mysql mysql 3665 Jan 30 23:31 mysql-relay-bin.586507 -rw-rw---- 1 mysql mysql 1846 Jan 30 23:31 mysql-relay-bin.586508 -rw-rw---- 1 mysql mysql 7486 Jan 30 23:31 mysql-relay-bin.586509 -rw-rw---- 1 mysql mysql 2624 Jan 30 23:31 mysql-relay-bin.586510 -rw-rw---- 1 mysql mysql 1195 Jan 30 23:31 mysql-relay-bin.586511 -rw-rw---- 1 mysql mysql 12683 Jan 30 23:31 mysql-relay-bin.586512 -rw-rw---- 1 mysql mysql 6765 Jan 30 23:31 mysql-relay-bin.586513 -rw-rw---- 1 mysql mysql 5477 Jan 30 23:32 mysql-relay-bin.586514 -rw-rw---- 1 mysql mysql 1613 Jan 30 23:32 mysql-relay-bin.586515 -rw-rw---- 1 mysql mysql 1373 Jan 30 23:32 mysql-relay-bin.586516 -rw-rw---- 1 mysql mysql 10729 Jan 30 23:32 mysql-relay-bin.586517 -rw-rw---- 1 mysql mysql 473 Jan 30 23:32 mysql-relay-bin.586518 -rw-rw---- 1 mysql mysql 1159 Jan 30 23:32 mysql-relay-bin.586519 -rw-rw---- 1 mysql mysql 5469 Jan 30 23:32 mysql-relay-bin.586520 -rw-rw---- 1 mysql mysql 12258 Jan 30 23:32 mysql-relay-bin.586521
維運紀錄上 relay log 長到 mysql-relay-bin.999999 後,這條 replication 也就沒救了
所以建立 replication 後,或修正 server-id 後,還是適度關懷一下 binlog / relay log 的成長消化狀況也合適些