centos7系統資源限制整理

概述在linux系統使用過程中,默認的系統設置足夠使用,但是對于一些高并發高性能的程序會有瓶頸存在,這些限制主要通過ulimit查看和修改 。
環境centos:CentOS  release 7.0 (Final)或以上版本
ulimit查看通過命令查看當前賬戶的限定設置 。
ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) unlimited
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 65536
pipe size            (512 bytes, -p) 8
POSIX message queues     (bytes, -q) unlimited
real-time priority              (-r) 0
stack size              (kbytes, -s) 8192
cpu time               (seconds, -t) unlimited
max user processes              (-u) 65536
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited
其中 , 比較常用的幾個是 。
“core file size”(coredump記錄文件大小 , 默認為0不記錄) 。
“open files”(進程打開文件最大數量,默認1024 , 網絡連接較多時會存在瓶頸) 。
“max user processes”(用戶最大進程數 , 多進程程序修改) 。
設定ulimit資源設定的修改分硬限制和軟限制 , 軟限制無法超過硬限制的上限,硬限制設定需要修改系統配置文件 。
格式和說明都在配置文件中有清晰的描述 。
vi /etc/security/limits.conf
#Each line describes a limit for a user in the form:
#
#<domain>        <type>  <item>  <value>
#
#Where:
#<domain> can be:
#        - a user name
#        - a group name, with @group syntax
#        - the wildcard *, for default entry
#        - the wildcard %, can be also used with %group syntax,
#                 for maxlogin limit
#
#<type> can have the two values:
#        - "soft" for enforcing the soft limits
#        - "hard" for enforcing hard limits
#
#<item> can be one of the following:
#        - core - limits the core file size (KB)
#        - data - max data size (KB)
#        - fsize - maximum filesize (KB)
#        - memlock - max locked-in-memory address space (KB)
#        - nofile - max number of open file descriptors
#        - rss - max resident set size (KB)
#        - stack - max stack size (KB)
#        - cpu - max CPU time (MIN)
#        - nproc - max number of processes
#        - as - address space limit (KB)
#        - maxlogins - max number of logins for this user
#        - maxsyslogins - max number of logins on the system
#        - priority - the priority to run user process with
#        - locks - max number of file locks the user can hold
#        - sigpending - max number of pending signals

推薦閱讀