網(wǎng)上有很多關(guān)于pos機(jī)具巡檢服務(wù), MySQL 巡檢的知識(shí),也有很多人為大家解答關(guān)于pos機(jī)具巡檢服務(wù)的問(wèn)題,今天pos機(jī)之家(m.afbey.com)為大家整理了關(guān)于這方面的知識(shí),讓我們一起來(lái)看下吧!
本文目錄一覽:
pos機(jī)具巡檢服務(wù)
作者:王向
愛(ài)可生 DBA 團(tuán)隊(duì)成員,負(fù)責(zé)公司 DMP 產(chǎn)品的運(yùn)維和客戶 MySQL 問(wèn)題的處理。擅長(zhǎng)數(shù)據(jù)庫(kù)故障處理。對(duì)數(shù)據(jù)庫(kù)技術(shù)和 python 有著濃厚的興趣。
本文來(lái)源:原創(chuàng)投稿
*愛(ài)可生開(kāi)源社區(qū)出品,原創(chuàng)內(nèi)容未經(jīng)授權(quán)不得隨意使用,轉(zhuǎn)載請(qǐng)聯(lián)系小編并注明來(lái)源。
MySQL巡檢操作系統(tǒng)層面巡檢嘛沒(méi)啥特別的,就直奔主題把。
cpusar -u 10 3 內(nèi)存
sar -r 10 3I/O
sar -b 10 3磁盤
df -h系統(tǒng)基礎(chǔ)信息
當(dāng)然,查看是否使用numa和swap,或是否頻繁交互信息等。還有其他的監(jiān)控項(xiàng)目,這里就不一一贅述了。
操作系統(tǒng)日志除此之外,還需要關(guān)注日志類信息,例如:
tail 200 /var/log/messagesdmesg | tail 200MySQL
MySQL重點(diǎn)參數(shù)的檢查,及主從健康狀態(tài)的巡檢。
重點(diǎn)參數(shù)參數(shù) 參考值 innodb_buffer_pool_size 系統(tǒng)的50%-75% binlog_format ROW sync_binlog 1 innodb_flush_log_at_trx_commit 1 read_only 從庫(kù)ON,主庫(kù)OFF super_read_only 從庫(kù)ON,主庫(kù)OFF log_slave_updates 1 innodb_io_capacity sata/sas硬盤這個(gè)值在200sas raid10: 2000ssd硬盤:8000fusion-io(閃存卡):25,000-50,000 max_connections
MySQL的狀態(tài)\\sshow full processlist;show engine innodb status\\Gshow slave hosts;wait事件
show global status like 'Innodb_buffer_pool_wait_free';show global status like 'Innodb_log_waits';鎖
#表鎖show global status like 'Table_locks_waited';show global status like 'Table_locks_immediate';#行鎖show global status like 'Innodb_row_lock_current_waits';當(dāng)前等待鎖的行鎖數(shù)量show global status like 'Innodb_row_lock_time';請(qǐng)求行鎖總耗時(shí)show global status like 'Innodb_row_lock_time_avg';請(qǐng)求行鎖平均耗時(shí)show global status like 'Innodb_row_lock_time_max';請(qǐng)求行鎖最久耗時(shí)show global status like 'Innodb_row_lock_waits';行鎖發(fā)生次數(shù)#還可以定時(shí)收集INFORMATION_SCHEMA里面的信息:SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCKS; SELECT * FROM INFORMATION_SCHEMA.INNODB_LOCK_WAITS; // MySQL 8.0 中已經(jīng)不再使用,建議觀測(cè) sys 庫(kù)#臨時(shí)表/臨時(shí)文件show global status like 'Created_tmp_disk_tables';show global status like 'Created_tmp_files';#打開(kāi)表/文件數(shù)show global status like 'Open_files';show global status like 'Open_table_definitions';show global status like 'Open_tables';#并發(fā)連接數(shù)show global status like 'Threads_running';show global status like 'Threads_created';show global status like 'Threads_cached';show global status like 'Aborted_clients'; #客戶端沒(méi)有正確關(guān)閉連接導(dǎo)致客戶端終止而中斷的連接數(shù)show global status like 'Aborted_connects';Binlog
# 使用臨時(shí)二進(jìn)制日志緩沖但超過(guò) binlog_cache_size 值并使用臨時(shí)文件show global status like 'Binlog_cache_disk_use'; # 使用臨時(shí)二進(jìn)制日志緩沖的事務(wù)數(shù)量show global status like 'Binlog_cache_use'; # 當(dāng)非事務(wù)語(yǔ)句使用二進(jìn)制日志緩存show global status like 'Binlog_stmt_cache_disk_use'; # 使用二進(jìn)制日志緩沖非事務(wù)語(yǔ)句數(shù)量show global status like 'Binlog_cache_disk_use'; 鏈接數(shù)
# 試圖連接到(不管成不成功)mysql服務(wù)器的鏈接數(shù)show global status like 'Connection'; 臨時(shí)表
# 服務(wù)器執(zhí)行語(yǔ)句時(shí),在硬盤上自動(dòng)創(chuàng)建的臨時(shí)表的數(shù)量,是指在排序時(shí),內(nèi)存不夠用(tmp_table_size小于需要排序的結(jié)果集),所以需要?jiǎng)?chuàng)建基于磁盤的臨時(shí)表進(jìn)行排序show global status like 'Created_tmp_disk_tables'; # 服務(wù)器執(zhí)行語(yǔ)句時(shí)自動(dòng)創(chuàng)建的內(nèi)存中的臨時(shí)表的數(shù)量show global status like 'Created_tmp_files';索引
# 內(nèi)部提交語(yǔ)句show global status like 'Handler_commit'; # 內(nèi)部 rollback語(yǔ)句數(shù)量show global status like 'Handler_rollback'; # 索引第一條記錄被讀的次數(shù),如果高,則它表明服務(wù)器正執(zhí)行大量全索引掃描show global status like 'Handler_read_first'; # 根據(jù)索引讀一行的請(qǐng)求數(shù),如果較高,說(shuō)明查詢和表的索引正確show global status like 'Handler_read_key'; # 查詢讀索引最后一個(gè)索引鍵請(qǐng)求數(shù)show global status like 'Handler_read_last';# 按照索引順序讀下一行的請(qǐng)求數(shù)show global status like 'Handler_read_next'; # 按照索引順序讀前一行的請(qǐng)求數(shù)show global status like 'Handler_read_prev';# 根據(jù)固定位置讀一行的請(qǐng)求數(shù),如果值較高,說(shuō)明可能使用了大量需要mysql掃整個(gè)表的查詢或沒(méi)有正確使用索引show global status like 'Handler_read_rnd'; # 在數(shù)據(jù)文件中讀下一行的請(qǐng)求數(shù),如果你正進(jìn)行大量的表掃,該值會(huì)較高show global status like 'Handler_read_rnd_next'; # 被緩存的.frm文件數(shù)量show global status like 'Open_table_definitions'; # 已經(jīng)打開(kāi)的表的數(shù)量,如果較大,table_open_cache值可能太小show global status like 'Opened_tables';# 當(dāng)前打開(kāi)的表的數(shù)量show global status like 'Open_tables';# 已經(jīng)發(fā)送給服務(wù)器的查詢個(gè)數(shù)show global status like 'Queries';# 沒(méi)有使用索引的聯(lián)接的數(shù)量,如果該值不為0,你應(yīng)該仔細(xì)檢查表的所有show global status like 'Select_full_join';# 對(duì)第一個(gè)表進(jìn)行完全掃的聯(lián)接的數(shù)量show global status like 'Select_scan';# 查詢時(shí)間超過(guò)long_query_time秒的查詢個(gè)數(shù)show global status like 'Slow_queries';# 排序算法已經(jīng)執(zhí)行的合并的數(shù)量,如果值較大,增加sort_buffer_size大小show global status like 'Sort_merge_passes';線程
# 線程緩存內(nèi)的線程數(shù)量show global status like 'Threads_cached';# 當(dāng)前打開(kāi)的連接數(shù)量show global status like 'Threads_connected';# 創(chuàng)建用來(lái)處理連接的線程數(shù)show global status like 'Threads_created';# 激活的(非睡眠狀態(tài))線程數(shù)show global status like 'Threads_running';庫(kù)表情況自增id使用情況
SELECTtable_schema,table_name,ENGINE,Auto_increment FROMinformation_schema.TABLES WHERETABLE_SCHEMA NOT IN ("INFORMATION_SCHEMA","PERFORMANCE_SCHEMA","MYSQL","SYS") limit 30;表行數(shù)數(shù)據(jù)大小統(tǒng)計(jì)
SELECTtable_schema "Database name",sum( table_rows ) "No. of rows",sum( data_length ) / 1024 / 1024 "Size data (MB)",sum( index_length )/ 1024 / 1024 "Size index (MB)" FROMinformation_schema.TABLES GROUP BYtable_schema;表行數(shù) TOP 30
SELECT TABLE_SCHEMA, TABLE_NAME, TABLE_ROWSFROM `information_schema`.`tables` WHERE TABLE_SCHEMA not in('information_schema','sys','mysql','performance_schema')ORDER BY table_rows DESC LIMIT 30;存儲(chǔ)引擎不是innodb的表
SELECTTABLE_SCHEMA,TABLE_NAME,ENGINE FROMINFORMATION_SCHEMA.TABLES WHEREENGINE != 'innodb' AND TABLE_SCHEMA NOT IN ( "INFORMATION_SCHEMA", "PERFORMANCE_SCHEMA", "MYSQL", "SYS" );表數(shù)據(jù)和碎片 TOP 30
select TABLE_SCHEMA, TABLE_NAME, TABLE_ROWS, DATA_LENGTH, INDEX_LENGTH, DATA_FREEfrom information_schema.tables where DATA_FREE is not null ORDER BY DATA_FREE DESC LIMIT 30;無(wú)主鍵的表
SELECTt1.table_schema,t1.table_name,t1.table_type FROMinformation_schema.TABLES t1LEFT OUTER JOIN information_schema.TABLE_CONSTRAINTS t2 ON t1.table_schema = t2.TABLE_SCHEMA AND t1.table_name = t2.TABLE_NAME AND t2.CONSTRAINT_NAME IN ( 'PRIMARY' ) WHEREt2.table_name IS NULL AND t1.TABLE_SCHEMA NOT IN ( 'information_schema', 'performance_schema', 'test', 'mysql', 'sys' ) AND t1.table_type = "BASE TABLE";MySQL主從檢測(cè)
#主從狀態(tài)show slave status\\G#主從是否延遲Master_Log_File == Relay_Master_Log_File && Read_Master_Log_Pos == Exec_Master_Log_Pos高可用層面
MHA && keepalived
觀察日志看是否有頻繁主從切換,如果有的話就分析一下是什么原因?qū)е骂l繁切換?
中間件的巡檢mycat && proxysql
這些中間件的巡檢,首先參考系統(tǒng)巡檢,再看一下中間件本身的日志類和狀態(tài)類信息,網(wǎng)絡(luò)延遲或丟包的檢查,也是必須要做工作。
以上就是關(guān)于pos機(jī)具巡檢服務(wù), MySQL 巡檢的知識(shí),后面我們會(huì)繼續(xù)為大家整理關(guān)于pos機(jī)具巡檢服務(wù)的知識(shí),希望能夠幫助到大家!
