MySQL show processlist故障處理
MySQL中遇到問題,我們首先會去看show processlist,如果你的連結數量比較多,阻塞比較多的情況下,一般不太好查源頭,我們還要手工執行一些sql ,才能定位問題,針對一些由於配置導致的MYSQL響應慢問題,也是需要進行一些排查。
myanalyzer.py 這個工具能自動分析執行緒阻塞的原因,並給出建議,能非常方便的快速定位問題,針對對mysql不熟悉的人,也能使用這個工具進行故障處理,排查mysql的當前執行狀態。另外我們在使用show processlist的情況下,如果sql過長,看不到完整的sql,使用這個工具能檢視完整的sql資訊。
python myanalyzer.py --help usage: myanalyzer.py -t 5 -i 192.168.0.0.1 optional arguments: -h, --help show this help message and exit -a ACTION, --action ACTION show or check. -n TOPN, --topn TOPN show topn long query or big transaction record. -t TIME, --time TIME check thread which time greater than t. -i IP, --ip IP server ip. -P PORT, --port PORT server port. -c CONFIG, --config CONFIG read MySQL configuration from. (default: '~/.my.cnf' -s SECTION, --section SECTION read MySQL configuration from this section. (default: '[client]')
示例輸出
python myanalyzer.py -i xxx -P xxx There are no long query,but there are long uncommitted transaction trx_id trx_state trx_started trx_requested_lock_id trx_mysql_thread_id trx_query trx_tables_in_use trx_tables_locked trx_isolation_level user host db info --------------- --------- ------------------- --------------------- ------------------- --------- ----------------- ----------------- ------------------- --------------------------- ------------------- ------------------------- ------ 421553576313088 RUNNING 2021-12-22 09:58:18 <null> 430824 None 0 0 READ COMMITTED xx xx:55057 xxb <null> 421553576049136 RUNNING 2021-12-23 10:41:25 <null> 449170 None 0 0 READ COMMITTED xxx xx:50408 xxx <null> 377122286 RUNNING 2021-12-23 09:00:32 <null> 448342 None 0 1 READ COMMITTED xxx xx:62272 xxx <null> You're about to kill long transaction. Do you want to proceed? (y/n): n kill nothing
python myanalyzer.py -i xxx -P xx mysql looks good!
顯示show processlist
$ python myanalyzer.py -c /Users/xiaoyu.bai/sandboxes/rsandbox_percona-server-5_7_21/master/my.sandbox.cnf -a show ID USER HOST DB COMMAND TIME STATE INFO ROWS_SENT ROWS_EXAMINED -- -------- --------- ------ ------- ---- ---------- ---------------------------------------------- --------- ------------- 2 msandbox localhost test Query 6 User sleep 'select sleep(100) from user limit 1' 0 0 3 msandbox localhost <null> Query 0 executing 'select * from information_schema.processlist' 0 0
顯示阻塞
$ python myanalyzer.py -c /Users/xiaoyu.bai/sandboxes/rsandbox_percona-server-5_7_21/master/my.sandbox.cnf -t 1 id :4 alter table `user` add column sex9 int is waiting for table metadata lock. waiting 31 seconds cause by uncommited transaction or long query,kill long transactions or long query trx_id trx_state trx_started trx_requested_lock_id trx_mysql_thread_id trx_query trx_tables_in_use trx_tables_locked trx_isolation_level user host db info --------------- --------- ------------------- --------------------- ------------------- ------------------------------------- ----------------- ----------------- ------------------- -------- --------- ---- ----------------------------------- 421785610750400 RUNNING 2021-12-23 17:06:56 <null> 59 'select sleep(100) from user limit 1' 1 0 SERIALIZABLE msandbox localhost test select sleep(100) from user limit 1 You're about to kill long transaction. Do you want to proceed? (y/n): y done ID USER HOST DB COMMAND TIME STATE INFO ROWS_SENT ROWS_EXAMINED -- -------- --------- ---- ------- ---- ---------- ------------------------------------- --------- ------------- 59 msandbox localhost test Query 33 User sleep 'select sleep(100) from user limit 1' 0 0 You're about to kill long query select. Do you want to proceed? (y/n): y thread already been killed. done
現實鎖等待
$ python myanalyzer.py -c /Users/xiaoyu.bai/sandboxes/rsandbox_percona-server-5_7_21/master/my.sandbox.cnf -t 1 long sql is executing! id: 70 user: msandbox host: localhost sql is: update user set sex9=1 DML is blocked, waiting info is :: waiting_thread waiting_query waiting_rows_modified waiting_age waiting_wait_secs waiting_user waiting_host waiting_db blocking_thread blocking_query blocking_rows_modified blocking_age blocking_wait_secs blocking_user blocking_host blocking_db -------------- ------------------------------- --------------------- ----------- ----------------- ------------ ------------ ---------- --------------- ------------------------ ---------------------- ------------ ------------------ ------------- ------------- ----------- 4 "update user set username='aa'" 0 4 4 msandbox localhost test 70 'update user set sex9=1' 497191 12 <null> msandbox localhost test trx_id trx_state trx_started trx_requested_lock_id trx_mysql_thread_id trx_query trx_tables_in_use trx_tables_locked trx_isolation_level user host db info ------- --------- ------------------- --------------------- ------------------- ------------------------ ----------------- ----------------- ------------------- -------- --------- ---- ---------------------- 1347463 RUNNING 2021-12-23 17:11:53 <null> 70 'update user set sex9=1' 1 1 SERIALIZABLE msandbox localhost test update user set sex9=1 You're about to kill long transaction. Do you want to proceed? (y/n):
來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/25719946/viewspace-2848951/,如需轉載,請註明出處,否則將追究法律責任。
相關文章
- mysql的show processlistMySql
- mysql show processlist stateMySql
- MySQL 之 show processlist 神器MySql
- mysql show processlist 詳解MySql
- Mysql show processlist 排查問題MySql
- 轉載:mysql的show processlistMySql
- mysql show processlist命令詳解MySql
- 故障分析 | show processlist 引起的效能問題
- MySQL 中 show full processlist 詳解MySql
- MySQL:show processlist Time負數的思考MySql
- MySQL8 show processlist 最佳化MySql
- 12、MySQL Case-show processlist 狀態一直處於Sending to clientMySqlclient
- MySQL調優使用者監控之show processlistMySql
- Mysql故障處理2則MySql
- show processlist time負數的初探
- MySQL show processlist命令詳解及檢視當前連線數MySql
- mysql processlistMySql
- SHOW PROCESSLIST 最多能顯示多長的 SQL?SQL
- 線上MYSQL同步報錯故障處理總結MySql
- MySQL 常見同步複製故障處理方法MySql
- 處理mysql複製故障一例薦MySql
- 【故障處理】一次RAC故障處理過程
- MongoDB故障處理MongoDB
- 故障分析 | Greenplum Segment 故障處理
- 線上MYSQL同步報錯故障處理方法總結MySql
- GPON網路故障如何處理?GPON網路故障處理流程
- 【故障處理】ORA-600:[13013],[5001]故障處理
- 【故障處理】ORA- 2730*,status 12故障分析與處理
- linux故障處理Linux
- ora-故障處理
- MySQL:5.6 大事務show engine innodb status故障一例MySql
- 批量kill mysql processlist程式MySql
- 專案02(Mysql gtid複製故障處理01)MySql
- 線上故障處理手冊
- 微服務的故障處理微服務
- teams登入故障處理
- Oracle更新Opatch故障處理Oracle
- 如何快速處理線上故障