国产探花免费观看_亚洲丰满少妇自慰呻吟_97日韩有码在线_资源在线日韩欧美_一区二区精品毛片,辰东完美世界有声小说,欢乐颂第一季,yy玄幻小说排行榜完本

首頁 > 數據庫 > MySQL > 正文

MySQL和連接相關的timeout 的詳細整理

2024-07-24 13:14:20
字體:
來源:轉載
供稿:網友

MySQL和連接相關的timeout 

 前言:

今天同事問為什么查詢mysql庫時, 在數據量比較大時,會話總斷。剛開始以為是mysql的和連接有關timeout的問題,結果是網絡的不穩定的原因。 

下面總結下和連接有關的timeout 

slave-net-timeout

The number of seconds to wait for more data from the master before the slave considers the connection broken, aborts the read, and tries to reconnect. The first retry occurs immediately after the timeout. The interval between retries is controlled by the MASTER_CONNECT_RETRY option for the CHANGE MASTER TO statement, and the number of reconnection attempts is limited by the --master-retry-count option. The default is 3600 seconds (one hour).
當slave認為連接master的連接有問題時,就等待N秒,然后斷開連接,重新連接master

net_read_timeout :

The number of seconds to wait for more data from a connection before aborting the read. When the server is reading from the client, net_read_timeout is the timeout value controlling when to abort
在終止讀之前,從一個連接獲得數據而等待的時間秒數;當服務正在從客戶端讀取數據時,net_read_timeout控制何時超時。 

net_write_timeout:

The number of seconds to wait for a block to be written to a connection before aborting the write.When the server is writing to the client, net_write_timeout is the timeout value controlling when to abort。
在終止寫之前,等待多少秒把block寫到連接;當服務正在寫數據到客戶端時,net_write_timeout控制何時超時

wait_timeout

The number of seconds the server waits for activity on a noninteractive connection before closing it.
與服務器端無交互狀態的連接,直到被服務器端強制關閉而等待的時間

interactive_timeout :

The number of seconds the server waits for activity on an interactive connection before closing it.
與服務器端無交互狀態的連接,直到被服務器端強制關閉而等待的時間

connect_timeout

The number of seconds that the mysqld server waits for a connect packet before responding with Bad handshake. The default value is 10 seconds.

等待一個連接響應的時間 

connect_timeout:在獲取連接階段(authenticate)起作用

interactive_timeout和wait_timeout:在連接空閑階段(sleep)起作用
net_read_timeout和net_write_timeout:則是在連接繁忙階段(query)起作用。 

獲取MySQL連接是多次握手的結果,除了用戶名和密碼的匹配校驗外,還有IP->HOST->DNS->IP驗證,任何一步都可能因為網絡問題導致線程阻塞。為了防止線程浪費在不必要的校驗等待上,超過connect_timeout的連接請求將會被拒絕。 

即使沒有網絡問題,也不能允許客戶端一直占用連接。對于保持sleep狀態超過了wait_timeout(或interactive_timeout,取決于client_interactive標志)的客戶端,MySQL會主動斷開連接。

即使連接沒有處于sleep狀態,即客戶端忙于計算或者存儲數據,MySQL也選擇了有條件的等待。在數據包的分發過程中,客戶端可能來不及響應(發送、接收、或者處理數據包太慢)。為了保證連接不被浪費在無盡的等待中,MySQL也會選擇有條件(net_read_timeout和net_write_timeout)地主動斷開連接。 

參考:

http://dev.mysql.com/doc/refman/5.5/en/server-system-variables.html

 以上就是MySQL和連接相關的timeout 的詳細整理,如有疑問請留言或者到本站社區交流討論,感謝閱讀,希望能幫助到大家,謝謝大家對本站的支持!


注:相關教程知識閱讀請移步到MYSQL教程頻道。
發表評論 共有條評論
用戶名: 密碼:
驗證碼: 匿名發表
主站蜘蛛池模板: 萨嘎县| 达日县| 怀仁县| 阳山县| 翁牛特旗| 涟源市| 锡林浩特市| 聂荣县| 泾川县| 武冈市| 普兰县| 华池县| 鄂州市| 崇左市| 安陆市| 岳池县| 平顶山市| 昌黎县| 磐安县| 池州市| 太湖县| 河间市| 桑日县| 吉首市| 读书| 郁南县| 崇文区| 新干县| 大化| 灵山县| 赞皇县| 石首市| 青海省| 宁化县| 宜丰县| 精河县| 巩义市| 盘山县| 太湖县| 桓台县| 枝江市|