Ubuntu ulimit System Maximum open file number setting

Source: Internet
Author: User
Tags posix

There's a lot of searching on the internet, but it doesn't seem to work.

Basic commands Understand:

root@ubuntu:~#ulimit-a
Core file size (blocks,-c) 0
Data seg Size (Kbytes,-D) Unlimited
Scheduling Priority (-e) 0
File size (blocks,-f) Unlimited
Pending Signals (I.) 31498
Max locked Memory (Kbytes, L) 64
Max memory Size (Kbytes, M) Unlimited
open Files (-N) 1024
Pipe Size (bytes, p) 8
POSIX message queues (bytes,-Q) 819200
Real-time priority (-R) 0
Stack size (Kbytes,-s) 8192
CPU time (seconds,-t) unlimited
MAX User Processes (-u) 31498
Virtual Memory (Kbytes,-V) Unlimited
File locks (-X) Unlimited

The Red Word section is the number of open files 1024, generally this is too small. You can also use ulimit-n to view


How to set it, the official is like this:

First step: Configure/etc/security/limits.conf

sudo vim/etc/security/limits.conf
file tail append 
* Hard nofile 40960
* Soft Nofile 40960
4096 can set up their own, four column parameters set see English, simple to say:

The first column can be a user, or a group, using syntax such as @group, or wildcard characters such as *%

The second column, two values: hard, hard limit, soft, software limitations, generally soft than hard small, hard is the bottom line, must not exceed, more than soft alarm, until hard number

The third column, see list, open file number is Nofile

The fourth column, the quantity, this also cannot set too big


#
#Each Line describes a limit to 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 is also used with%group syntax,
# for Maxlogin limit
#-Note:group and wildcard limits are not applied to root.
# to apply a limit to the root user, <domain> must is
# the literal username root.
#
#<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 spaces (KB)
#-Nofile-max Number of open files
#-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
#-Msgqueue-max memory used by POSIX message queues (bytes)
#-Nice-max Nice priority allowed to raise to values: [-20, 19]
#-Rtprio-max Realtime Priority
#-Chroot-change Root to directory (debian-specific)
#
#<domain> <type> <item> <value>
#


#* Soft Core 0
#root Hard Core 100000


Step Two:/etc/pam.d/su (official) or/etc/pam.d/common-session (network)

sudo vim/etc/pam.d/su
pam_limits.so This line of comments to remove the 
reboot system
sudo vim/etc/pam.d/common-session
plus the following line of session
required pam_limits.so

Open/etc/pam.d/su, found to contain/etc/pam.d/common-session this file, so modify which file should be OK

This think modify su This file is better, uncomment the OK, not easy to error, vim open, positioning, X can



The official only to the second step, to restart the system, there is no third step, as if not, the feeling is not all the role of the third step.

Step Three: Configure/etc/profile

The last line Plus

Ulimit-shn 40960

Reboot, Ulimit-n verify, show 40960, no problem.



Update: 2012/9/29:

CentOS 6.3, just modify the/etc/security/limits.conf, log on OK.

Ubuntu Server 12.04.1, modify/etc/security/limits.conf, restart no use, change/etc/pam.d/common-session, su, login Restart no use, not to change/etc/ Profile?

There seems to be a difference between the two. Or I'm not testing it in place.

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.