Linux Open File Number problem

Source: Internet
Author: User

Too many open files

The reason for this is that the number of file/socket connections that the program opens exceeds the system setting.

To view the maximum allowable number of open files per user

Ulimit-a

fdipzone@ubuntu:~$ ulimit-a  
Core file size          (blocks,-c) 0  
data seg size           (Kbytes,-D) Unlimited  
Scheduling Priority             (-E)  
file size               (blocks,-f) Unlimited pending signals (-I                 ) 16382  
Max Locked Memory       (Kbytes, L)  
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< c24/> (Kbytes,-s) 8192  
CPU time               (seconds,-T) unlimited  
max User Processes              (-u) Unlimited  
Virtual Memory          (Kbytes,-V) unlimited  
file Locks                      (-X) Unlimited

where open files (-N) 1024 indicates that the maximum number of files allowed for each user is 1024

View the number of files currently open on the system

lsof | Wc-l  
Watch "lsof | Wc-l "

View the number of open files for a process

Lsof-p PID | Wc-l  
lsof-p 1234 | wc-l

Set the open files numeric method

Ulimit-n 2048

fdipzone@ubuntu:~$ ulimit-n 2048  
fdipzone@ubuntu:~$ ulimit-a  
core file size          (blocks,-c) 0  
data seg siz E           (Kbytes,-D) unlimited  
scheduling priority             (-E)  
file size               (blocks,-f) Unlimited  
Pending Signals                 (i) 16382  
max locked Memory (Kbytes,-       L)  
max memory size         (Kbytes, M) Unlimited  
open Files                      (-N) 2048  
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) unlimited  
virtual memory          (Kbytes,-V) unlimited  
file locks                      (x) Unlimited

This sets the maximum allowable number of open files for the current user to 2048, but this setting is restored to the default value after the reboot.

Permanent Settings method

Vim/etc/security/limits.conf  
in the last addition  
* Soft nofile 4096  
* Hard nofile 4096

The top * represents all users and can set a user as needed, such as

Fdipzone soft nofile 8192  
fdipzone hard Nofile 8192

After the change, the cancellation will be effective.

This column more highlights: http://www.bianceng.cnhttp://www.bianceng.cn/OS/Linux/

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.