Percona-Toolkit 之 pt-pmp
pt-pmp 有两个方便的作用:一是获取进程的堆栈信息,二是对堆栈信息进行汇总。
进程的堆栈信息是通过gdb获取的,所以在获取过程中,会对mysql服务端的性能有一定的影响。
pt-pmp脚本本身是用shell写的,用法也比较简单,唯一的要求是服务器上已安装gdb包。
pt-pmp 参数:
[root@hankyoon ~ ]# pt-pmp --help Usage: pt-pmp [OPTIONS] [FILES] For more information, 'man pt-pmp' or 'perldoc /usr/bin/pt-pmp'. Command line options: --binary Which binary to trace. 指定分析的进程名,如果不指定,默认就是mysqld --help Show help and exit. 帮助 --interval Number of seconds to sleep between L<"--iterations">. 迭代时间之间的时间间隔 --iterations How many traces to gather and aggregate. 执行gdb命令的次数 --lines Aggregate only first specified number of many functions; 指定打印汇总后每一个分类中的头几个函数 0=infinity. --pid Process ID of the process to trace; overrides L<"--binary">.指定进程的pid --save-samples Keep the raw traces in this file after aggregation. 是否将gdb获取的堆栈信息保存在文件中(注意,没有汇总) --version Show version and exit. Options and values after processing arguments: --binary mysqld --help TRUE --interval 0 --iterations 1 --lines 0 --pid (No value) --save-samples (No value) --version FALSE
用法:
1. 汇总pstack获取的结果 # ps -ef | grep mysqld # pstack 7777 > 7777.info # pt-pmp 7777.info 2. 直接根据进程名汇总堆栈信息 # pt-pmp --binary mysqld 3. 上述命令只是一次迭代的结果,如果要迭代多次,且每次相隔1s,可指定如下: # pt-pmp --binary mysqld --iterations 2 --interval 1 4. 如果要同时保留汇总前的堆栈信息,可指定--save-samples参数 # pt-pmp --binary sshd --save-samples sshd.txt
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· winform 绘制太阳,地球,月球 运作规律
· AI与.NET技术实操系列(五):向量存储与相似性搜索在 .NET 中的实现
· 超详细:普通电脑也行Windows部署deepseek R1训练数据并当服务器共享给他人
· 上周热点回顾(3.3-3.9)
· AI 智能体引爆开源社区「GitHub 热点速览」