mysql和连接相关的timeout
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)地主动断开连接。
mysql和连接相关的timeout的更多相关文章
- golang中mysql建立连接超时时间timeout 测试
本文测试连接mysql的超时时间. 这里的"连接"是建立连接的意思. 连接mysql的超时时间是通过参数timeout设置的. 1.建立连接超时测试 下面例子中,设置连接超时时间为 ...
- MYSQL连接相关参数和状态值详解
针对mysql的连接参数和状态值,本文做些介绍和对比 一.MYSQL连接参数变量 1.常用连接数限制参数 show variables like '%connect%'; | max_connect_ ...
- openresty 学习笔记四:连接mysql和进行相关操作
openresty 学习笔记四:连接mysql和进行相关操作 毕竟redis是作为缓存,供程序的快速读写,虽然reidis也可以做持久化保存,但还是需要一个做数据存储的数据库.比如首次查询数据在red ...
- Mysql和网络连接相关的参数介绍
摘要:同时还需要注意OS级别的网络监听队列的限制.因为如果OS的网络监听设置小于mysql的back_log设置的时候,我们加大back_log是没有意义的... max_conecctions:整个 ...
- mysql交互式连接&非交互式连接
交互式操作:通俗的说,就是你在你的本机上打开mysql的客户端,就是那个黑窗口,在黑窗口下进行各种sql操作,当然走的肯定是tcp协议. 非交互式操作:就是你在你的项目中进行程序调用.比如一边是tom ...
- C Mysql API连接Mysql
最近都在查看MYsql C API文档,也遇到了很多问题,下面来简单的做一个总结. mysql多线程问题 mysql多线程处理不好,经常会发生coredump,见使用Mysql出core一文. 单线程 ...
- python操作mysql数据库的相关操作实例
python操作mysql数据库的相关操作实例 # -*- coding: utf-8 -*- #python operate mysql database import MySQLdb #数据库名称 ...
- 服务器保持与Mysql的连接
服务器程序经常要访问数据库,并且服务器程序是长时间保持运行的,mysql有一个特点,当连接上数据库后不做任何操作,默认8小时候会自动关闭休 眠的连接!一般情况下很难预料什么时候程序会执行数据库操作,如 ...
- PAIP.MYSQL SLEEP 连接太多解决
PAIP.MYSQL SLEEP 连接太多解决 作者Attilax 艾龙, EMAIL:1466519819@qq.com 来源:attilax的专栏 地址:http://blog.csdn.n ...
随机推荐
- gson 设置多个别名SerializedName
如图: @SerializedName(value = "orderDetail",alternate = {"orderDetail1","adve ...
- php命令行脚本 mock数据
<?php $con = mysql_connect("192.168.1.5:3306","root","123"); if (!$ ...
- struts2客户端与服务器端即jsp页面与action之间的关系
在Struts2中,客户端和服务器之间的数据传输全部要用到get.set方法:用set方法 ,可以将表单中的值存入Action类.通过Struts2.0标签,调用get方法将Action类中的结果数据 ...
- Mybatis增删改查(CURD)
前面的小节我们已经讲到用接口的方式编程.使用这种方式,需要注意的一个地方就是,在User.xml 配置文件中,mapper namespace="com.yiibai.mybatis.int ...
- e836. 设置JTabbedPane中卡片的提示语
There are two ways to set a tool tip on a tab. The first is to specify it when the tab is created; t ...
- jQuery回调、递延对象总结
jQuery回调.递延对象总结(上篇)—— jQuery.Callbacks jQuery回调.递延对象总结(中篇) —— 神奇的then方法 jQuery回调.递延对象总结(下篇) —— 解密jQu ...
- c# mvc 获取 HtmlHelper 表达式值和时间格式化 去边框
/// <summary> /// 返回没有边框的只读的TextBox标签 /// </summary> /// <typeparam name="TModel ...
- PLSQL Developer连接不上64位Oracle 10g的解决办法
下载instantclient-basic-win32-10.2.0.4.zip 假设Oracle 10g的安装目录为D:\oracle\product\10.2.0\db1 首先,将instantc ...
- 文本处理三剑客之 sed详解
1.简介 sed是非交互式的编辑器,它不会修改文件,除非使用shell重定向来保存结果.默认情况下,所有的输出行都被打印到屏幕上. sed编辑器逐行处理文件(或输入),并将结果发送到屏幕.具体过程如下 ...
- GetDlgItem的用法小结
GetDlgItem用于获得指定控件ID的窗体指针,函数原型如下: HWND GetDlgItem( HWND hDlg, int nIDDlgItem ); CWnd* GetDlgItem(int ...