天天看點

通過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()

繼續閱讀