濮阳杆衣贸易有限公司

主頁 > 知識庫 > MySQL和連接相關(guān)的timeout 的詳細(xì)整理

MySQL和連接相關(guān)的timeout 的詳細(xì)整理

熱門標(biāo)簽:電銷機(jī)器人價格多少錢一臺 地圖標(biāo)注圖標(biāo)素材入駐 百度地圖標(biāo)注地方備注 怎么申請400電話申請 怎么辦理400電話呢 電話機(jī)器人免費嗎 好搜地圖標(biāo)注 龍圖酒吧地圖標(biāo)注 400電話申請什么好

MySQL和連接相關(guān)的timeout 

 前言:

今天同事問為什么查詢mysql庫時, 在數(shù)據(jù)量比較大時,會話總斷。剛開始以為是mysql的和連接有關(guān)timeout的問題,結(jié)果是網(wǎng)絡(luò)的不穩(wěn)定的原因。 

下面總結(jié)下和連接有關(guān)的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).
當(dāng)slave認(rèn)為連接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
在終止讀之前,從一個連接獲得數(shù)據(jù)而等待的時間秒數(shù);當(dāng)服務(wù)正在從客戶端讀取數(shù)據(jù)時,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寫到連接;當(dāng)服務(wù)正在寫數(shù)據(jù)到客戶端時,net_write_timeout控制何時超時

wait_timeout

The number of seconds the server waits for activity on a noninteractive connection before closing it.
與服務(wù)器端無交互狀態(tài)的連接,直到被服務(wù)器端強(qiáng)制關(guān)閉而等待的時間

interactive_timeout :

The number of seconds the server waits for activity on an interactive connection before closing it.
與服務(wù)器端無交互狀態(tài)的連接,直到被服務(wù)器端強(qiáng)制關(guān)閉而等待的時間

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.

等待一個連接響應(yīng)的時間 

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

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

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

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

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

參考:

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

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

您可能感興趣的文章:
  • MySQL中interactive_timeout和wait_timeout的區(qū)別
  • C3P0連接池+MySQL的配置及wait_timeout問題的解決方法
  • MySQL slave_net_timeout參數(shù)解決的一個集群問題案例

標(biāo)簽:撫順 汕尾 固原 防疫工作 內(nèi)江 浙江 溫州 廣西

巨人網(wǎng)絡(luò)通訊聲明:本文標(biāo)題《MySQL和連接相關(guān)的timeout 的詳細(xì)整理》,本文關(guān)鍵詞  MySQL,和,連接,相關(guān),的,timeout,;如發(fā)現(xiàn)本文內(nèi)容存在版權(quán)問題,煩請?zhí)峁┫嚓P(guān)信息告之我們,我們將及時溝通與處理。本站內(nèi)容系統(tǒng)采集于網(wǎng)絡(luò),涉及言論、版權(quán)與本站無關(guān)。
  • 相關(guān)文章
  • 下面列出與本文章《MySQL和連接相關(guān)的timeout 的詳細(xì)整理》相關(guān)的同類信息!
  • 本頁收集關(guān)于MySQL和連接相關(guān)的timeout 的詳細(xì)整理的相關(guān)信息資訊供網(wǎng)民參考!
  • 推薦文章
    武夷山市| 田东县| 孟州市| 宜川县| 济南市| 即墨市| 东海县| 磴口县| 灵石县| 澄城县| 平果县| 石泉县| 松滋市| 阿合奇县| 新丰县| 屏边| 原平市| 梨树县| 襄樊市| 栾川县| 古丈县| 永寿县| 凤冈县| 揭东县| 双桥区| 靖西县| 霍山县| 淮北市| 泰兴市| 滦平县| 鄂伦春自治旗| 呼玛县| 晋宁县| 璧山县| 新密市| 东乌珠穆沁旗| 锦州市| 云霄县| 盐边县| 息烽县| 扎囊县|