前往小程序,Get更优阅读体验!
立即前往
首页
学习
活动
专区
工具
TVP
发布
社区首页 >专栏 >percona-toolkit学习笔记(七)

percona-toolkit学习笔记(七)

作者头像
保持热爱奔赴山海
发布2019-09-18 14:45:23
4270
发布2019-09-18 14:45:23
举报
文章被收录于专栏:数据库相关数据库相关

pt-fifo-split

功能:

模拟切割文件并通过管道传递给先入先出队列而不用真正的切割文件

说明:

    pt-fifo-split读取大文件中的数据并打印到fifo文件,每次达到指定行数就往fifo文件中打印一个EOF字符,读取完成以后,关闭掉fifo文件并移走,然后重建fifo文件,打印更多的行。这样可以保证你每次读取的时候都能读取到制定的行数直到读取完成。注意此工具只能工作在类unix操作系统。这个程序对大文件的数据导入数据库非常有用,具体参考:https://www.percona.com/blog/2008/07/03/how-to-load-large-files-safely-into-innodb-with-load-data-infile/

实例:

一次读取100行记录

    pt-fifo-split--lines 100 /root/all.sql

    while[ -e /tmp/pt-fifo-split ]; do cat /tmp/pt-fifo-split; done

pt-find

功能:Find MySQL tables and executeactions, like GNU find

说明:

    pt-findsearches for MySQL tables and executes actions, like GNU find.  The default action is to print the databaseand table name.

实例:

pt-find --ctime -1 --engine MyISAM-uroot -proot -h localhost  # 列出创建时间小于1天且使用MyISAM引擎的数据表

pt-find --engine InnoDB -uroot-proot -h localhost              # 列出InnoDB引擎的表

pt-find --ctime -1 -uroot -proot-h localhost --exec-plus "drop table %s"  # 将找到的符合条件的table删除掉

pt-find --tablesize +500M -uroot-proot -h localhost               # 列出总大小超过500M的表

pt-find hellodb -uroot -proot -hlocalhost       # 列出hellodb库里的所有表

pt-find --printf"%T\t%D.%N\n"  -uroot -proot -hlocalhost | sort -rn # 列出所有表的total data and index size,并从大到小排序

pt-fingerprint

功能:Convert queries into fingerprints.

用于生成查询指纹。主要将将sql查询生成queryID,pt-query-digest中的ID即是通过此工具来完成的。 类似于Oracle中的SQL_ID,涉及绑定变量,字面量等

说明:

    pt-findsearches for MySQL tables and executes actions, like GNU find.  The default action is to print the databaseand table name.

实例:

    #pt-fingerprint --query "select a,b,c from hellodb.students wherestuid=22"

pt-ioprofile

功能:pt-ioprofile的原理是对某个pid附加一个strace进程进行IO分析

    pt-ioprofileuses "strace" and "lsof" to watch a process’s IO and printout a table of files and I/O activity. By default, it watches the mysqld process for 30 seconds.

pt-kill

功能:Kill掉符合指定条件mysql语句

官方示例:

Kill queries runninglonger than 60s:

# pt-kill --busy-time 60 --kill

Print, do not kill,queries running longer than 60s:

# pt-kill --busy-time 60 --print

Check for sleepingprocesses and kill them all every 10s:

# pt-kill --match-command Sleep--kill --victims all --interval 10

Print all loginprocesses:

# pt-kill --match-state login--print --victims all

See which queries inthe processlist right now would match:

# mysql -e "SHOWPROCESSLIST" > proclist.txt

# pt-kill --test-matchingproclist.txt --busy-time 60 --print

pt-stalk

功能:用于收集mysql数据库故障时的相关信息便于后续诊断处理。Collect forensic data about MySQLwhen problems occur

pt-stalk等待触发条件触发,然后收集数据帮助错误诊断,它被设计成使用root权限运行的守护进程,因此你可以诊断那些你不能直接观察的间歇性问题。默认的诊断触发条件为SHOW GLOBAL STATUS。也可以指定processlist为诊断触发条件,使用--function参数指定。

范例1:指定诊断触发条件为status,同时运行语句超过20的时候触发,收集的数据存放在/tmp/test目录下:

# pt-stalk  --function status \

--variable Threads_running--threshold 20 \

--dest /tmp/test -- -uroot -proot -h192.168.2.11

范例2:指定诊断触发条件为processlist,超过20个状态为statistics触发,收集的数据存放在/tmp/test目录下:

# pt-stalk  --function processlist \

--variable State --matchstatistics --threshold 20 \

--dest /tmp/test -- -uroot -proot -h192.168.2.11

本文参与 腾讯云自媒体同步曝光计划,分享自作者个人站点/博客。
原始发表:2016/05/11 ,如有侵权请联系 cloudcommunity@tencent.com 删除

本文分享自 作者个人站点/博客 前往查看

如有侵权,请联系 cloudcommunity@tencent.com 删除。

本文参与 腾讯云自媒体同步曝光计划  ,欢迎热爱写作的你一起参与!

评论
登录后参与评论
0 条评论
热度
最新
推荐阅读
目录
  • pt-fifo-split
  • pt-find
  • pt-fingerprint
  • pt-ioprofile
  • pt-kill
  • pt-stalk
相关产品与服务
云数据库 SQL Server
腾讯云数据库 SQL Server (TencentDB for SQL Server)是业界最常用的商用数据库之一,对基于 Windows 架构的应用程序具有完美的支持。TencentDB for SQL Server 拥有微软正版授权,可持续为用户提供最新的功能,避免未授权使用软件的风险。具有即开即用、稳定可靠、安全运行、弹性扩缩等特点。
领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档