天天看点

通过iotop与performance_schema.threads查看mysql的IO使用情况

1.安装iotop,yum install iotop

2.iotop查看mysql进程里的各运行线程:

iotop -u mysql ##-u mysql查询用户mysql运行的对应程序

通过iotop与performance_schema.threads查看mysql的IO使用情况

这边可以看到,虽然mysql是单进程实例,但是在运行过程中会产生很多线程。在某些卡顿的情况下,可以使用该命令查看哪个线程读写速率比较大

3.结合iotop查看到的线程号,查询performance_schema中的threads表,看一下是哪个线程占用较大的io

通过iotop与performance_schema.threads查看mysql的IO使用情况

4.查看对应操作系统线程号与mysql哪个功能线程对应

select name,type,thread_id,thread_os_id from threads;

通过iotop与performance_schema.threads查看mysql的IO使用情况

type字段中BACKGROUND表示后台线程,FOREGROUND表示前端线程,如连接线程等

5.查看processlist_id

select name,thread_id,thread_os_id,processlist_id from threads;

对应show processlist

通过iotop与performance_schema.threads查看mysql的IO使用情况

查看当前连接:select connection_id()

继续阅读