mysql中一個普通ERROR 1135 (HY000)錯誤引發(fā)的血案
今天接到測試人員反應,測試環(huán)境前端應用程序無連接mysql數(shù)據(jù)庫,登錄mysql服務器,查看錯誤日志,發(fā)現(xiàn)有如下報錯:
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限制連接數(shù)有關(guān),文件描述符不夠用。接下來檢查配置件 /etc/security/limits.conf 相關(guān)結(jié)果如下:
#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限制已經(jīng)打開。
但是,執(zhí)行如下命令:
# 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
發(fā)現(xiàn)max user processes值仍為1024.
而在Centos5里面,只須在/etc/security/limits.conf添加如下兩行:
點擊(此處)折疊或打開
root soft nofile 65535
root hard nofile 65535
對應的uilmit -u 就會是65535.
后來猜想centos6的用戶的ulimit限制是不是還有其他的配置文件做相關(guān)的限制呢?果不其然,發(fā)現(xiàn)在 /etc/security/limits.d/目錄下,有一個名為:90-nproc.conf的配置文件,
打開看看什么內(nèi)容:
[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個,也就是說,系統(tǒng)的任何用戶均不可以通過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后,執(zhí)行如下命令:
[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后,繼續(xù)使用root用戶啟動mysqld_safe腳本,穩(wěn)定運行了一個上午,一切正常。 至此,ERROR 1135 (HY000): Can't create a new thread (errno 11)這個問題總算告以段落。
相關(guān)文章
mysql SKIP-NAME-RESOLVE 錯誤的使用時機造成用戶權(quán)限
新加的一臺服務器,連接內(nèi)網(wǎng)中的一臺mysql服務器的時候,經(jīng)常出現(xiàn)超時。2011-06-06
高效數(shù)據(jù)流轉(zhuǎn):Mycat分庫分表與GreatSQL實時同步
聚焦數(shù)據(jù)庫擴容與實時數(shù)據(jù)同步,探索MyCat分庫分表與GreatSQL的強大結(jié)合!想在大規(guī)模數(shù)據(jù)處理中游刃有余?本指南將帶你輕松掌握MyCat的分布式解決方案和GreatSQL的實時同步機制,讓高效、穩(wěn)定的數(shù)據(jù)庫管理觸手可及,一起揭開高并發(fā)環(huán)境下數(shù)據(jù)庫優(yōu)化的神秘面紗吧!2024-01-01
Mysql報Table?'mysql.user'?doesn't?exist問題的解
這篇文章主要給大家介紹了關(guān)于Mysql報Table?'mysql.user'?doesn't?exist問題的解決方法,初學者可能會遇到這個問題,文中通過圖文將解決方法介紹的非常詳細,需要的朋友可以參考下2022-05-05
Slave memory leak and trigger oom-killer
這篇文章主要介紹了Slave memory leak and trigger oom-killer,需要的朋友可以參考下2016-07-07
MySQL數(shù)據(jù)庫操作常用命令小結(jié)
這篇文章主要介紹了MySQL數(shù)據(jù)庫操作常用命令小結(jié),例如創(chuàng)建數(shù)據(jù)庫、使用數(shù)據(jù)庫、查看數(shù)據(jù)庫、數(shù)據(jù)庫編碼操作等命令講解,需要的朋友可以參考下2014-12-12

