这个文件主要是用来限制用户对系统资源的使用,具体的使用方法 man 5 limits.conf,里面便给出了详细的用法
user@db-2:~$ cat /etc/security/limits.conf # /etc/security/limits.conf # #Each line describes a limit for a user in the form: # #<domain> <type> <item> <value> # #Where: #<domain> can be: # - an 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 files # 最大打开的文件数(以文件描叙符,file descripter计数) # - 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 # - 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 # - msgqueue - max memory used by POSIX message queues (bytes) # - nice - max nice priority allowed to raise to # - rtprio - max realtime priority # #<domain> <type> <item> <value> # root soft nofile 200000 root hard nofile 200000 admin hard nofile 65536 admin soft nofile 65536 # End of file
每行的格式:用户名/用户组 类型(硬限制、软限制) 选项 值
比如很多朋友可能在使用mysql的时候遇到two many open files的错误,此时便可以通过将运行mysqld的用户的 nofile(最大打开文件数)这个值增大一点,例如
db_running_user - nofile 设定一个合理的值
注意上面的第二列 ‘-’表示hard和soft,可以显示的为soft和hard写两行