欧美bbbwbbbw肥妇,免费乱码人妻系列日韩,一级黄片

通過案例分析MySQL中令人頭疼的Aborted告警

 更新時間:2017年06月29日 09:39:23   作者:dbapower  
這篇文章通過案例跟大家分析了MySQL中令人頭疼的Aborted告警的相關(guān)資料,文中將Aborted告警介紹的非常詳細,對大家具有一定的參考學(xué)習(xí)價值,需要的朋友們下面來一起看看吧。

本文主要給大家介紹的是關(guān)于MySQL中Aborted告警的相關(guān)內(nèi)容,分享出來供大家參考學(xué)習(xí),下面來一起看看詳細的介紹:

實戰(zhàn)

Part1:寫在最前

在MySQL的error log中,我們會經(jīng)常性看到一些各類的Aborted connection錯誤,本文中會針對這類錯誤進行一個初步分析,并了解一個問題產(chǎn)生后的基本排查思路和方法。掌握這種方法是至關(guān)重要的,而不是出現(xiàn)問題了,去猜,去試。數(shù)據(jù)庫出現(xiàn)問題的時候需要DBA在短時間內(nèi)快速解決問題,因此一個好與壞的DBA,區(qū)別也在于此。

Part2:種類

[Warning] Aborted connection 305628 to db: 'db' user: 'dbuser' host: 'hostname' (Got an error reading communication packets)
[Warning] Aborted connection 81 to db:'unconnected' user: 'root' host: '127.0.0.1' (Got timeout reading communication
packets)
[Warning] Aborted connection 109 to db:'helei1' user: 'sys_admin' host: '192.168.1.1' (Got an error writing communication packets)
[Warning] Access denied for user 'root'@'127.0.0.1' (using password: YES)
[Warning] Got an error writing communication packets

Part3:重點參數(shù)分析

wait_timeout

Command-Line Format --wait-timeout=#
System Variable Name wait_timeout
Variable Scope Global, Session
Dynamic Variable Yes
Permitted Values (Windows) Type integer
Default 28800
Min Value 1
Max Value 2147483
Permitted Values (Other) Type integer
Default 28800
Min Value 1
Max Value 31536000

這個參數(shù)指的是數(shù)據(jù)庫系統(tǒng)在關(guān)閉它之前,服務(wù)器等待非交互式連接上的活動的秒數(shù)。

interactive_timeout

Command-Line Format --interactive-timeout=#
System Variable Name interactive_timeout
Variable Scope Global, Session
Dynamic Variable Yes
Permitted Values Type integer
Default 28800
Min Value 1

這個參數(shù)指的是在關(guān)閉交互式連接之前,服務(wù)器等待活動的秒數(shù)

Warning:警告這兩個參數(shù)建議一起調(diào)節(jié),能夠避免一些坑。

本文的兩個參數(shù)值采用的是默認值

mysql> show global variables like '%timeout%';
+----------------------------+----------+
| Variable_name    | Value |
+----------------------------+----------+
| connect_timeout   | 10  |
| delayed_insert_timeout  | 300  |
| innodb_lock_wait_timeout | 50  |
| innodb_rollback_on_timeout | OFF  |
|interactive_timeout  | 28800 |
| lock_wait_timeout   | 31536000 |
| net_read_timeout   | 30  |
| net_write_timeout   | 60  |
| slave_net_timeout   | 3600  |
|wait_timeout    | 28800 |
+----------------------------+----------+
10 rows in set (0.01 sec)

另外在數(shù)據(jù)庫中,我們重點關(guān)注下這兩個參數(shù),看看什么情況下Aborted_clients會提升,什么情況下Aborted_connects 會提升

mysql>show global status like 'aborted%';
+------------------+-------+
|Variable_name | Value |
+------------------+-------+
|Aborted_clients | 19 |
|Aborted_connects | 0  |
+------------------+-------+
2 rows inset (0.00 sec)

Part4:案例1

這里我故意輸入錯誤的密碼5次,來看下數(shù)據(jù)庫的error log和Aborted的哪個參數(shù)記載了這一問題

[root@HE3~]# mysql -uroot -pwrongpass -h127.0.0.1
ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)
[root@HE3~]# mysql -uroot -pwrongpass -h127.0.0.1
ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)
[root@HE3~]# mysql -uroot -pwrongpass -h127.0.0.1
ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)
[root@HE3~]# mysql -uroot -pwrongpass -h127.0.0.1
ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)
[root@HE3~]# mysql -uroot -pwrongpass -h127.0.0.1
ERROR 1045 (28000): Access denied for user 'root'@'127.0.0.1' (using password: YES)

可以看出,這里的Aborted_connects 記錄了密碼錯誤的這一問題

mysql>show global status like 'aborted%';
+------------------+-------+
|Variable_name | Value |
+------------------+-------+
|Aborted_clients | 19 |
|Aborted_connects | 5  |
+------------------+-------+
2 rows inset (0.00 sec)

error log中,也記載了這類密碼輸錯的信息

