mysql中一个普通ERROR 1135 (HY000)错误引发的血案_MySQL
今天接到测试人员反应,测试环境前端应用程序无连接mysql数据库,登录mysql服务器,查看错误日志,发现有如下报错:
ERROR 1135 (HY000): Can't create a new thread (errno 11);if you are not out of available memory,you can consult the manual for a possible OS-dependent bug
第一反应感觉可能是跟ulimit限制连接数有关,文件描述符不够用。接下来检查配置件 /etc/security/limits.conf 相关结果如下:
代码如下:
#for root
root soft nofile 65535
root hard nofile 65535
# End of file
mysql soft nproc 65536
mysql hard nproc 65536
mysql soft nofile 65535
mysql hard nofile 65535
配置没有问题,mysql的ulimit限制已经打开。
但是,执行如下命令:
代码如下:
# sudo -u root bash -c " ulimit -a "
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 62591
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 1024
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 1024
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
发现max user processes值仍为1024.
而在Centos5里面,只须在/etc/security/limits.conf添加如下两行:
点击(此处)折叠或打开
root soft nofile 65535
root hard nofile 65535
对应的uilmit -u 就会是65535.
后来猜想centos6的用户的ulimit限制是不是还有其他的配置文件做相关的限制呢?果不其然,发现在 /etc/security/limits.d/目录下,有一个名为:90-nproc.conf的配置文件,
打开看看什么内容:
[root@fztest ~]# cat /etc/security/limits.d/90-nproc.conf
代码如下:
# Default limit for number of user's processes to prevent
# accidental fork bombs.
# See rhbz #432903 for reasoning.
* soft nproc 1024
而在配置文件/etc/security/limits.d/90-nproc.conf中的 “* soft nproc 1024”的意思是任何用户的最大max user processes为1024个,也就是说,系统的任何用户均不可以通过ulimit -u来修改 。真的是这样吗?我们来进行如下验证操作:
代码如下:
[oracle@fztest ~]$ ulimit -u 65535
-bash: ulimit: max user processes: cannot modify limit: Operation not permitted
[root@fztest ~]# ulimit -u 65535
[root@fztest ~]# ulimit -u
65535
由以上操作,可知事实上这个限制是对除root以外的普通用户进行的限制,root可以通过ulimit -u 65535来进行即时修改,只对当前会话生效。一旦重启服务器,便会失效(重新恢复max user processes -u 1024)。
接下来,尝试通过修改这个配置文件,来验证max user processes的值是否会改变。
将/etc/security/limits.d/90-nproc.conf中的1024修改为65535后,执行如下命令:
代码如下:
[root@fztest ~]# sudo -u root bash -c " ulimit -a"
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 95191
max locked memory (kbytes, -l) 64
max memory size (kbytes, -m) unlimited
open files (-n) 65535
pipe size (512 bytes, -p) 8
POSIX message queues (bytes, -q) 819200
real-time priority (-r) 0
stack size (kbytes, -s) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 65535
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
由此可见,修改生效。如果不想修改/etc/security/limits.d/90-nproc.conf这个文件,也可以将此限制添加到/etc/rc.local文件中,让其开机应用生效即可。
成功修改了root用户的max user processes后,继续使用root用户启动mysqld_safe脚本,稳定运行了一个上午,一切正常。 至此,ERROR 1135 (HY000): Can't create a new thread (errno 11)这个问题总算告以段落。

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

AI Hentai Generator
Generate AI Hentai for free.

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics



PHP is a popular web development language that has been used for a long time. The PDO (PHP Data Object) class integrated in PHP is a common way for us to interact with the database during the development of web applications. However, a problem that some PHP developers often encounter is that when using the PDO class to interact with the database, they receive an error like this: PHPFatalerror:CalltoundefinedmethodPDO::prep

It is very common to use axios in Vue applications. axios is a Promise-based HTTP client that can be used in browsers and Node.js. During the development process, the error message "Uncaught(inpromise)Error: Requestfailedwithstatuscode500" sometimes appears. For developers, this error message may be difficult to understand and solve. This article will explore this

Solve the "error:incompletetypeisnotallowed" problem in C++ code. During the C++ programming process, you sometimes encounter some compilation errors. One of the common errors is "error:incompletetypeisnotallowed". This error is usually caused by operating on an incomplete type. This article will explain the cause of this error and provide several solutions. firstly, I

Solution to "0271: real time clock error" that cannot boot: 1. Press F1, and in the interface that appears, move the option bar to the third item "Date/Time"; 2. Manually change the system time to the current one time; 3. Press F10 and select yes in the pop-up dialog box; 4. Re-open the notebook to boot normally.

Solve the "error:expectedinitializerbefore'datatype'" problem in C++ code. In C++ programming, sometimes we encounter some compilation errors when writing code. One of the common errors is "error:expectedinitializerbefore'datatype'". This error usually occurs in a variable declaration or function definition and may cause the program to fail to compile correctly or

How to solve PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory In the process of using PHP development, we often encounter some file operation problems, one of which is "PHPWarning:fopen():failedtoopenstream:Nosuchfileordirectory"

When writing web applications using PHP, a MySQL database is often used to store data. PHP provides a way to interact with the MySQL database called MySQLi. However, sometimes when using MySQLi, you will encounter an error message, as shown below: PHPFatalerror:Calltoundefinedfunctionmysqli_connect() This error message means that PHP cannot find my

When using PHP for web application development, you will often need to use a database. When using a database, error messages are very common. Among them, PHPFatalerror: Calltoamemberfunctionfetch() is a relatively common error that occurs when using PDO to query the database. So, what causes this error and how to solve it? This article will explain it in detail for you. 1. Cause of error
