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.检查修改表 ...
随机推荐
- G711格式语音采集/编码/转码/解码/播放
2019-05-01 语音g711格式和AMR格式类似,应用很简单,很多人已经整理过了,收录于此,以备不时之需,用别人现成的足矣,我们的时间应该用来干更有意义的事. 1.PCM to G711 Fas ...
- python title() upper() lower() 以首字母大写的方式显示每个单词/将字符串改为全部大写或全部小写
以首字母大写的方式显示每个单词 [root@chenbj python]# cat name.py #!/usr/bin/env python # _*_ coding:utf-8 _*_ name ...
- HTTP head meta
HTTP(HyperTextTransferProtocol)即超文本传输协议,目前网页传输的的通用协议.HTTP协议采用了请求/响应模型,浏览器或其他客户端发出请求,服务器给与响应.就整个网络资源传 ...
- vs2012或vs2013调试卡 关闭调试卡
以前vs2013就有这个问题.没有解决.今天又装了vs2012.又遇到了.特别郁闷. 今天一定要解决.网上百度了.很久.可能关键字有问题.没有找到好的办法. 找到的办法有.显卡问题.不是管理员运行问题 ...
- python——文件处理
1.文件处理 f = open(file="file01.txt", mode="r", encoding="utf-8") #python ...
- mpvue重构小程序之坑点1
对于最近刚做的项目,想着用框架重新架构一遍,方便以后拓展,毕竟现在拓展方向非常大. 目前主要碰到两个略坑的问题: 1: 关于用户授权信息的按钮,原生是以下方式,使用bindgetuserinfo事件 ...
- 时间复杂度 log n
时间复杂度 O(log n) 意味着什么? 预先知道算法的复杂度是一回事,了解其后的原理是另一件事情. 不管你是计算机科班出身还是想有效解决最优化问题,如果想要用自己的知识解决实际问题,你都必须理解时 ...
- Vim---配置实用的.vimrc文件
配置自己电脑的vim,配置一个根据个人习惯使用的.vimrc文件.我的有以下功能等,读者可以根据自己的 个人喜好去配置自己的vim. 1.自动插入文件头 ,新建C.C++源文件时自动插入表头:包括文件 ...
- 利用Selenium+java实现淘宝自动结算购物车商品(附源代码)
转载请声明原文地址! 本次的主题是利用selenium+java实现结算购买购物车中的商品. 话不多说,本次首先要注意的是谷歌浏览器的版本,浏览器使用的驱动版本,selenium的jar包版本. ...
- MySQL数据库 : 查询语句,连接查询及外键约束
查询指定字段 select 字段1,字段2 from 表名; 消除重复行(重复指的是结果集中的所有完全重复行) select distinct 字段1,字段2.. ...