Changes between Version 9 and Version 10 of jazz/10-05-11


Ignore:
Timestamp:
May 11, 2010, 3:46:10 PM (14 years ago)
Author:
jazz
Comment:

--

Legend:

Unmodified
Added
Removed
Modified
  • jazz/10-05-11

    v9 v10  
    1818~$ sudo sa -a            # 顯示所有程序記錄
    1919~$ sudo sa -m            # 依使用者統計
     20}}}
     21
     22 * 如何調整每個使用者可以開啟的檔案個數
     23   * [參考] [http://www.xenoclast.org/doc/benchmark/HTTP-benchmarking-HOWTO/node7.html Increasing the file descriptor limit]
     24   * 注意:修改 /etc/security/limits.conf 中間必須確定是 TAB ,如果有設定 vim 的 softwaretab 的話,得特別當心!!!
     25   * /proc/sys/fs/file-max - 核心預設最多可以開啟的檔案個數
     26{{{
     27~$ cat /proc/sys/fs/file-max
     28743964
     29}}}
     30   * /etc/security/limits.conf - 每個程序(process)可以開啟檔案的個數(number limits of open files per process) - 像 HDFS 的 !DataNode 就需要調整這種參數([wiki:jazz/10-02-22#Hadoop:HDFS 2010-02-22])
     31{{{
     32#!diff
     33--- /etc/security/limits.conf 2010-02-22 11:29:11.000000000 +0800
     34+++ /etc/security/limits.conf.new 2010-02-22 11:28:33.000000000 +0800
     35@@ -49,4 +49,6 @@
     36 #ftp             -       chroot          /ftp
     37 #@student        -       maxlogins       4
     38 
     39+*      soft        nofile        4096
     40+*      hard        nofile        743964
     41+
     42 # End of file
     43}}}
     44   * /etc/pam.d/login - 告訴系統要用 /etc/security/limits.conf 來設定一些上限
     45{{{
     46# Sets up user limits according to /etc/security/limits.conf
     47# (Replaces the use of /etc/limits in old login)
     48session    required   pam_limits.so
     49}}}
     50   * 指令: ulimit - 可以告訴你一些系統限制,並且設定想要的値
     51{{{
     52jazz@Wdebian:~$ ulimit -a
     53core file size          (blocks, -c) 0
     54data seg size           (kbytes, -d) unlimited
     55scheduling priority             (-e) 0
     56file size               (blocks, -f) unlimited
     57pending signals                 (-i) 72704
     58max locked memory       (kbytes, -l) 32
     59max memory size         (kbytes, -m) unlimited
     60open files                      (-n) 1024
     61pipe size            (512 bytes, -p) 8
     62POSIX message queues     (bytes, -q) 819200
     63real-time priority              (-r) 0
     64stack size              (kbytes, -s) 8192
     65cpu time               (seconds, -t) unlimited
     66max user processes              (-u) 72704
     67virtual memory          (kbytes, -v) unlimited
     68file locks                      (-x) unlimited
     69}}}
     70 * 假設 /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 來提高開檔個數。
     71{{{
     72~$ ulimit -n 743964
     73}}}
     74 * [備註] 如果 ulimit 超出可容許範圍,會顯示 Operation not permitted,此時請檢查相關設定値
     75{{{
     76~$ ulimit -n 7439640
     77-bash: ulimit: open files: cannot modify limit: Operation not permitted
    2078}}}
    2179