[Warning] Access denied for user'root'@'127.0.0.1' (using password: YES)
[Warning] Access denied for user 'root'@'127.0.0.1' (using password:YES)
[Warning] Access denied for user 'root'@'127.0.0.1' (using password:YES)
[Warning] Access denied for user 'root'@'127.0.0.1' (using password:YES)
[Warning] Access denied for user 'root'@'127.0.0.1' (using password:YES)

Part5:案例2

接下來我們看下文章第三節(jié)提到的兩個重點參數(shù)對數(shù)據(jù)庫連接的行為影響

這里我們將這兩個參數(shù)均配置為10秒

mysql>set global wait_timeout=10;
Query OK,0 rows affected (0.00 sec)
 
mysql>set global interactive_timeout=10;
Query OK,0 rows affected (0.00 sec)
mysql>show processlist;
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect... Connection id: 79 Current database: *** NONE ***
 
+----+------+-----------------+------+---------+------+-------+------------------+
| Id |User | Host   | db | Command | Time | State | Info    |
+----+------+-----------------+------+---------+------+-------+------------------+
| 79 |root | 127.0.0.1:42016 | NULL | Query | 0 | NULL | show processlist |
+----+------+-----------------+------+---------+------+-------+------------------+
1 row in set (0.00 sec)

這里三次操作,可以看到clients數(shù)上升,這是由于timeout參數(shù)控制的,已經(jīng)連接上數(shù)據(jù)的連接被殺掉。

mysql>show global status like 'aborted%';
ERROR 2006 (HY000): MySQL server has gone away
No connection. Trying to reconnect... Connection id: 81 Current database: *** NONE ***
 
+------------------+-------+
|Variable_name | Value |
+------------------+-------+
|Aborted_clients | 22 |
|Aborted_connects | 5  |
+------------------+-------+
2 rows in set (0.01 sec)

error log中記載的是

[Warning] Aborted connection 81 to db: 'unconnected' user: 'root' host: '127.0.0.1' (Got timeout reading communication packets)
[Warning] Aborted connection 78 to db: 'unconnected' user: 'root' host: '127.0.0.1' (Got timeout reading communication packets) 
[Warning] Aborted connection 79 to db: 'unconnected' user: 'root' host: '127.0.0.1' (Got timeout reading communication packets)

Part6:案例3

在這個案例中我們看下最大連接數(shù)對數(shù)據(jù)庫連接的行為影響

mysql>show global variables like 'max_conn%';
+--------------------+-------+
|Variable_name  | Value |
+--------------------+-------+
|max_connect_errors | 1000 |
|max_connections | 1024 |
+--------------------+-------+
2 rows in set (0.00 sec)
 
 
mysql>set global max_connections=2;
Query OK,0 rows affected (0.00 sec)

這里看到爆出了連接數(shù)過多的問題

[root@HE3~]# mysql -uroot -pMANAGER -h127.0.0.1
ERROR 1040 (HY000): Too many connections

而錯誤日志沒有任何記錄

Part7:案例4

第三方工具navicat select結(jié)果沒有出來的時候選擇停止則出現(xiàn)

clients上漲

mysql>show global status like 'aborted%';
+------------------+-------+
|Variable_name | Value |
+------------------+-------+
|Aborted_clients | 28 |
|Aborted_connects | 10 |
+------------------+-------+
2 rows in set (0.00 sec)

error log日志記錄

170626 16:26:56 [Warning] Aborted connection 109 to db: 'helei1' user: 'sys_admin' host: '192.168.1.1' (Got an error writing communication packets)

Part8:原因總結(jié)

  1. 在MySQL中sleep狀態(tài)數(shù)百秒的而且經(jīng)常重復(fù)連接是應(yīng)用程序在工作后沒有關(guān)閉連接的癥狀之一,而是依靠數(shù)據(jù)庫wait_timeout來關(guān)閉它們。強烈建議在操作結(jié)束時更改應(yīng)用程序邏輯以正確關(guān)閉連接;
  2. 檢查以確保max_allowed_packet的值足夠高,并且客戶端沒有收到“數(shù)據(jù)包太大”消息。 這種情況他會中止連接,而不正確關(guān)閉它;
  3. 另一種可能性是TIME_WAIT。建議您確認連接被妥善管理并且是在應(yīng)用端正常關(guān)閉;
  4. 確保事務(wù)正確提交(開始和提交),以便一旦應(yīng)用程序“完成”連接,它將處于“clean”的狀態(tài);
  5. 您應(yīng)該確保客戶端應(yīng)用程序不中止連接。 例如,如果PHP的選項max_execution_time設(shè)置為5秒,增加connect_timeout是沒用的,因為PHP會殺死腳本。 其他編程語言和環(huán)境也有類似的選項;
  6. 連接延遲的另一個原因是DNS問題。 檢查是否啟用了skip-name-resolve,檢查主機根據(jù)其IP地址而不是其主機名進行身份驗證;
  7. 嘗試增加MySQL的net_read_timeout和net_write_timeout值,看看是否減少了錯誤的數(shù)量。

總結(jié)

