Fixing Poor MySQL Default Configuration Values
I've recently been accumulating some MySQL configuration variables that have defaults which have proven to be problematic in a high-volume production environment. The thing they all have in common is a network blip or two can trigger some very undesirable behavior.
max_connect_errors
If a client is having trouble connecting to MySQL, the server will give up waiting after connect_timeout seconds and increment the counter which tracks the number of connect errors it has seen for the host. Then, when that value reachesmax_connect_errors, the client will be locked out until you issue a FLUSH HOSTS command. Worse yet, if you have occasionally network blips and never need to restart your MySQL boxes, these errors can accumulate over time and eventually cause you middle of the night pain.
See Host 'host name' is blocked in the MySQL docs. Sadly, there is no way to disable this check entirely. Setting the variable to 0 doesn't accomplish that. Your only real solutions are (a) setting it to a very high value (max_connect_errors=1844674407370954751), and (b) running an occasional FLUSH HOSTS command.
connect_timeout
This is related to the above problem. In situations of network congestion (either at the client or server), it's possible for an initial connection to take several seconds to complete. But the default value for connect_timeout is 5 seconds. When you trip over that, the max_connect_errors problem above kicks in.
To avert this, try setting connect_timeout to a value more like 15 or 20. And also consider making thread_cache_size a non-zero value. That will help in situations when the server occasionally gets a high number of new connections in a very short period of time.
skip-name-resolve
MySQL does a reverse DNS lookup on every incoming connection by default. This sucks. It seems that no matter how good your infrastructure is, there are blips in DNS service. MySQL's host cache exists to keep those lookups to a minimum. Yet I've seen this cause pain off and on for eight years now. I can only assume there's a bug in the host cache or the resolver library when this happens.
I recommend adding skip-name-resolve to your /etc/my.cnf to skip DNS entirely. Just use IP addresses or ranges for your GRANTs. It seems that slow replies from DNS servers can also help you to trip over connect_timeout as well. Imagine having 2 or 3 DNS servers configured but the first one is unavailable.
slave_net_timeout
When the network connection between a master and slave database is interrupted in a way that neither side can detect (like a firewall or routing change), you must wait until slave_net_timeout seconds have passed before the salve realizes that something is wrong. It'll then try to reconnect to the master and pick up where it left off. That's awesome.
However, the default value is 3600 seconds. That's a full hour! FAIL.
Who wants their slaves to sit idle for that long before checking to see if something might be wrong? I can't think of anyone who wants that.
My suggestion, if you're in a busy environment, is that you set that to something closer to 30 seconds.
参考:http://jeremy.zawodny.com/blog/archives/011421.html
Fixing Poor MySQL Default Configuration Values的更多相关文章
- Default Parameter Values in Python
Python’s handling of default parameter values is one of a few things that tends to trip up most new ...
- 《理解 ES6》阅读整理:函数(Functions)(一)Default Parameter Values
对于任何语言来说,函数都是一个重要的组成部分.在ES6以前,从JavaScript被创建以来,函数一直没有大的改动,留下了一堆的问题和很微妙的行为,导致在JavaScript中使用函数时很容易出现错误 ...
- 【解决】Can't find default configuration "arch/x86/configs/xx_defconfig"!
Can't find default configuration "arch/x86/configs/xx_defconfig"! 这个问题常见在没有设置好架构的makefile中 ...
- 【IntellJ IDEA】idea启动测试类报错Error running 'Test1.test': Command line is too long. Shorten command line for Test1.test or also for JUnit default configuration.
idea启动测试类报错 Error running 'Test1.test': Command line is too long. Shorten command line for Test1.tes ...
- log4j报错ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only errors to the console.
ERROR StatusLogger No log4j2 configuration file found. Using default configuration: logging only err ...
- [Node.js] Manage Configuration Values with Environment Variables
Storing configuration in files instead of the environment has many downsides, including mistakenly c ...
- How to: Initialize Business Objects with Default Property Values in XPO 如何:在 XPO 中用默认属性值初始化业务对象
When designing business classes, a common task is to ensure that a newly created business object is ...
- How to: Initialize Business Objects with Default Property Values in Entity Framework 如何:在EF中用默认属性值初始化业务对象
When designing business classes, a common task is to ensure that a newly created business object is ...
- mysql DEFAULT约束 语法
mysql DEFAULT约束 语法 作用:用于向列中插入默认值. 说明:如果没有规定其他的值,那么会将默认值添加到所有的新记录.直线电机 mysql DEFAULT约束 示例 //在 "P ...
随机推荐
- VS2013失去智能提示如何恢复
一般智能提示包括,输入智能提示,鼠标移到类,方法,接口,变量上面自动提示相关信息,VS2013常常会失去这种提示功能,遇到这种情况可以这样解决: 1.在开发环境中随便打开一个xxx.aspx页面,也就 ...
- XMPP协议的原理介绍
XMPP(可扩展消息处理现场协议)是基于可扩展标记语言(XML)的协议,它用于即时消息(IM)以及在线现场探测.它在促进服务器之间的准即时操作.这个协议可能最终允许因特网用户向因特网上的其他任何人发送 ...
- CODEVS1073 家族 (并查集)
一道裸的并查集,练练手不错. program CODEVS1073; var i,j,m,n,q,x,y,k1,k2,z:longint; f:..] of longint; function fin ...
- HDU 4460
http://acm.hdu.edu.cn/showproblem.php?pid=4460 水题一道,oj时间卡的非常奇怪,把spfa的queue开成全局卡线过,别的全挂了,迪杰斯特拉的手写堆都超时 ...
- Inno Setup 插件大全
Inno Setup 插件大全 这是我收集到的目前网上最全的插件之一,里面的每个插件,都有详细的脚本示例来讲解该插件的具体用法.另外,下载了我公开的脚本的朋友,也有可能会被提示缺少文件,如果缺 ...
- iOS-XMPP客户端
首先我们自己做一个的IOS客户端程序 先看一下我们完成的效果图 首先下载xmppframework这个框架 点ZIP下载 接下来,用Xcode新建一个工程 将以下这些文件拖入新建工程中 加入frame ...
- MINIX3 系统任务分析
MINIX3 系统任务分析 7.1 MINIX3 系统任务概要 MINIX3 怎么来给用户提供丰富的服务呢?除了中断,异常处理,除了时钟服务. 程序员总是希望一个操作系统给他提供足够的服务,使得他 ...
- buildroot ntp 网络时钟同步
/********************************************************************** * buildroot ntp 网络时钟同步 * 说明: ...
- apache配置文件 httpd-vhosts.conf 和 htaccess
1.apache多站点配置中ServerAlias什么意思? -:就是给ServerName起别名,通过Alias中的域名也可以访问这个虚拟主机. eg: <VirtualHost www.be ...
- python numpy 模块简单介绍
用python自带的list去处理数组效率很低, numpy就诞生了, 它提供了ndarry对象,N-dimensional object, 是存储单一数据类型的多维数组,即所有的元素都是同一种类型. ...