怎么解決mysql中的ERROR1135(HY000)報錯問題-創(chuàng)新互聯

這篇文章主要講解了“怎么解決mysql中的ERROR 1135 (HY000)報錯問題”,文中的講解內容簡單清晰,易于學習與理解,下面請大家跟著小編的思路慢慢深入,一起來研究和學習“怎么解決mysql中的ERROR 1135 (HY000)報錯問題”吧!

創(chuàng)新互聯主要從事網站設計、做網站、網頁設計、企業(yè)做網站、公司建網站等業(yè)務。立足成都服務荊門,10余年網站建設經驗,價格優(yōu)惠、服務專業(yè),歡迎來電咨詢建站服務:028-86922220

收到報錯:

[root@i-iivphroy ~]# mysql -uroot -p*********  -h292.168.0.254

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

馬上google一番,有人說可能說磁盤空間滿了,經查看發(fā)現果然是磁盤滿了,(這個盤一直空間很緊張(95%),我高度警惕著,天天檢查,可是昨天我執(zhí)行了個大事務,產生了大量的binlog,給一下子撐爆了)

馬上刪除了幾天前的binlog和一些別的不需要的數據,空間釋放到了80%,再次登錄mysql

[root@i-iivphroy ~]# mysql -uroot -p******* -h292.168.0.254

依舊報錯:

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

再次google一番,查到下面這個文檔:

This error was the bane of my life for a while, and it was very hard to get a definitive answer as to what was causing it, I hope this saves you some trouble.

My website occasionally got large traffic spikes, and at the top of these peaks, I would start to see errors like these:

MySQL error #1135: 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.

I looked in the my.cnf file on the db server and looked at the open files limit, because a process is counted as an open file, but it seemed fine:

[mysqld_safe]

open-files-limit=10240

I also checked that maximum connections was high enough, it was at 2048.

What the open-files-limit in my.cnf files does is it tells the init script to use ulimit to whatever number you put in there.

After a lot of digging around various places, and much frustration, I discovered that by default linux has a hard limit of 1024 open files for all non super-users, so even though I had set a high open-files-limit, it was capped at 1024 by the OS. I also discovered how to raise it;

/etc/security/limits.conf

This file is used by PAM to set things like maximum processes, max open files, memory usage etc and these limits can be set on a per-user basis, so I added these lines:

mysql soft nofile 4096

mysql hard nofile 4096

大體的意思是說,這個報錯的原因:由于:mysql的配置文件/etc/my.cnf的參數open-files-limit設置的比linux的max user processes的數值大,需要通過修改linux的配置文件 /etc/security/limits.d/90-nproc.conf來擴大linux系統(tǒng)的限制,也就是這個錯是由于linux的max user processes閾值太小了。

馬上查看我的相關配置:

mysql的open-files-limit,如下所示:

[root@i-iivphroy ~]# cat /etc/my.cnf

[mysqld_safe]

open-files-limit=85216

linux的max user processes,如下所示紅色部分:

[root@i-iivphroy ~]# 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) 62842

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) 62842

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

將查看果然是前面文檔描述的情況,馬上修改max user processes

方法一:

[root@i-iivphroy ~]# cat  /etc/security/limits.conf

*  soft nofile 65535

*  hard nofile 65535

* soft nproc 65535

* hard nproc 65535

其中nofile對應open_files

nproc對應max_user_processes

但是在Linux 6.4之后,如果只修改了該文件中的nproc,那么其他非root用戶對應的max_user_processes并不會改變,仍然是1024,這個是因為受到了下面這個文件的影響

/etc/security/limits.d/90-nproc.conf

修改/etc/security/limits.d/90-nproc.conf將

* soft nproc 1024

修改為:

* soft nproc 65535

或者

修改/etc/security/limits.conf,將

* soft nofile 10240

修改為

Oracle  soft nofile 10240

方法二:這樣為每一個運行bash shell的用戶執(zhí)行此文件,當bash shell被打開時,該文件被讀取。也就是說,當用戶shell執(zhí)行了bash時,運行這個文件,如果這個服務器上有多個用戶,最好是用方法一。

修改了/etc/bashrc,成功了,并且不用重啟。

vi /etc/bashrc

添加 :

ulimit -u 65535

退出session,從新開session再次ulimit -a 發(fā)現已經變化了

[root@i-iivphroy ~]# 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) 62842

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) 65535

virtual memory          (kbytes, -v) unlimited

file locks                      (-x) unlimited

并且把mysql的open-files-limit改小。

[root@i-iivphroy ~]# cat /etc/my.cnf

[mysqld_safe]

open-files-limit=65000

重啟了mysql服務,問題解決。。。。

原因分析:

操作系統(tǒng)連接數太小。(比如centos 6 默認的  max user process只有 1024個。當mysql process大于這個值時 就會出現Can't create a new thread的問題)

連接數超限處理的辦法:

ulimit -a

查看max user processes 這一項

要是這個值比較的小 當mysql中process的數目超過這個數的時候 就會抱標題相應的錯誤。

一個過程process可以視為一個打開的文件

也就是說 下面幾個參數共同控制這mysql的 create a new thread

1) mysql的 /etc/my.cnf

open-files-limit=65535

2)linux  參數   open files和max user processes

[root@S243 ~]# ulimit

unlimited

[root@S243 ~]# 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) 1032207

max locked memory       (kbytes, -l) 64

max memory size         (kbytes, -m) unlimited

open files                      (-n) 50000

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

感謝各位的閱讀,以上就是“怎么解決mysql中的ERROR 1135 (HY000)報錯問題”的內容了,經過本文的學習后,相信大家對怎么解決mysql中的ERROR 1135 (HY000)報錯問題這一問題有了更深刻的體會,具體使用情況還需要大家實踐驗證。這里是創(chuàng)新互聯,小編將為大家推送更多相關知識點的文章,歡迎關注!

當前文章:怎么解決mysql中的ERROR1135(HY000)報錯問題-創(chuàng)新互聯
文章轉載:http://muchs.cn/article14/pcoge.html

成都網站建設公司_創(chuàng)新互聯,為您提供外貿網站建設、移動網站建設、關鍵詞優(yōu)化、網頁設計公司、手機網站建設、動態(tài)網站

廣告

聲明:本網站發(fā)布的內容(圖片、視頻和文字)以用戶投稿、用戶轉載內容為主,如果涉及侵權請盡快告知,我們將會在第一時間刪除。文章觀點不代表本網站立場,如需處理請聯系客服。電話:028-86922220;郵箱:631063699@qq.com。內容未經允許不得轉載,或轉載時需注明來源: 創(chuàng)新互聯

網站建設網站維護公司