`
m635674608
  • 浏览: 5004284 次
  • 性别: Icon_minigender_1
  • 来自: 南京
社区版块
存档分类
最新评论

MySQL的timeout相关配置参数小结一把

 
阅读更多
MySQL的版本:
 
MySQL-XtraDB-5.1.47
 
首先我们来看看有那些涉及到timeout的配置参数,看看,还真不少啊!
 
mysql> show  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 |
| net_read_timeout           | 30    |
| net_write_timeout          | 60    |
| slave_net_timeout          | 3600  |
| table_lock_wait_timeout    | 50    |  //这个参数已经没用了
| wait_timeout               | 28800 |
+----------------------------+-------+
10 rows in set (0.00 sec)
 

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 as of MySQL 5.1.23 and 5 seconds before that.
Increasing the connect_timeout value might help if clients frequently encounter errors of the form Lost connection to MySQL server at ‘XXX’, system error: errno.
解释:在获取链接时,等待握手的超时时间,只在登录时有效,登录成功这个参数就不管事了。主要是为了防止网络不佳时应用重连导致连接数涨太快,一般默认即可。

delayed_insert_timeout

手册描述:
How many seconds an INSERT DELAYED handler thread should wait for INSERT statements before terminating.
解释:这是为MyISAM INSERT DELAY设计的超时参数,在INSERT DELAY中止前等待INSERT语句的时间。

innodb_lock_wait_timeout

手册描述:
The timeout in seconds an InnoDB transaction may wait for a row lock before giving up. The default value is 50 seconds. A transaction that tries to access a row that is locked by another InnoDB transaction will hang for at most this many seconds before issuing the following error:

ERROR 1205 (HY000): Lock wait timeout exceeded; try restarting transaction

When a lock wait timeout occurs, the current statement is not executed. The current transaction is not rolled back. (To have the entire transaction roll back, start the server with the –innodb_rollback_on_timeout option, available as of MySQL 5.1.15. See also Section 13.6.12, “InnoDB Error Handling”.)
innodb_lock_wait_timeout applies to InnoDB row locks only. A MySQL table lock does not happen inside InnoDB and this timeout does not apply to waits for table locks.
InnoDB does detect transaction deadlocks in its own lock table immediately and rolls back one transaction. The lock wait timeout value does not apply to such a wait.
For the built-in InnoDB, this variable can be set only at server startup. For InnoDB Plugin, it can be set at startup or changed at runtime, and has both global and session values.
解释:描述很长,简而言之,就是事务遇到锁等待时的Query超时时间。跟死锁不一样,InnoDB一旦检测到死锁立刻就会回滚代价小的那个事务,锁等待是没有死锁的情况下一个事务持有另一个事务需要的锁资源,被回滚的肯定是请求锁的那个Query。

innodb_rollback_on_timeout

手册描述:
In MySQL 5.1, InnoDB rolls back only the last statement on a transaction timeout by default. If –innodb_rollback_on_timeout is specified, a transaction timeout causes InnoDB to abort and roll back the entire transaction (the same behavior as in MySQL 4.1). This variable was added in MySQL 5.1.15.
解释:这个参数关闭或不存在的话遇到超时只回滚事务最后一个Query,打开的话事务遇到超时就回滚整个事务。

interactive_timeout/wait_timeout

手册描述:
The number of seconds the server waits for activity on an interactive connection before closing it. An interactive client is defined as a client that uses the CLIENT_INTERACTIVE option to mysql_real_connect(). See also
解释:一个持续SLEEP状态的线程多久被关闭。线程每次被使用都会被唤醒为acrivity状态,执行完Query后成为interactive状态,重新开始计时。wait_timeout不同在于只作用于TCP/IP和Socket链接的线程,意义是一样的。

net_read_timeout / net_write_timeout

手册描述:
The number of seconds to wait for more data from a connection before aborting the read. Before MySQL 5.1.41, this timeout applies only to TCP/IP connections, not to connections made through Unix socket files, named pipes, or shared memory. When the server is reading from the client, net_read_timeout is the timeout value controlling when to abort. When the server is writing to the client, net_write_timeout is the timeout value controlling when to abort. See also slave_net_timeout.
On Linux, the NO_ALARM build flag affects timeout behavior as indicated in the description of the net_retry_count system variable.
解释:这个参数只对TCP/IP链接有效,分别是数据库等待接收客户端发送网络包和发送网络包给客户端的超时时间,这是在Activity状态下的线程才有效的参数

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 or –master-connect-retry option, and the number of reconnection attempts is limited by the –master-retry-count option. The default is 3600 seconds (one hour).
解释:这是Slave判断主机是否挂掉的超时设置,在设定时间内依然没有获取到Master的回应就人为Master挂掉了

 

http://wangwei.cao.blog.163.com/blog/static/10236252620111119115540534/

分享到:
评论

相关推荐

    mysql提示got timeout reading communication packets的解决方法

    mysql>show gloable variables like “%timeout%”; 进行查看 interactive_timeout 的黓认值为28800 wait_timeout 的默认值这:120 根据情况增加吧. 这两个值是一个全局变量,可以动态增加,如: mysql> set ...

    MySQL性能优化之参数配置.docx

    MySQL 性能优化是一种重要的数据库优化技术,通过合理地配置 MySQL 参数,可以最大程度地提高 MySQL 的性能。本文将介绍如何通过修改 MySQL 参数来提高 MySQL 的性能。 修改 back_log 参数 back_log 参数控制着 ...

    MySQL和连接相关的timeout 的详细整理

    MySQL数据库在处理客户端连接时,提供了多种与超时相关的配置参数,这些参数有助于管理和优化数据库的性能及稳定性。以下是对这些timeout参数的详细解析: 1. `slave_net_timeout`: 这个参数主要应用于主从复制场景...

    关于MySQL的wait-timeout连接超时问题报错解决方案.pdf

    2. 查看 wait_timeout 参数的值:可以通过 SHOW GLOBAL VARIABLES 命令来查看 wait_timeout 参数的值,例如:mysql> show global variables like 'wait_timeout'; 这将显示当前的 wait_timeout 值。 3. 避免使用 ...

    MySQL slave_net_timeout参数解决的一个集群问题案例

    在MySQL数据库集群中,`slave_net_timeout`是一个至关重要的参数,它直接影响到主从复制的稳定性与效率。这个参数定义了从库在等待主库发送新的二进制日志事件(binlog events)时的最大等待时间。如果超过这个时间...

    解决mysql出现大量TIME_WAIT

    本文将深入解析如何有效解决MySQL出现大量TIME_WAIT状态的问题,通过调整系统内核参数、优化数据库配置以及合理管理连接池策略,确保服务器性能的稳定与高效。 ### 一、理解TIME_WAIT TIME_WAIT是TCP协议中的一个...

    MySQL中interactive_timeout和wait_timeout的区别

    在MySQL中,`interactive_timeout` 和 `wait_timeout` 是两个重要的配置参数,它们与客户端连接到服务器的超时设置紧密相关。理解这两个参数的区别对于优化数据库性能和避免不必要的连接断开至关重要。 `...

    MySQL配置参数参考

    MySQL配置参数参考

    关于MySQL的wait-timeout连接超时问题报错解决方案.docx

    这是因为 Hibernate 框架在执行数据库操作时,可能会长时间保持连接,而 MySQL 的 wait_timeout 参数设置的太小,导致连接超时。 error 信息分析 在出现连接超时问题时,错误信息可能如下所示: ERROR [org....

    mysql性能调优参数

    2. Innodb_lock_wait_timeout:这个参数确定 Innodb 事务在被回滚之前可以等待一个锁定的超时秒数,默认是 50 秒。 3. Innodb_max_dirty_pages_pct:这个参数确定 Innodb 主线程刷新缓存池中的数据,使脏数据比例...

    MySQL 使用 SSL 连接配置详解

    MySQL 使用SSL连接配置详解 在现代数据库管理中,安全性是至关重要的,SSL(Secure Sockets Layer)连接为MySQL提供了一种加密数据传输的方式,确保了客户端和服务器之间的通信不被窃听或篡改。本文将详细介绍如何...

    MySQL5.1 启动选项(配置参数)详解

    MySQL 5.1 启动选项是 MySQL 的一个重要组件,了解这些选项可以帮助 DBA 和开发者更好地配置和优化 MySQL 服务器。本文将详细介绍 MySQL 5.1 的启动选项,包括配置参数、启动选项、 MySQL 选项等。 一、配置参数 ...

    Mysql JDBC Url参数说明

    MySQL JDBC URL(Java Database Connectivity Uniform Resource Locator)是Java应用程序连接MySQL数据库时使用的字符串,它包含了数据库连接所需的各项配置信息。这篇博文将详细解释MySQL JDBC URL的各个参数及其...

    mysql最新版+配置文件.zip

    8. **连接参数**:如`max_connections`定义了最大并发连接数,`wait_timeout`定义了无操作后自动断开连接的时间。 9. **性能优化**:例如`innodb_buffer_pool_size`,决定了InnoDB引擎缓存数据和索引的内存大小,...

    mysql优化配置大全

    同时,MySQL也是优化难度最大的一个部分,不但需要理解一些MySQL专业知识,同时还需要长时间的观察统计并且根据经验 进行判断,然后设置合理的参数。 下面我们了解一下MySQL优化的一些基础,MySQL的优化我分为两...

    mysql连接的空闲时间超过8小时后 MySQL自动断开该连接解决方案

    wait_timeout =86400 相关参数,红色部分 mysql> show variables like ‘%timeout%’; +————————–+——-+ | Variable_name | Value | +————————–+——-+ | connect_timeout | 5 | | delayed_i

Global site tag (gtag.js) - Google Analytics