Mysql

忽略要複製的表時如何抑制mysql錯誤日誌中的特定警告

  • July 4, 2019

有沒有辦法通過某些警告使 mysql 錯誤日誌不那麼囉嗦?我只是在 my.cnf 中添加了replicate-ignore-table選項,因此我們的執行狀況檢查表不會被複製。但是現在我每分鐘都會收到幾個警告,告訴我一些我特別想發生的事情……這很煩人,更不用說現在日誌將以更快的速度增長。

我認為添加slave-skip-errors=1237可以解決它,但這並不是停止複制的實際錯誤。

有任何想法嗎?

2015-07-16 21:51:02 31210 [Warning] Error log throttle: 4 time(s) Error_code: 1237 "Slave SQL thread ignored the query because of replicate-*-table rules" got suppressed.
2015-07-16 21:51:02 31210 [Warning] Slave SQL: Could not execute Query event. Detailed error: Slave SQL thread ignored the query because of replicate-*-table rules; Error log throttle is enabled. This error will not be displayed for next 60 secs. It will be suppressed, Error_code: 1237
2015-07-16 21:53:01 31210 [Warning] Error log throttle: 3 time(s) Error_code: 1237 "Slave SQL thread ignored the query because of replicate-*-table rules" got suppressed.
2015-07-16 21:53:01 31210 [Warning] Slave SQL: Could not execute Query event. Detailed error: Slave SQL thread ignored the query because of replicate-*-table rules; Error log throttle is enabled. This error will not be displayed for next 60 secs. It will be suppressed, Error_code: 1237
2015-07-16 21:54:01 31210 [Warning] Error log throttle: 2 time(s) Error_code: 1237 "Slave SQL thread ignored the query because of replicate-*-table rules" got suppressed.
2015-07-16 21:54:01 31210 [Warning] Slave SQL: Could not execute Query event. Detailed error: Slave SQL thread ignored the query because of replicate-*-table rules; Error log throttle is enabled. This error will not be displayed for next 60 secs. It will be suppressed, Error_code: 1237
2015-07-16 21:55:01 31210 [Warning] Error log throttle: 3 time(s) Error_code: 1237 "Slave SQL thread ignored the query because of replicate-*-table rules" got suppressed.
2015-07-16 21:55:01 31210 [Warning] Slave SQL: Could not execute Query event. Detailed error: Slave SQL thread ignored the query because of replicate-*-table rules; Error log throttle is enabled. This error will not be displayed for next 60 secs. It will be suppressed, Error_code: 1237
2015-07-16 21:56:02 31210 [Warning] Error log throttle: 2 time(s) Error_code: 1237 "Slave SQL thread ignored the query because of replicate-*-table rules" got suppressed.
2015-07-16 21:56:02 31210 [Warning] Slave SQL: Could not execute Query event. Detailed error: Slave SQL thread ignored the query because of replicate-*-table rules; Error log throttle is enabled. This error will not be displayed for next 60 secs. It will be suppressed, Error_code: 1237    

你可以:

Set global log_warnings=0;

也許有點晚了,但由於 mysql v 8.0.13 有一個新參數 log_error_suppression_list:: https ://dev.mysql.com/doc/refman/8.0/en/server-system-variables.html#sysvar_log_error_suppression_list

在寫入錯誤日誌時,您可以使用SET @@GLOBAL.log_error_suppression_list = "1237";… 以逗號分隔的錯誤程式碼列表來抑制。

這個變數是新引入的,與上面提到的更通用的變數結合使用log_warnings,也適用於舊的 mysql 伺服器。

引用自:https://dba.stackexchange.com/questions/107273