自拍偷在线精品自拍偷,亚洲欧美中文日韩v在线观看不卡

詳解MySQL數(shù)據(jù)庫(kù)資源不足的異常錯(cuò)誤

數(shù)據(jù)庫(kù) MySQL
MySQL是一個(gè)線程管理型的系統(tǒng), 通過Linux系統(tǒng)的ps -ef無(wú)法正常發(fā)現(xiàn)其占用的進(jìn)程數(shù),在無(wú)法登錄mysql用戶或者登錄進(jìn)入mysql的情況下, 可以通過查看proc文件系統(tǒng)檢查系統(tǒng)的情況。

前幾天,在管理系統(tǒng)的時(shí)候遇到一個(gè)奇怪的問題, 今天才有機(jī)會(huì)安裝好MySQL環(huán)境來(lái)重現(xiàn)此問題,由于不是最原始的環(huán)境, 所以未必能夠完全重現(xiàn), 我只能努力重現(xiàn)關(guān)鍵問題了.. 我覺得此問題有點(diǎn)特別, 故在此大概的回想下當(dāng)時(shí)的情景..

工作時(shí), 執(zhí)行了一個(gè)su – mysql 的命令, 遇到了下面這樣一個(gè)錯(cuò)誤..

  1. [root@dbmain ~]# su - mysql   
  2. su: cannot set user id: Resource temporarily unavailable  

這是一個(gè)Shell中由于資源不足引起的問題, 當(dāng)時(shí)下意識(shí)的先運(yùn)行ulimit,看看ulimit的基本限制.

  1. [root@dbmain ~]# ulimit -a   
  2. core file size          (blocks, -c) 0   
  3. data seg size           (kbytes, -d) unlimited   
  4. scheduling priority             (-e) 0   
  5. file size               (blocks, -f) unlimited   
  6. pending signals                 (-i) 25600   
  7. max locked memory       (kbytes, -l) 32   
  8. max memory size         (kbytes, -m) unlimited   
  9. open files                      (-n) 1024   
  10. pipe size            (512 bytes, -p) 8   
  11. POSIX message queues     (bytes, -q) 819200   
  12. real-time priority              (-r) 0   
  13. stack size              (kbytes, -s) 10240   
  14. cpu time               (seconds, -t) unlimited   
  15. max user processes              (-u) 25600   
  16. virtual memory          (kbytes, -v) unlimited   
  17. file locks                      (-x) unlimited 

又看了看,/etc/security/limits.conf

  1. oracle              soft    nproc   2047   
  2. oracle              hard    nproc   16384   
  3. oracle              soft    nofile  1024   
  4. oracle              hard    nofile  65536   
  5. oracle              soft    memlock        12582912   
  6. oracle              hard   memlock        12582912   
  7. grid              soft    nproc   2047   
  8. grid              hard    nproc   16384   
  9. grid              soft    nofile  1024   
  10. grid              hard    nofile  65536   
  11. grid              soft    memlock        12582912   
  12. grid              hard   memlock        12582912   
  13. mysql             soft    nproc  500   
  14. mysql             hard    nproc  500   
  15. mysql             soft    nofile  1024   
  16. mysql             hard    nofile  65536   
  17. mysql             soft    memlock  12582912   
  18. mysql             hard    memlock  12582912 

經(jīng)過分析,懷疑也只有process/file這兩個(gè)出現(xiàn)資源緊張的概率比較大.. 因此就先ps -ef 看系統(tǒng)中該用戶的進(jìn)程數(shù)量..

  1. [root@dbmain ~]# ps -ef | grep mysql   
  2. root      4733     1  0 10:30 ?        00:00:00 /bin/sh /usr/bin/mysqld_safe --datadir=/var/lib/mysql --pid-file=/var/lib/mysql/dbmain.pid   
  3. mysql     4788  4733  0 10:30 ?        00:00:04 /usr/sbin/mysqld --basedir=/ --datadir=/var/lib/mysql --user=mysql --log-error=/var/lib/mysql/dbmain.err --pid-file=/var/lib/mysql/dbmain.pid   
  4. root     15171 17507  0 13:26 pts/2    00:00:00 mysql -uroot -p   
  5. root     20792 17163  0 15:30 pts/1    00:00:00 grep mysql 

從這個(gè)輸出,,我們暫時(shí)排除nproc超標(biāo)的可能性.

由此, 就根據(jù)此進(jìn)程的pid進(jìn)入其proc目錄查看當(dāng)前打開的文件數(shù)量..

發(fā)現(xiàn)有大量socket的文件連接.. 但是其數(shù)量遠(yuǎn)遠(yuǎn)未達(dá)到文件數(shù)的限制, 由此懷疑可能是MySQL的線程也會(huì)消耗掉Linux系統(tǒng)的nproc基數(shù), 因此嘗試調(diào)整/etc/security/limits.conf文件的nproc參數(shù)的值.

發(fā)現(xiàn)調(diào)整過后, su – mysql 確實(shí)可以成功執(zhí)行了,,后面又將此參數(shù)改回, 重新執(zhí)行su – mysql,,此問題又再次重現(xiàn)..由此確認(rèn),,使用MySQL的系統(tǒng), 在設(shè)置MySQL的參數(shù)max_connections之外, 還需要考慮設(shè)置/etc/security/limits.conf文件的大小, MySQL是線程模式執(zhí)行的, 其線程數(shù)也會(huì)被統(tǒng)計(jì)在nproc中, 這可能掩蓋或造成對(duì)此問題的誤判..

【編輯推薦】 

  1. MySQL數(shù)據(jù)庫(kù)集群進(jìn)行正確配置步驟
  2. MySQL 集群在Server1與Server2上如何安裝MySQL
  3. MySQL集群配置
  4. MySQL集群自動(dòng)安裝腳本
  5. MySQL觸發(fā)器如何正確使用
責(zé)任編輯:彭凡 來(lái)源: DBhome
相關(guān)推薦

2011-04-07 15:47:28

MySQL數(shù)據(jù)庫(kù)

2011-07-12 16:41:14

mysql處理異常

2022-03-29 10:52:08

MySQL數(shù)據(jù)庫(kù)

2010-03-29 10:19:24

2018-07-30 15:00:05

數(shù)據(jù)庫(kù)MySQLJOIN

2011-05-26 14:43:49

ORACLE數(shù)據(jù)庫(kù)異常處理

2011-08-05 14:02:17

MySQL數(shù)據(jù)庫(kù)異常處理

2010-06-02 11:24:57

MySQL數(shù)據(jù)庫(kù)主鍵

2010-05-19 13:37:39

MySQL數(shù)據(jù)庫(kù)密碼

2011-08-30 12:51:19

MySQL線程緩沖池

2011-08-17 17:29:32

Windows編譯MySQL

2010-06-10 17:19:05

MySQL數(shù)據(jù)庫(kù)

2011-08-30 13:40:28

MySQL線程

2011-09-01 10:56:34

2010-01-05 09:24:42

MySQL外鍵約束

2011-08-25 17:49:14

MySQLmysqlcheck

2010-06-11 14:46:13

MySQL數(shù)據(jù)庫(kù)

2011-08-22 18:12:20

OracleORA-01591

2011-07-05 10:03:00

Qt MYSQL 數(shù)據(jù)庫(kù)

2009-12-31 11:10:01

點(diǎn)贊
收藏

51CTO技術(shù)棧公眾號(hào)