Mysql
MariaDB 複製不會自動重新連接
我在兩台 MariaDB 5.5 伺服器之間建立了一個簡單的主從複製設置。伺服器之間的連接有些不穩定,不時導致斷開連接。
但是,“master_retry_count=0”在從屬伺服器的 my.ini 中設置,據我了解,這意味著從屬伺服器應在斷開連接時繼續嘗試重新連接到主伺服器,因此真的不應該有任何重大問題片狀連接。
但是,我經歷過幾次複製停止,並出現以下錯誤:
從屬 I/O 執行緒停止,因為 master 上的 SET @master_heartbeat_period 失敗。錯誤:查詢期間失去與 MySQL 伺服器的連接
當我注意到這一點時,複製通常會處於停止狀態數小時,只需發出“START SLAVE”查詢就可以再次恢復正常,但我不明白為什麼會首先出現這個問題。
是否有人碰巧有任何經驗或能夠對此有所了解?有什麼方法可以確保複製不會因為臨時連接問題而停止?
這是帶有錯誤的範例日誌:
130710 2:42:29 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013) 130710 2:42:30 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000341' at position 20051884 130710 2:56:26 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013) 130710 2:56:26 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000341' at position 20523725 130710 2:57:04 [ERROR] Slave I/O: error reconnecting to master 'rep_user@master_server:3306' - retry-time: 60 retries: 0 message: Lost connection to MySQL server at 'reading au thorization packet', system error: 0, Error_code: 2013 130710 2:58:05 [Note] Slave: connected to master 'rep_user@master_server:3306',replication resumed in log 'mysql-bin.000341' at position 20523725 130710 3:26:31 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013) 130710 3:26:31 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000341' at position 20893274 130710 3:27:48 [ERROR] Slave I/O: error reconnecting to master 'rep_user@master_server:3306' - retry-time: 60 retries: 0 message: Lost connection to MySQL server at 'reading authorization packet', system error: 0, Error_code: 2013 130710 3:31:01 [Note] Slave: connected to master 'rep_user@master_server:3306',replication resumed in log 'mysql-bin.000341' at position 20893274 130710 3:32:19 [ERROR] Error reading packet from server: Lost connection to MySQL server during query ( server_errno=2013) 130710 3:32:19 [Note] Slave I/O thread: Failed reading log event, reconnecting to retry, log 'mysql-bin.000341' at position 21083757 130710 3:48:03 [ERROR] Slave I/O: The slave I/O thread stops because SET @master_heartbeat_period on master failed. Error: Lost connection to MySQL server during query, Error_code: 1593 130710 3:48:03 [Note] Slave I/O thread exiting, read up to log 'mysql-bin.000341', position 21083757
(從上面的日誌來看,連接確實很糟糕;它通常不會那麼糟糕,但有時會發生。修復連接顯然是理想的,但我也希望複製不應該因此而停止)
從站上可能相關的 my.ini 設置:
master_retry_count=0 slave_sql_verify_checksum=0 slave_net_timeout=1800 net_retry_count=10
對心跳不是很了解,所以一直沒有設置,但是根據狀態,心跳週期是900秒。
謝謝閱讀。
看起來這是 MariaDB 和 MySQL 中的一個錯誤,已在 MySQL 5.6 中修復。
MariaDB 中的修復將在此處跟踪:https ://mariadb.atlassian.net/browse/MDEV-6188