pt-table-checksum工具使用報錯一例

2018-02-24 16:05 更新

Percona Tollkit
圖片來自Percona官網

今天同事在用?percona toolkit?工具中的?pt-table-checksum?對主從數據庫進行校驗,提交命令后,一直提示下面的信息:

Pausing because Threads_running=0

看字面意思是在提示當前活躍線程數為0,但為什么不繼續(xù)執(zhí)行呢。這個提示信息有點含糊其辭,該工具是用Perl寫的,因此直接打開看腳本跟蹤一下,大概就明白怎么回事了,原來是這個工具有負載保護機制,避免運行時對線上數據庫產生影響。

和這個機制相關的參數名是:?–max-load,其類型是:Array,用法是一個或多個?variables = value?組成的判斷條件,然后根據這個規(guī)則判斷某些條件是否超標。例如,設定?–max-load=”Threads_running=25″,意思是當前活躍線程數如果超過25,就暫停 checksum 工作,直到活躍線程數低于 25。

因此,在我們這個案例中,想要強制讓 table-checksum 繼續(xù)工作的話,可以設定 –max-load 的值,例如:

pt-table-checksum --max-load="Threads_running=25" ...其他選項...

或者

pt-table-checksum --max-load="Threads_connected=25" ...其他選項...

前面的選項意思是判斷活躍線程數不要超過25個,后面的選項意思是當前打開的線程數不要超過25個。

下面是 pt-table-checksum 幫助手冊里的一段話:

–max-load
type: Array; default: Threads_running=25; group: Throttle

Examine SHOW GLOBAL STATUS after every chunk, and pause if any status variables are higher than the threshold. The option accepts a comma-sep-
arated list of MySQL status variables to check for a threshold. An optional “=MAX_VALUE” (or “:MAX_VALUE”) can follow each variable. If not
given, the tool determines a threshold by examining the current value and increasing it by 20%.

For example, if you want the tool to pause when Threads_connected gets too high, you can specify “Threads_connected”, and the tool will check
the current value when it starts working and add 20% to that value. If the current value is 100, then the tool will pause when Threads_con-
nected exceeds 120, and resume working when it is below 120 again. If you want to specify an explicit threshold, such as 110, you can use
either “Threads_connected:110″ or “Threads_connected=110″.

The purpose of this option is to prevent the tool from adding too much load to the server. If the checksum queries are intrusive, or if they
cause lock waits, then other queries on the server will tend to block and queue. This will typically cause Threads_running to increase, and the
tool can detect that by running SHOW GLOBAL STATUS immediately after each checksum query finishes. If you specify a threshold for this vari-
able, then you can instruct the tool to wait until queries are running normally again. This will not prevent queueing, however; it will only
give the server a chance to recover from the queueing. If you notice queueing, it is best to decrease the chunk time.

以上內容是否對您有幫助:
在線筆記
App下載
App下載

掃描二維碼

下載編程獅App

公眾號
微信公眾號

編程獅公眾號