1. IO層面檢查
查看%util是否接近100%定位是哪個磁盤IO壓力大
# cat /sys/block/sda/queue/scheduler
# cat /etc/sysctl.cnf
4.收集MySQL數據庫基本信息
(1)收集OS基本信息
#pt-summary
(2)查看MySQL統計信息
#pt-mysql-summary --user=root --password=123456 --host=127.0.0.1 --port=3306
(3)查看用戶數據庫的存儲引擎
mysql>select count(*) as cnt,table_schema,engine from information_schema.tables where table_schema not in('mysql','information_schema','PERFORMANCE_SCHEMA') group by table_schema,engine order by cnt desc;
(4)查看所有表的存儲引擎
mysql>select table_schema,table_name,engine,TABLE_ROWS,AVG_ROW_LENGTH,DATA_LENGTH,INDEX_LENGTH from information_schema.tables where table_schema not in('mysql','information_schema','PERFORMANCE_SCHEMA') order by table_schema,TABLE_ROWS desc;
(5)查看線程狀態
mysql> show full processlist;
(6)如果第5步有不少SQL經常能看到,把那些SQL的執行計划也收集下,以及相應表的DDL
mysql> explain select....
mysql> show create table table_name;
mysql> show index from table_name;
(7)提供慢日志統計結果
mysqldumpslow slow.log > slow-stat.log
slow.log文件名改成你真正的慢日志文件名
(8)查看死鎖
監控死鎖
#pt-deadlock-logger--ask-pass --run-time=10 --interval=3 --create-dest-table --dest D=test,t=deadlocks u=root,P=3306,h=127.0.0.1
查看死鎖
mysql>select * from deadlocks\G;
5.檢查主從同步
(1)從庫檢查同步狀態
檢查Slave_IO_Running和Slave_SQL_Running是否都為YES
首先Master_Log_File和Relay_Master_Log_File所指向的文件必須一致。
其次Relay_Log_Pos和Exec_Master_Log_Pos的為止也要一致才行。
(2)主從數據校驗
6.PXC集群檢查
(1)查看Galera集群每個節點狀態
mysql>show status like 'wsrep%';
wsrep_cluster_status狀態為Primary
wsrep_connected為ON
(2)masterha_check_ssh驗證ssh信任登錄是否成功
(3)masterha_check_repl驗證mysql復制是否成功
8.查看日志
mysql> show variables like 'log_error';
#cat mysqlerr.log |grep -i -C 5 ERROR
(2)查看備份日志