| 16 | | * /etc/security/limits.conf - 每個程序(process)可以開啟檔案的個數(number limits of open files per process) - 像 HDFS 的 !DataNode 就需要調整這種參數([wiki:jazz/10-02-22#Hadoop:HDFS 2010-02-22]) |
| | 16 | * 如何調整每個使用者可以開啟的檔案個數 |
| | 17 | * [參考] [http://www.xenoclast.org/doc/benchmark/HTTP-benchmarking-HOWTO/node7.html Increasing the file descriptor limit] |
| | 18 | * [參考] [http://www.netadmintools.com/art295.html GNU/Linux - How Many Open Files?] |
| | 19 | * 注意:修改 /etc/security/limits.conf 中間必須確定是 TAB ,如果有設定 vim 的 softwaretab 的話,得特別當心!!! |
| | 20 | * /proc/sys/fs/file-max - 核心預設最多可以開啟的檔案個數 |
| | 21 | {{{ |
| | 22 | ~$ cat /proc/sys/fs/file-max |
| | 23 | 743964 |
| | 24 | }}} |
| | 25 | * /proc/sys/fs/file-max - 目前已開啟檔案個數、可供開啟檔案個數、總開啟檔案上限 |
| | 26 | {{{ |
| | 27 | [root@srv-4 proc]# cat /proc/sys/fs/file-nr |
| | 28 | 3391 969 52427 |
| | 29 | | | | |
| | 30 | | | | |
| | 31 | | | maximum open file descriptors |
| | 32 | | total free allocated file descriptors |
| | 33 | total allocated file descriptors |
| | 34 | (the number of file descriptors allocated since boot) |
| | 35 | }}} |
| | 36 | * /etc/security/limits.conf - 每個程序(process)可以開啟檔案的個數(number limits of open files per process) - 像 HDFS 的 !DataNode 就需要調整這種參數([wiki:jazz/10-02-22#Hadoop:HDFS 2010-02-22]) |
| 29 | | * [參考] [http://www.xenoclast.org/doc/benchmark/HTTP-benchmarking-HOWTO/node7.html Increasing the file descriptor limit] |
| | 50 | * /etc/pam.d/login - 告訴系統要用 /etc/security/limits.conf 來設定一些上限 |
| | 51 | {{{ |
| | 52 | # Sets up user limits according to /etc/security/limits.conf |
| | 53 | # (Replaces the use of /etc/limits in old login) |
| | 54 | session required pam_limits.so |
| | 55 | }}} |
| | 56 | * 指令: ulimit - 可以告訴你一些系統限制,並且設定想要的値 |
| | 57 | {{{ |
| | 58 | jazz@Wdebian:~$ ulimit -a |
| | 59 | core file size (blocks, -c) 0 |
| | 60 | data seg size (kbytes, -d) unlimited |
| | 61 | scheduling priority (-e) 0 |
| | 62 | file size (blocks, -f) unlimited |
| | 63 | pending signals (-i) 72704 |
| | 64 | max locked memory (kbytes, -l) 32 |
| | 65 | max memory size (kbytes, -m) unlimited |
| | 66 | open files (-n) 1024 |
| | 67 | pipe size (512 bytes, -p) 8 |
| | 68 | POSIX message queues (bytes, -q) 819200 |
| | 69 | real-time priority (-r) 0 |
| | 70 | stack size (kbytes, -s) 8192 |
| | 71 | cpu time (seconds, -t) unlimited |
| | 72 | max user processes (-u) 72704 |
| | 73 | virtual memory (kbytes, -v) unlimited |
| | 74 | file locks (-x) unlimited |
| | 75 | }}} |
| | 76 | * 假設 /proc/sys/fs/file-max 跟 /etc/security/limits.conf 都有設定上限為 743964,且 /etc/pam.d/login 也有打開,但是 ulimit -a 指令仍顯示 1024 (預設),可以修改 /etc/rc.local 或 /etc/profile 強制用 ulimit -n 743964 來提高開檔個數。 |
| | 77 | {{{ |
| | 78 | ~$ ulimit -n 743964 |
| | 79 | }}} |
| | 80 | * [備註] 如果 ulimit 超出可容許範圍,會顯示 Operation not permitted,此時請檢查相關設定値 |
| | 81 | {{{ |
| | 82 | ~$ ulimit -n 7439640 |
| | 83 | -bash: ulimit: open files: cannot modify limit: Operation not permitted |
| | 84 | }}} |