(GO) Linux open files too many open file solution

Source: Internet
Author: User
Tags posix

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

  1. [Email protected]:~$ ulimit-a
  2. Core file size (blocks,-c) 0
  3. Data seg Size (Kbytes,-D) Unlimited
  4. Scheduling Priority (-e )
  5. File size (blocks,-f) Unlimited
  6. Pending signals (-i) 16382
  7. Max locked Memory (Kbytes,-l )
  8. Max memory Size (Kbytes,-m) unlimited
  9. Open files (-N) 1024x768
  10. Pipe size (bytes,-p) 8
  11. POSIX message queues (bytes,-q) 819200
  12. Real-time priority (-R) 0
  13. Stack size (Kbytes,-s) 8192
  14. CPU time (seconds,-t) unlimited
  15. MAX User Processes (-u) Unlimited
  16. Virtual Memory (Kbytes,-V) Unlimited
  17. 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

    1. lsof | wc-l
    2. watch "lsof | Wc-l "

View the number of open files for a process

    1. lsof-p pid | wc-l
    2. lsof-p 1234 | wc-l

Set the open files numeric method

Ulimit-n 2048

  1. [email protected]:~$ ulimit-n 2048
  2. [email protected]:~$ ulimit-a
  3. core file size (blocks,-c) 0
  4. Data seg Size (Kbytes,-D) Unlimited
  5. scheduling Priority (-e )
  6. file Size (blocks,-f) Unlimited
  7. pending Signals (-i) 16382
  8. Max locked Memory (Kbytes,-l )
  9. max memory Size (Kbytes,-m) Unlimited
  10. Open Files (-N) 2048
  11. Pipe Size (bytes,-p) 8
  12. POSIX message queues (bytes,-q) 819200
  13. real-Time Priority(-R) 0
  14. stack size (Kbytes,-s) 8192
  15. CPU Time (seconds,-T) unlimited
  16. MAX User Processes (-u) Unlimited
  17. virtual Memory (Kbytes,-V) Unlimited
  18. 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

Related Article

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.