Percona-Tookit工具包之pt-heartbeat
pt-heartbeat [OPTIONS] [DSN] --update|--monitor|--check|--stop
--check //Specify the check mode to slave delay.It only checks once then exits.
--monitor //Specify the monitor mode to slave delay.
--update //Specify the update mode on master.
--check-read-only //It skips insert operations if the server is read-only status.
--create-table //Create a heartbeat table.
--table //Specify the heartbeat table(default "heartbeat").
--daemonize //Run it as background process.
--dbi-driver //Specify the drive of database(default "mysql",other value is "pg").
--file //Specify a output file when using --monitor.
--log //Print all output to the file when using --daemonize
--master-server-id //Calculate delay from this master server id.
--interval //Specify the frequency to update or check the heartbeat table(default "1.0").
--run-time //Specify the period of time to run(default suffix is "s",if you set 60,it means 60s). Notice:
Specify at least one of --stop, --update, --monitor, or --check.
--update, --monitor, and --check are mutually exclusive.
--daemonize and --check are mutually exclusive.
[root@zlm2 :: ~]
#pt-heartbeat --database=sysbench --create-table --table=hb --daemonize -h192.168.1. -P3306 -uzlm -pzlmzlm --update [root@zlm2 :: ~]
# (zlm@192.168.1.101 )[sysbench]>show tables like 'hb';
+-------------------------+
| Tables_in_sysbench (hb) |
+-------------------------+
| hb |
+-------------------------+
row in set (0.00 sec) (zlm@192.168.1.101 )[sysbench]>select * from hb;
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
| ts | server_id | file | position | relay_master_log_file | exec_master_log_pos |
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
| --19T03::07.005490 | | mysql-bin. | | NULL | NULL |
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
row in set (0.00 sec) //The operation above will create a heartbeat table "hb" in database "sysbench" if the target table not exist.
//It will update the table which contains the heartbeat info of master every time you execute with "--update".
[root@zlm2 :: ~]
#pt-heartbeat --database=sysbench -h192.168.1. -P3306 -uzlm -pzlmzlm --check
DBD::mysql::db selectrow_arrayref failed: Table 'sysbench.heartbeat' doesn't exist [for Statement "SHOW CREATE TABLE `sysbench`.`heartbeat`"] at /usr/bin/pt-heartbeat line 5873. [root@zlm2 :: ~]
#pt-heartbeat --database=sysbench --create-table --table=hb -h192.168.1. -P3306 -uzlm -pzlmzlm --check
0.00 (zlm@192.168.1.102 )[sysbench]>show tables like 'hb';
+-------------------------+
| Tables_in_sysbench (hb) |
+-------------------------+
| hb |
+-------------------------+
row in set (0.00 sec) (zlm@192.168.1.102 )[sysbench]>select * from hb;
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
| ts | server_id | file | position | relay_master_log_file | exec_master_log_pos |
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
| --19T03::53.005890 | | mysql-bin. | | NULL | NULL |
| -- :: | | NULL | NULL | NULL | NULL |
+----------------------------+-----------+------------------+----------+-----------------------+---------------------+
rows in set (0.00 sec) //The connection option refers to slave.
//It will also create the same heartbeat table on the slave.
//The output will show the delay time.
[root@zlm2 :: ~]
#pt-heartbeat --database=sysbench --create-table --table=hb --daemonize --log=/root/monitor.log -h192.168.1. -P3306 -uzlm -pzlmzlm --monitor [root@zlm2 :: ~]
#ls -l|grep monitor
-rw-r--r-- root root Jul : monitor.log [root@zlm2 :: ~]
#cat monitor.log
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
possibly with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
at /usr/bin/pt-heartbeat line .
*******************************************************************
Using the default of SSL_verify_mode of SSL_VERIFY_NONE for client
is deprecated! Please set SSL_verify_mode to SSL_VERIFY_PEER
possibly with SSL_ca_file|SSL_ca_path for verification.
If you really don't want to verify the certificate and keep the
connection open to Man-In-The-Middle attacks please set
SSL_verify_mode explicitly to SSL_VERIFY_NONE in your application.
*******************************************************************
at /usr/bin/pt-heartbeat line . # A software update is available:
# * The current version for Percona::Toolkit is 3.0. .00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ]
.00s [ .00s, .00s, .00s ] [root@zlm2 :: ~]
# //The output will be write into the logfile sepcified by option "--log".
//The logfile will be continuously written unless you've specified th option "--run-time".
//It seems no delay between master and slave at all.We can use sysbench generate some transactions to observe the difference.
[root@zlm2 :: ~/sysbench-1.0/src/lua]
#sysbench oltp_read_write.lua --mysql-host=192.168.1.101 --mysql-port= --mysql-user=zlm --mysql-password=zlmzlm --mysql-db=sysbench --tables= --table-size= --mysql-storage-engine=innodb prepare
sysbench 1.0. (using bundled LuaJIT 2.1.-beta2) Creating table 'sbtest1'...
Inserting records into 'sbtest1'
FATAL: mysql_drv_query() returned error (The table 'sbtest1' is full) for query 'INSERT INTO sbtest1(k, c, pad) VALUES(5007652, '---------', '----'),(4980838, '---------', '----'),(4369690, '---------', '----'),(4980019, '---------', '----'),(4997783, '---------', '----'),(4996542, '---------', '----'),(5016589, '---------', '----'),(4994933, '---------', '----'),(5024203, '---------', '----'),(4162450, '---------', '----'),(4995444, '---------', '----'),(5014023, '---------', '----'),(5024261, '---------', '----'),(5024236, '---------', '----'),(5049980, '---------', '----'),(5471904, '---------', '----'),(5019788, '---------', '----'),(5021303, '---------', '----'),(5015123, '---------', '----'),(3676715, '---------', '----'),(5236763, '----FATAL: `sysbench.cmdline.call_command' function failed: ./oltp_common.lua:230: db_bulk_insert_next() failed //Master
[root@zlm2 :: ~/sysbench-1.0/src/lua]
#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root .4G .4G 68M % / //The disk space of master is full.
devtmpfs 488M 488M % /dev
tmpfs 497M 497M % /dev/shm
tmpfs 497M 6.6M 491M % /run
tmpfs 497M 497M % /sys/fs/cgroup
/dev/sda1 497M 118M 379M % /boot
none 87G 80G .6G % /vagrant //Slave
[root@zlm3 :: ~]
#df -h
Filesystem Size Used Avail Use% Mounted on
/dev/mapper/centos-root .4G .4G 20K % / //The disk space of slave is full,too.
devtmpfs 488M 488M % /dev
tmpfs 497M 497M % /dev/shm
tmpfs 497M 6.5M 491M % /run
tmpfs 497M 497M % /sys/fs/cgroup
/dev/sda1 497M 118M 379M % /boot
none 87G 80G .6G % /vagrant //Check the output logfile.
[root@zlm2 :: ~]
#tail monitor.log
.00s [ .40s, .65s, .55s ]
.00s [ .26s, .65s, .55s ]
.99s [ .13s, .65s, .55s ]
.99s [ .00s, .66s, .55s ]
.99s [ .86s, .67s, .56s ]
.99s [ .73s, .68s, .56s ]
.99s [ .59s, .70s, .57s ]
.00s [ .46s, .72s, .57s ]
.01s [ .29s, .73s, .58s ]
.99s [ .16s, .75s, .58s ] //Long time later. [root@zlm2 :: ~]
#tail monitor.log
.00s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ] [root@zlm2 :: ~]
#tail monitor.log
.00s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ]
.99s [ .50s, .50s, .50s ]
.00s [ .50s, .50s, .50s ] (zlm@192.168.1.102 )[sysbench]>show slave status\G
ERROR (HY000): Lost connection to MySQL server during query
(zlm@192.168.1.102 )[sysbench]>show slave status\G
ERROR (HY000): MySQL server has gone away
No connection. Trying to reconnect...
Connection id:
Current database: sysbench //The slave has hung because of the lack of disk space.
//The delay continuously increasing what can be seen in the logfile on master. # :: server id end_log_pos Table_map: `sysbench`.`hb` mapped to number
# at
# :: server id end_log_pos Update_rows: table id flags: STMT_END_F
### UPDATE `sysbench`.`hb`
### WHERE
### @='2018-07-19T04:31:55.004000' /* VARSTRING(78) meta=78 nullable=0 is_null=0 */
### @= /* INT meta=0 nullable=0 is_null=0 */
### @='mysql-bin.000019' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
### @= /* LONGINT meta=0 nullable=1 is_null=0 */
### @=NULL /* VARSTRING(765) meta=765 nullable=1 is_null=1 */
### @=NULL /* LONGINT meta=0 nullable=1 is_null=1 */
### SET
### @='2018-07-19T04:31:55.004400' /* VARSTRING(78) meta=78 nullable=0 is_null=0 */
### @= /* INT meta=0 nullable=0 is_null=0 */
### @='mysql-bin.000019' /* VARSTRING(765) meta=765 nullable=1 is_null=0 */
### @= /* LONGINT meta=0 nullable=1 is_null=0 */
### @=NULL /* VARSTRING(765) meta=765 nullable=1 is_null=1 */
### @=NULL /* LONGINT meta=0 nullable=1 is_null=1 */
# at
# :: server id end_log_pos Xid =
COMMIT/*!*/; //The output above is the detail of updating heartbeat table "hb" on master.
- pt-heartbeat is rather useful in checking replica lag of MySQL and it also support PostgreSQL.
- pt-heartbeat will read connection options in my.cnf by default if you do not specify them.
- If you've executed the pt-heartbeat with option "--daemonize",don't forget to kill the redundant processes.
- We can retrieve these lag information in heartbeat table using our monitor tool or script.
Percona-Tookit工具包之pt-heartbeat的更多相关文章
- Linux后台开发工具箱
https://files-cdn.cnblogs.com/files/aquester/Linux后台开发工具箱.pdf 目录 目录 1 1. 前言 3 2. 脚本类工具 3 2.1. sed命令- ...
- Mysql: pt-table-checksum 和 pt-table-sync 检查主从一致性,实验过程
一.安装 percona 包 1.安装仓库的包 https://www.percona.com/doc/percona-repo-config/yum-repo.html sudo yum insta ...
- Linux后台开发工具箱-葵花宝典
Linux后台开发工具箱-葵花宝典 一见 2016/11/4 目录 目录 1 1. 前言 4 2. 脚本类工具 4 2.1. 双引号和单引号 4 2.2. 取脚本完整文件路径 5 2.3. 环境变量和 ...
- 推荐几款MySQL相关工具
前言: 随着互联网技术的不断发展, MySQL 相关生态也越来越完善,越来越多的工具涌现出来.一些公司或个人纷纷开源出一些不错的工具,本篇文章主要介绍几款 MySQL 相关实用工具.提醒下,这里并不介 ...
- [知识库分享系列] 二、.NET(ASP.NET)
最近时间又有了新的想法,当我用新的眼光在整理一些很老的知识库时,发现很多东西都已经过时,或者是很基础很零碎的知识点.如果分享出去大家不看倒好,更担心的是会误人子弟,但为了保证此系列的完整,还是选择分享 ...
- SQL慢查询安装过程
SQL慢查询 基本操作 打开防火墙 firewall-cmd --zone=public --add-port=3306/tcp --permanent firewall-cmd --reload 安 ...
- 快速安装Percona pt工具
yum install perl-DBI perl-DBD-MySQL perl-Time-HiRes perl-Time-HiRes perl-IO-Socket-SSLwget http://pk ...
- Percona 工具包 pt-online-schema-change 简介
mysql的在线表结构修改,因为低效和阻塞读写.一直被诟病.至于ALTER TABLE 的原理,参看我上一篇文章.MySQL在线修改大表结构.看完后,发现的问题是还是会锁的,且对于在线更新的这块也是不 ...
- 安装percona工具包
1.安装percona源 sudo yum install http://www.percona.com/downloads/percona-release/redhat/0.1-4/percona- ...
- percona pt toolkit 总结
##=====================================================##pt-osc之工作流程:1.检查更改表是否有主键或唯一索引,是否有触发器2.检查修改表 ...
随机推荐
- Python 看书的一些记录 运算符重载
1.类和模块有什么关系? (1)类是模块的一部分,是模块对象的属性. (2)类和模块都是命名空间,但是类是对于语法的.模块是对于文件的 (3)类支持多个实例,但是模块被导入时只有一个. 2.什么是抽象 ...
- 虚拟内存映射 段分割 vm_area_struct
http://www.cnblogs.com/huxiao-tee/p/4660352.html linux内核使用vm_area_struct结构来表示一个独立的虚拟内存区域,由于每个不同质的虚拟内 ...
- Mysql limit 优化,百万至千万级快速分页,--复合索引的引用并应用于轻量级框架
MySql 性能到底能有多高?用了php半年多,真正如此深入的去思考这个问题还是从前天开始.有过痛苦有过绝望,到现在充满信心!MySql 这个数据库绝对是适合dba级的高手去玩的,一般做一点1万篇新闻 ...
- mac home brew install go
mac利器home brew安装Go 首先你得需要安装home brew和ruby环境(因为home brew依赖ruby) 如果没有请自行到链接安装 准备好之后就开始安装go了 brew updat ...
- 第39章 ETH—Lwip以太网通信—零死角玩转STM32-F429系列
第39章 ETH—Lwip以太网通信 全套200集视频教程和1000页PDF教程请到秉火论坛下载:www.firebbs.cn 野火视频教程优酷观看网址:http://i.youku.com/ ...
- ASP.NET中无刷新分页
上次介绍了我们代码写的刷新分页,这次就来说说无刷新分页. 这次我们是在上次的基础上改动了一些,我们都知道想要无刷新,就需要Ajax,在我们的ASP.NET中AJax是和一般处理程序配合着用的. 无刷新 ...
- js将数字转换成中文
var _change = { ary0:["零", "一", "二", "三", ...
- loss 和accuracy的关系梳理
最近打算总结一下这部分东西,先记录留个脚印.
- java 基础词汇 必须 第九天
Collection 集合 List 列表集合 Set 不重复集合 Linked 链表 Vector 线程安全集合 Hash 哈希值 tree 树型结构 Map 键值对集合 add 增加 remove ...
- LeetCode978. 最长湍流子数组
问题:978. 最长湍流子数组 当 A 的子数组 A[i], A[i+1], ..., A[j] 满足下列条件时,我们称其为湍流子数组: 若 i <= k < j,当 k 为奇数时, A[ ...