![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.
- 前言
- 为什么InnoDB表要建议用自增列做主键
- 线上环境到底要不要开启query cache
- MySQL复制中slave延迟监控
- 如何安全地关闭MySQL实例
- 如何查看当前最新事务ID
- 从MyISAM转到InnoDB需要注意什么
- 5.6版本GTID复制异常处理一例
- 不同的binlog_format会导致哪些SQL不会被记录
- Spring框架中调用存储过程失败
- 如何将两个表名对调
- mysqldump加-w参数备份
- 使用mysqldump备份时为什么要加上 -q 参数
- 修改my.cnf配置不生效
- 什么情况下会用到临时表
- profiling中要关注哪些信息
- EXPLAIN结果中哪些信息要引起关注
- processlist中哪些状态要引起关注
- MySQL无法启动例一
- pt-table-checksum工具使用报错一例
- 为什么要关闭query cache,如何关闭
- MySQL联合索引是否支持不同排序规则
- SAVEPOINT语法错误一例
- 你所不知的table is full那些事
- 大数据量时如何部署MySQL Replication从库
- 内存溢出案例