通過這4個案例,我們能夠了解到,Aborted_clients、和Aborted_connects的區(qū)別,以及什么情況下會爆出什么樣的錯誤日志,文章第二節(jié)中的幾個Aborted錯誤是常見的錯誤,這類錯誤出現(xiàn)的時候腦海里要有一個理論知識,知道什么情況下,會出現(xiàn)什么樣的錯誤,以便快速定位問題。由于筆者的水平有限,編寫時間也很倉促,文中難免會出現(xiàn)一些錯誤或者不準(zhǔn)確的地方,不妥之處懇請讀者批評指正。

好了,以上就是這篇文章的全部內(nèi)容了,希望本文的內(nèi)容對大家的學(xué)習(xí)或者工作能帶來一定的幫助,如果有疑問大家可以留言交流,謝謝大家對腳本之家的支持。

相關(guān)文章

  • mysql的事務(wù),隔離級別和鎖用法實例分析

    mysql的事務(wù),隔離級別和鎖用法實例分析

    這篇文章主要介紹了mysql的事務(wù),隔離級別和鎖用法,結(jié)合實例形式分析了MySQL事務(wù),隔離級別和鎖相關(guān)原理、用法及操作注意事項,需要的朋友可以參考下
    2020-02-02
  • MySQL創(chuàng)建全文索引分享

    MySQL創(chuàng)建全文索引分享

    使用索引是數(shù)據(jù)庫性能優(yōu)化的必備技能之一。在MySQL數(shù)據(jù)庫中,有四種索引:聚集索引(主鍵索引)、普通索引、唯一索引以及我們這里將要介紹的全文索引(FULLTEXT INDEX)
    2017-01-01
  • MYSQL基礎(chǔ)之連接MYSQL、修改密碼、添加用戶

    MYSQL基礎(chǔ)之連接MYSQL、修改密碼、添加用戶

    在這篇文章中我們就從連接MYSQL、修改密碼、增加用戶等方面來學(xué)習(xí)一些MYSQL的常用命令。
    2008-08-08
  • 在MySQL數(shù)據(jù)庫中使用C執(zhí)行SQL語句的方法

    在MySQL數(shù)據(jù)庫中使用C執(zhí)行SQL語句的方法

    與PostgreSQL相似,可使用許多不同的語言來訪問MySQL,包括C、C++、Java和Perl。從Professional Linux Programming中第5章有關(guān)MySQL的下列章節(jié)中,Neil Matthew和Richard Stones使用詳盡的MySQL C接口向我們介紹了如何在MySQL數(shù)據(jù)庫中執(zhí)行SQL語句。
    2012-10-10
  • MySql樹形結(jié)構(gòu)(多級菜單)查詢設(shè)計方案

    MySql樹形結(jié)構(gòu)(多級菜單)查詢設(shè)計方案

    本文主要介紹了MySql樹形結(jié)構(gòu)(多級菜單)查詢設(shè)計方案,文中通過示例代碼介紹的非常詳細,對大家的學(xué)習(xí)或者工作具有一定的參考學(xué)習(xí)價值,需要的朋友們下面隨著小編來一起學(xué)習(xí)學(xué)習(xí)吧
    2023-03-03
  • C#實現(xiàn)MySQL命令行備份和恢復(fù)

    C#實現(xiàn)MySQL命令行備份和恢復(fù)

    MySQL數(shù)據(jù)庫的備份有很多工具可以使用,今天介紹一下使用C#調(diào)用MYSQL的mysqldump命令完成MySQL數(shù)據(jù)庫的備份與恢復(fù)
    2018-03-03
  • MySQL創(chuàng)建用戶和權(quán)限管理的方法

    MySQL創(chuàng)建用戶和權(quán)限管理的方法

    這篇文章主要介紹了MySQL創(chuàng)建用戶和權(quán)限管理的方法,文中示例代碼非常詳細,幫助大家更好的理解和學(xué)習(xí),感興趣的朋友可以了解下
    2020-07-07
  • MySQL中表子查詢與關(guān)聯(lián)子查詢的基礎(chǔ)學(xué)習(xí)教程

    MySQL中表子查詢與關(guān)聯(lián)子查詢的基礎(chǔ)學(xué)習(xí)教程

    這篇文章主要介紹了MySQL中表子查詢與關(guān)聯(lián)子查詢的基礎(chǔ)學(xué)習(xí)教程,同時文中也提到了關(guān)于關(guān)聯(lián)子查詢的查詢效率問題,需要的朋友可以參考下
    2015-12-12
  • 淺析mysql union和union all

    淺析mysql union和union all

    union 是對數(shù)據(jù)進行并集操作,不包括重復(fù)行,同時進行默認排序而Union all 是對數(shù)據(jù)進行并集操作,包括重復(fù)行,不進行排序,下面給大家詳細介紹mysql union和union all,感興趣的朋友一起看看吧
    2017-10-10
  • mysql8.4版本mysql_native_password無法連接問題解決

    mysql8.4版本mysql_native_password無法連接問題解決

    用dbeaver可以直接連接,但是用NAVICAT連接后報錯,本文主要介紹了mysql8.4版本mysql_native_password無法連接問題解決,具有一定的參考價值,感興趣的可以了解一下
    2024-07-07

最新評論