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 processlist 神器MySql
- 故障分析 | show processlist 引起的效能問題
- MySQL:show processlist Time負數的思考MySql
- MySQL8 show processlist 最佳化MySql
- 12、MySQL Case-show processlist 狀態一直處於Sending to clientMySqlclient
- MySQL調優使用者監控之show processlistMySql
- show processlist time負數的初探
- 【故障處理】ORA-600:[13013],[5001]故障處理
- SHOW PROCESSLIST 最多能顯示多長的 SQL?SQL
- linux故障處理Linux
- 故障分析 | Greenplum Segment 故障處理
- 專案02(Mysql gtid複製故障處理01)MySql
- GPON網路故障如何處理?GPON網路故障處理流程
- MySQL:5.6 大事務show engine innodb status故障一例MySql
- 線上MYSQL同步報錯故障處理方法總結MySql
- 微服務的故障處理微服務
- Oracle更新Opatch故障處理Oracle
- teams登入故障處理
- 線上故障處理手冊
- 記一次一波三折的Mysql故障處理MySql
- 【故障處理】TNS-04610問題
- GaussDB(分散式)例項故障處理分散式
- Oracle 10g RAC故障處理Oracle 10g
- ORA-01591錯誤故障處理
- 如何處理HTTP 503故障問題?HTTP
- Oracle 11.2.0.4 Dataguard兩則故障處理Oracle
- 資料庫故障處理優質文章彙總(含Oracle、MySQL、MogDB等)資料庫OracleMySql
- 故障分析 | MySQL convert 函式導致的字符集報錯處理MySql函式
- mysql 1129處理MySql
- hbase 故障的處理方案。 (轉載文章)
- Oracle DG同步失敗故障處理(二)Oracle
- NO.A.0001——zabbix常見故障的處理
- 體檢伺服器nginx故障處理伺服器Nginx
- Oracle client安裝the jre is 0故障處理Oracleclient
- 生產環境故障處理演練-mysql資料庫主從恢復MySql資料庫
- MySQL事務處理MySql
- MySQL 併發處理MySql
- 【故障處理】ORA-3113 "end of file on communication channel"