mysql checksum用法_pt-table-checksum工具使用报错一例

![Percona Tollkit](https://box.kancloud.cn/2015-07-29_55b87878f2f6b.png)

_图片来自Percona官网_

今天同事在用 [percona toolkit](http://www.percona.com/software/percona-toolkit "percona toolkit") 工具中的 [pt-table-checksum](http://www.percona.com/doc/percona-toolkit/2.2/pt-table-checksum.html "pt-table-checksum") 对主从数据库进行校验,提交命令后,一直提示下面的信息:

~~~

Pausing because Threads_running=0

~~~

看字面意思是在提示当前活跃线程数为0,但为什么不继续执行呢。这个提示信息有点含糊其辞,该工具是用Perl写的,因此直接打开看脚本跟踪一下,大概就明白怎么回事了,原来是这个工具有负载保护机制,避免运行时对线上数据库产生影响。

和这个机制相关的参数名是: –max-load,其类型是:Array,用法是一个或多个 variables = value 组成的判断条件,然后根据这个规则判断某些条件是否超标。例如,设定 –max-load=”Threads_running=25″,意思是当前活跃线程数如果超过25,就暂停 checksum 工作,直到活跃线程数低于 25。

因此,在我们这个案例中,想要强制让 table-checksum 继续工作的话,可以设定 –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.

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值