gpt4 book ai didi

linux - linux 上用户和 linux 系统范围内的打开文件数是多少?

转载 作者:IT王子 更新时间:2023-10-29 01:26:55 30 4
gpt4 key购买 nike

<分区>

抱歉,这个问题有好几层,但都涉及打开文件的数量。

我在我正在开发的应用程序的应用程序日志中收到一条消息“打开的文件太多”。有人建议我:

  1. 查找当前正在使用的打开文件数、系统范围和每个用户
  2. 找出系统和用户打开文件的限制是多少。

我运行了 ulimit -n 并返回了 1024。我还查看了/etc/limits.conf 并且该文件中没有任何特殊内容。/etc/sysctl.conf 也没有修改。我将在下面列出文件的内容。我还运行了 lsof | wc -l,它返回了 5000 多行(如果我正确使用它的话)。

所以,我的主要问题是:

  1. 如何找到允许每个用户打开的文件数?软限制是在/etc/limits.conf 中找到/定义的 nofile 设置吗?由于我没有触及/etc/limits.conf,默认值是多少?
  2. 如何找到系统范围内允许打开的文件数?它是 limits.conf 中的硬限制吗?如果不修改 limits.conf,默认值是多少?
  3. ulimit 为打开的文件返回的数字是多少?它说 1024 但是当我运行 lsof 并计算行数时,它超过 5000+ 所以我没有点击。是否有其他我应该运行的命令或要查看的文件以获得这些限制?预先感谢您的帮助。

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
# - 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
#
#<domain> <type> <item> <value>
#

#* soft core 0
#* hard rss 10000
#@student hard nproc 20
#@faculty soft nproc 20
#@faculty hard nproc 50
#ftp hard nproc 0
#@student - maxlogins 4

# End of file

sysctl.conf 的内容

# Controls IP packet forwarding
net.ipv4.ip_forward = 0

# Controls source route verification
net.ipv4.conf.default.rp_filter = 1

# Do not accept source routing
net.ipv4.conf.default.accept_source_route = 0

# Controls the System Request debugging functionality of the kernel
kernel.sysrq = 0

# Controls whether core dumps will append the PID to the core filename
# Useful for debugging multi-threaded applications
kernel.core_uses_pid = 1

# Controls the use of TCP syncookies
net.ipv4.tcp_syncookies = 1

# Controls the maximum size of a message, in bytes
kernel.msgmnb = 65536

# Controls the default maxmimum size of a mesage queue
kernel.msgmax = 65536

# Controls the maximum shared segment size, in bytes
kernel.shmmax = 68719476736

# Controls the maximum number of shared memory segments, in pages
kernel.shmall = 4294967296

# the interval between the last data packet sent and the first keepalive probe
net.ipv4.tcp_keepalive_time = 600

# the interval between subsequential keepalive probes
net.ipv4.tcp_keepalive_intvl = 60

# the interval between the last data packet sent and the first keepalive probe
net.ipv4.tcp_keepalive_time = 600

# the interval between subsequential keepalive probes
net.ipv4.tcp_keepalive_intvl = 60

# the number of unacknowledged probes to send before considering the connection dead and notifying the application layer
net.ipv4.tcp_keepalive_probes = 10

# the number of unacknowledged probes to send before considering the connection dead and notifying the application layer
net.ipv4.tcp_keepalive_probes = 10

# try as hard as possible not to swap, as safely as possible
vm.swappiness = 1
fs.aio-max-nr = 1048576
#fs.file-max = 4096

30 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com