死鎖詳情查詢
SELECT SUM(trx_rows_locked) AS rows_locked, SUM(trx_rows_modified) AS rows_modified, SUM(trx_lock_memory_bytes) AS lock_memory FROM information_schema.INNODB_TRX;
navicat實時查詢
show OPEN TABLES where In_use > 0; SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; show processlist
將死鎖語句導出
mysql -uroot -p -e "show engine innodb status \G;" > /tmp/lock-`date +%F_%T`.txt cat /tmp/lock.txt|grep -i -n lock cat /tmp/lock.txt|grep -i -n "LATEST DETECTED DEADLOCK" 在打印出來的信息中找到“LATEST DETECTED DEADLOCK”一節內容
注意:如果死鎖時間距離現在太遠,並且Buffer pool hit rate正常就可以忽略
cat /tmp/lock.txt|grep -i -n "hit"
330:Buffer pool hit rate 1000 / 1000, young-making rate 0 / 1000 not 0 / 1000
