ERROR 1135 (HY000): Can’t create a new thread (errno 11)
在一台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
首先使用perror工具看一下 错误代码11代表的意思
perror 11
OS error code 11: Resource temporarily unavailable
资源暂时不可用
google搜索了一下,很多文章说和当前用户的文件描述符ulimit -n有关系
ulimit -n
65535
当时候mysql的服务器load 为0,自然不可能是文件描述符不够导致的问题
第二个检查操作 cat /etc/security/limits.conf
得到的结果是
root soft nofile 65535
root hard nofile 65535
admin soft nofile 65535
admin hard nofile 65535
# End of file
mysql soft nproc 65536
mysql hard nproc 65536
mysql soft nofile 65535
第三个检查操作 查看mysql的错误日志
有一个很奇怪的现象,我的mysql是一直跑着的,但错误日志只有前两天的
这个时候,在ps aux | grep mysql的输出中发现 -log-error=/var/log/mysqld.log ,错误日志输出到/var目录下面是不正常的
mysql 2086 35.1 37.1 51184004 18388068 ? Sl 20:25 9:01
/u01/mysql/bin/mysqld –basedir=/u01/mysql –datadir=/u01/mysql/data –plugin-dir=/u01/mysql/lib/plugin
–user=mysql –log-error=/var/log/mysqld.log –open-files-limit=65535 –pid-file=/u01/mysql/run/mysqld.pid
–socket=/u01/mysql/run/mysql.sock –port=3306
直觉告诉我mysql用了/etc/my.cnf的内容
/etc/my.cnf的内容
[mysqld]
datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock
user=mysql
# Disabling symbolic-links is recommended to prevent assorted security risks
symbolic-links=0
[mysqld_safe]
log-error=/var/log/mysqld.log
pid-file=/var/run/mysqld/mysqld.pid
最终把mysqld_safe干掉后,用mysqld_safe –defaults-file=xx.cnf 重新指定my.cnf的位置,mysql就正常跑了
最终原因,@维西v 启动mysql的时候没有指定my.cnf的位置,所以导致mysqld_safe使用了/etc/my.cnf这个默认文件
但依然有问题不是很理解
1.为什么读了/etc/my.cnf的时候,mysqld还会继续使用my.cnf配置文件里面的/u01/mysql/data
2.为什么还会继续使用plugin-dir=/u01/mysql/lib/plugin
[...] 以前一直都是用redhat5,redhat6也处于测试阶段,当然也遇到了很多奇奇怪怪的问题,比如之前写的一篇博客,当时候是用root启动了mysqld_unsafe,在mysql的QPS到1W以上后,会出现ERROR 1135 (HY000): Can’t create a new thread (errno 11); 当时候的解决办法是用mysql用户来启动就解决了问题。但因为在系统重启后,如果用sudo -u mysql来启动的话,脚本会被卡主。 [...]