pt工具介绍
Percona Toolkit简称pt工具,是Percona公司开发用于管理MySQL的工具,功能包括检查主从复制的数据一致性、检查重复索引、定位IO占用高的表文件、在线DDL等,DBA熟悉掌握后将极大提高工作效率。
CentOS 7下安装
[root@testdb_172_16_123_101 /root]# yum -y install https://www.percona.com/downloads/percona-toolkit/3.0.1/binary/redhat/7/x86_64/percona-toolkit-3.0.1-1.el7.x86_64.rpm
pt-ioprofile的使用
这个工具可以定位哪个文件IO占用比较高
其原理是对某个pid附加一个strace进程进行IO分析, --profile-pid指定pid, --cell=sizes,该参数将结果已 B/s 的方式展示出来。
[root@testdb_172_16_123_101 /root]# yum -y install strace [root@testdb_172_16_123_101 /root]# ps aux | grep mysqld mysql 1962 0.2 21.6 1068008 204420 pts/0 Sl 14:41 0:33 /usr/local/mysql/bin/mysqld --defaults-file=/data/mysql/mysql_3306/my.cnf root 39205 0.0 0.1 112652 968 pts/0 R+ 18:23 0:00 grep --color=auto mysqld [root@testdb_172_16_123_101 /root]# pt-ioprofile --profile-pid=1962 --cell=sizes Mon Apr 10 18:24:00 CST 2017 Tracing process ID 1962 total read pwrite write fsync open close lseek ftruncate filename 4763136 0 4763136 0 0 0 0 0 0 /data/mysql/mysql_3306/data/ib_logfile0 4751360 0 163840 0 0 0 0 4587520 0 /data/mysql/mysql_3306/data/db_3306/t1.ibd 1585066 0 0 1585066 0 0 0 0 0 /data/mysql/mysql_3306/bin_logs/mysql-bin.000009 802816 0 802816 0 0 0 0 0 0 /data/mysql/mysql_3306/data/ibdata1 144160 144160 0 0 0 0 0 0 0 /dev/urandom 15508 0 0 7754 0 0 0 7754 0 /data/mysql/mysql_3306/data/innodb_status.1962 0 0 0 0 0 0 0 0 0 /data/mysql/mysql_3306/undo_logs/undo003 0 0 0 0 0 0 0 0 0 /data/mysql/mysql_3306/undo_logs/undo002 0 0 0 0 0 0 0 0 0 /data/mysql/mysql_3306/undo_logs/undo001 0 0 0 0 0 0 0 0 0 /data/mysql/mysql_3306/tmp/ibo5OEql