新聞中心
1、
我們提供的服務(wù)有:做網(wǎng)站、成都網(wǎng)站建設(shè)、微信公眾號(hào)開發(fā)、網(wǎng)站優(yōu)化、網(wǎng)站認(rèn)證、天峻ssl等。為上1000家企事業(yè)單位解決了網(wǎng)站和推廣的問題。提供周到的售前咨詢和貼心的售后服務(wù),是有科學(xué)管理、有技術(shù)的天峻網(wǎng)站制作公司
Aborted_clients 由于客戶沒有正確關(guān)閉連接已經(jīng)死掉,已經(jīng)放棄的連接數(shù)量。(做監(jiān)控)
????表示客戶端沒有正確的關(guān)閉連接,而被終止的連接數(shù),引起的原因 ????1.客戶端程序退出之前未調(diào)用MySQL_close()來關(guān)閉mysql連接 ????2.客戶端的休眠時(shí)間超過了mysql系統(tǒng)變量wait_timeout和interactive_timeout的值,導(dǎo)致連接被mysql進(jìn)程終止 ????3.客戶端程序在數(shù)據(jù)傳輸過程中突然結(jié)束
2、
Aborted_connects 嘗試已經(jīng)失敗的MySQL服務(wù)器的連接的次數(shù)。(做監(jiān)控)
????表示嘗試連接到mysql服務(wù)器的失敗次數(shù),可以結(jié)合host_cache來分析問題,引起的原因: ????1.密碼錯(cuò)誤?? ????2.沒權(quán)限訪問,但是嘗試去訪問 ????3.連接超時(shí) ????4.連接信息不正確
如果碰到連接超時(shí)等信息一定要分析一下是什么原因引起的
在MySQL服務(wù)器使用tcpdump抓包
[root@lichao ~]#?tcpdump -i eth0??port 3306??-s 1500 -w tcpdump.log
然后在另外一臺(tái)MySQL服務(wù)器,使用不存在的賬號(hào)或錯(cuò)誤的密碼訪問MySQL數(shù)據(jù)庫
# mysql -h xx.xx.xx.xx -u xxx? -pxxxx
ERROR 1045 (28000): Access denied for user 'xxx'@'xx.xx.xx.xxx' (using password: YES)
# mysql -h xx.xx.xx.xx -u xxxx -pxxx
ERROR 1045 (28000): Access denied for user 'test'@'xx.xx.xx.xx' (using password: YES)
[root@lichao~]#
?
執(zhí)行完命令后,你可以使用CTRL + C結(jié)束抓包分析,然后查看分析。如下截圖所示:
?
[root@lichao ~]# tcpdump -i eth0??port 3306??-s 1500 -w tcpdump.log
tcpdump: listening on eth0, link-type EN10MB (Ethernet), capture size 1500 bytes
28 packets captured
28 packets received by filter
0 packets dropped by kernel
[root@lichao ~]# strings tcpdump.log
3、
Binlog_cache_disk_use表示因?yàn)槲覀僢inlog_cache_size設(shè)計(jì)的內(nèi)存不足導(dǎo)致緩存二進(jìn)制日志用到了臨時(shí)文件的次數(shù)(做監(jiān)控)
4、
Binlog_cache_use? 表示 用binlog_cache_size緩存的次數(shù)
當(dāng)對應(yīng)的Binlog_cache_disk_use 值比較大的時(shí)候 我們可以考慮適當(dāng)?shù)恼{(diào)高 binlog_cache_size 對應(yīng)的值
沒有什么大事務(wù),dml也不是很頻繁的情況下可以設(shè)置小一點(diǎn),如果事務(wù)大而且多,dml操作也頻繁,則可以適當(dāng)?shù)恼{(diào)大一點(diǎn)。
前者建議是1048576? --1M
后者建議是: 2097152 -- 4194304? 即 2--4M
查看方式:show global status like 'bin%';
注意:
(1)max_binlog_cache_size 表示的是binlog 能夠使用的最大cache 內(nèi)存大小
當(dāng)我們執(zhí)行多語句事務(wù)的時(shí)候 所有session的使用的內(nèi)存超過max_binlog_cache_size的值時(shí)
就會(huì)報(bào)錯(cuò):“Multi-statement transaction required more than 'max_binlog_cache_size' bytes ofstorage”
(2)設(shè)置太大的話,會(huì)比較消耗內(nèi)存資源;設(shè)置太小又會(huì)使用到臨時(shí)文件即disk
調(diào)整方式(兩種辦法):
(1)配置文件設(shè)置my.cnf
binlog_cache_size?=?1M
(2)set global binlog_cache_size = 1048576
解釋:
show status like '%binlog%';
stmt就是statement的意思
Binlog_cache_disk_use ?。ㄊ聞?wù)類)二進(jìn)志日志緩存的已經(jīng)存在硬盤的條數(shù)?
Binlog_cache_use (事務(wù)類)二進(jìn)制日志已緩存的條數(shù)(內(nèi)存中) ? ?注意,這個(gè)不是容量,而是事務(wù)個(gè)數(shù)。每次有一條事務(wù)提交,都會(huì)有一次增加
Binlog_stmt_cache_disk_use ?(非事務(wù)類)二進(jìn)志日志緩存的已經(jīng)存在硬盤的條數(shù) ?
Binlog_stmt_cache_use??(非事務(wù)類)二進(jìn)制日志已緩存的條數(shù)(內(nèi)存中)?非事務(wù)型的語句,都存在這兒,比如MYISAM引擎的表,插入記錄就存在這兒
參數(shù)衍生:
binlog_cache_use和binlog_cache_disk_use兩者結(jié)合可以用來調(diào)整binlog_cache_size的大小
binglog_stmt_cache_use和binlog_stmt_cache_disk_use兩者結(jié)合可以有來調(diào)整 binlog_stmt_cache_size的大小
5、
Bytes_received/Bytes_sent(做監(jiān)控)
看 mysql總的吞吐量
Bytes_received
從所有客戶端接收到的字節(jié)數(shù)。結(jié)合bytes sent, 可以作為數(shù)據(jù)庫網(wǎng)卡吞吐量的評測指標(biāo),單位字節(jié)
Bytes_sent
發(fā)送給所有客戶端的字節(jié)數(shù)。結(jié)合bytes received,可以作為數(shù)據(jù)庫網(wǎng)卡吞吐量的評測指標(biāo),單位字節(jié)
6、
Com_admin_commands [ Com_xxx ]
Com_xxx 語句計(jì)數(shù)變量表示每個(gè)xxx 語句執(zhí)行的次數(shù)。每類語句有一個(gè)狀態(tài)變量。例如,Com_delete和Com_insert分別統(tǒng)計(jì)DELETE 和INSERT語句執(zhí)行的次數(shù)。
Com_xxx包括:
Com_alter_db
Com_alter_db_upgrade
Com_alter_event
Com_alter_function
Com_alter_procedure
Com_alter_server
Com_alter_table
Com_alter_tablespace
Com_analyze
Com_assign_to_keycache
Com_begin
Com_binlog
Com_call_procedure
Com_change_db
Com_change_master
Com_check
Com_checksum
Com_commit??MySQL提交的事務(wù)數(shù)量,可以用來統(tǒng)計(jì)TPS(每秒事務(wù)數(shù)),計(jì)算公式:Com_commit/S+Com_rollback/S(做監(jiān)控)
Com_create_db
Com_create_event
Com_create_function
Com_create_index
Com_create_procedure-------創(chuàng)建存儲(chǔ)過程個(gè)數(shù)(監(jiān)控)
Com_create_server
Com_create_table--------創(chuàng)建數(shù)據(jù)表個(gè)數(shù)(監(jiān)控)
Com_create_trigger
Com_create_udf
Com_create_user
Com_create_view
Com_dealloc_sql
Com_delete??MySQL刪除的數(shù)量,可以用來統(tǒng)計(jì)qps,計(jì)算公式:questions / uptime 或者基于com_%計(jì)算:Com_select/s + Com_insert/s + Com_update/s + Com_delete/s(做監(jiān)控)
Com_delete_multi
Com_do
Com_drop_db? ? (做監(jiān)控)
Com_drop_event
Com_drop_function
Com_drop_index
Com_drop_procedure
Com_drop_server
Com_drop_table(做監(jiān)控)
Com_drop_trigger
Com_drop_user
Com_drop_view
Com_empty_query
Com_execute_sql
Com_flush
Com_grant(做監(jiān)控)
Com_ha_close
Com_ha_open
Com_ha_read
Com_help
Com_insert?MySQL插入的數(shù)量,可以用來統(tǒng)計(jì)qps,qps計(jì)算公式:questions / uptime 或者基于com_%計(jì)算:Com_select/s + Com_insert/s + Com_update/s + Com_delete/s (做監(jiān)控)
Com_insert_select
Com_install_plugin
Com_kill
Com_load
Com_lock_tables------鎖表lock tables,解鎖命令unlock tables
Com_optimize
Com_preload_keys
Com_prepare_sql
Com_purge
Com_purge_before_date
Com_release_savepoint
Com_rename_table
Com_rename_user
Com_repair
Com_replace
Com_replace_select
Com_reset
Com_resignal
Com_revoke
Com_revoke_all
Com_rollback??MySQL回滾的事務(wù)數(shù)量,可以用來統(tǒng)計(jì)TPS(每秒事務(wù)數(shù)),計(jì)算公式:Com_commit/S+Com_rollback/S (監(jiān)控)
Com_rollback_to_savepoint
Com_savepoint
Com_select
Com_set_option
Com_show_authors
Com_show_binlog_events
Com_show_binlogs
Com_show_charsets
Com_show_collations
Com_show_contributors
Com_show_create_db
Com_show_create_event
Com_show_create_func
Com_show_create_proc
Com_show_create_table
Com_show_create_trigger
Com_show_databases----執(zhí)行show databases次數(shù)(監(jiān)控)
Com_show_engine_logs
Com_show_engine_mutex
Com_show_engine_status
Com_show_errors
Com_show_events
Com_show_fields
Com_show_function_code
Com_show_function_status
Com_show_grants
Com_show_keys
Com_show_logs
Com_show_master_status
Com_show_new_master
Com_show_open_tables
Com_show_plugins
Com_show_privileges
Com_show_procedure_code
Com_show_procedure_status
Com_show_processlist
Com_show_profile
Com_show_profiles
Com_show_relaylog_events
Com_show_slave_hosts
Com_show_slave_status
Com_show_status
Com_show_storage_engines
Com_show_table_status
Com_show_tables
Com_show_triggers
Com_show_variables
Com_show_warnings
Com_signal
Com_slave_start
Com_slave_stop
Com_stmt_close
Com_stmt_execute
Com_stmt_fetch
Com_stmt_prepare
Com_stmt_reprepare
Com_stmt_reset
Com_stmt_send_long_data
Com_truncate? (監(jiān)控)
Com_uninstall_plugin
Com_unlock_tables(監(jiān)控1)
Com_update??MySQL更新的數(shù)量,可以用來統(tǒng)計(jì)qps,qps計(jì)算公式:questions / uptime 或者基于com_%計(jì)算:Com_select/s + Com_insert/s + Com_update/s + Com_delete/s(監(jiān)控)
Com_update_multi
Com_xa_commit
Com_xa_end
Com_xa_prepare
Com_xa_recover
Com_xa_rollback
Com_xa_start
7、
Connections 試圖連接MySQL服務(wù)器的次數(shù)。
8、
Created_tmp_tables 當(dāng)執(zhí)行語句時(shí),已經(jīng)被創(chuàng)造了的隱含臨時(shí)表的數(shù)量。
Created_tmp_disk_tables
關(guān)于這兩個(gè)值是:
? ? ? ? mysql> show global status like 'created_tmp%';
? ? ? ? +-------------------------+---------+
? ? ? ? | Variable_name????????????| Value????|
? ? ? ? +-------------------------+---------+
? ? ? ? | Created_tmp_disk_tables | 21197????|
? ? ? ? | Created_tmp_files????????| 58???????|
? ? ? ? | Created_tmp_tables???????| 1771587 |
? ? ? ? +-------------------------+---------+
每次創(chuàng)建臨時(shí)表,Created_tmp_tables增加,如果是在磁盤上創(chuàng)建臨時(shí)表,Created_tmp_disk_tables也增加,Created_tmp_files表示MySQL服務(wù)創(chuàng)建的臨時(shí)文件文件數(shù),比較理想的配置是:
? ? ? ? Created_tmp_disk_tables / Created_tmp_tables * 100% <= 25%
比如上面的服務(wù)器Created_tmp_disk_tables / Created_tmp_tables * 100% = 1.20%,應(yīng)該相當(dāng)好了。我們再看一下MySQL服務(wù)器對臨時(shí)表的配置:
? ? ? ? mysql> show variables where Variable_name in ('tmp_table_size', 'max_heap_table_size');
? ? ? ? +---------------------+-----------+
? ? ? ? | Variable_name????????| Value??????|
? ? ? ? +---------------------+-----------+
? ? ? ? | max_heap_table_size | 268435456 |
? ? ? ? | tmp_table_size???????| 536870912 |
? ? ? ? +---------------------+-----------+
只有256MB以下的臨時(shí)表才能全部放內(nèi)存,超過的就會(huì)用到硬盤臨時(shí)表。
9、
Delayed_insert_threads 正在使用的延遲插入處理器線程的數(shù)量。
Delayed_writes 用INSERT DELAYED寫入的行數(shù)。
Delayed_errors 用INSERT DELAYED寫入的發(fā)生某些錯(cuò)誤(可能重復(fù)鍵值)的行數(shù)。
10、
Flush_commands 執(zhí)行FLUSH命令的次數(shù) (監(jiān)控)
11、
Handler_delete 請求從一張表中刪除行的次數(shù)。(監(jiān)控)
Handler_read_first 請求讀入表中第一行的次數(shù)。
Handler_read_key 請求數(shù)字基于鍵讀行。
Handler_read_next 請求讀入基于一個(gè)鍵的一行的次數(shù)。
Handler_read_rnd 請求讀入基于一個(gè)固定位置的一行的次數(shù)。
Handler_update 請求更新表中一行的次數(shù)。(監(jiān)控)
Handler_write 請求向表中插入一行的次數(shù)。(監(jiān)控)
12、
Key_blocks_used 用于關(guān)鍵字緩存的塊的數(shù)量。
Key_read_requests 請求從緩存讀入一個(gè)鍵值的次數(shù)。
Key_reads 從磁盤物理讀入一個(gè)鍵值的次數(shù)。(監(jiān)控)
Key_write_requests 請求將一個(gè)關(guān)鍵字塊寫入緩存次數(shù)。
Key_writes 將一個(gè)鍵值塊物理寫入磁盤的次數(shù)(監(jiān)控)
13、
Max_used_connections 同時(shí)使用的連接的最大數(shù)目。(監(jiān)控)
Not_flushed_key_blocks 在鍵緩存中已經(jīng)改變但是還沒被清空到磁盤上的鍵塊。
Not_flushed_delayed_rows 在INSERT DELAY隊(duì)列中等待寫入的行的數(shù)量。
14、
Open_tables 打開表的數(shù)量。(監(jiān)控)
Open_files 打開文件的數(shù)量。(監(jiān)控)
Open_streams 打開流的數(shù)量(主要用于日志記載)
Opened_tables 已經(jīng)打開的表的數(shù)量
15、
Questions 發(fā)往服務(wù)器的查詢的數(shù)量。(監(jiān)控)
Slow_queries 要花超過long_query_time時(shí)間的查詢數(shù)量。
Threads_connected 當(dāng)前打開的連接的數(shù)量。(監(jiān)控)
Threads_running 不在睡眠的線程數(shù)量。(監(jiān)控)
Uptime 服務(wù)器工作了多少秒。(監(jiān)控)
本文名稱:mysqladminextended-status總結(jié)
文章起源:http://www.dlmjj.cn/article/jochji.html