Too many open files
The reason for this is that the program opened the file/socket the number of connections exceeds the system set value.
View the maximum number of open files per user
Ulimit-a
- [Email protected]:~$ 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) 1024x768
- 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
where open files (-N) 1024 indicates that the maximum number of files allowed per user is 1024
View the number of files open on the current 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
- [email protected]:~$ ulimit-n 2048
- [email protected]:~$ 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) 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 allows you to set the maximum number of open files for the current user to 2048, but this setting will revert to the default value after a reboot.
Permanent Setup Method
vim /etc/security/limits.conf在最后加入* soft nofile 4096* hard nofile 4096
The top * represents all users and can set a user as needed, for example
fdipzone soft nofile 8192fdipzone hard nofile 8192
It will take effect if you cancel it after you change it.
Turn from: 34588803
(GO) Linux open files too many open file solution