AskOverflow.Dev

AskOverflow.Dev Logo AskOverflow.Dev Logo

AskOverflow.Dev Navigation

  • 主页
  • 系统&网络
  • Ubuntu
  • Unix
  • DBA
  • Computer
  • Coding
  • LangChain

Mobile menu

Close
  • 主页
  • 系统&网络
    • 最新
    • 热门
    • 标签
  • Ubuntu
    • 最新
    • 热门
    • 标签
  • Unix
    • 最新
    • 标签
  • DBA
    • 最新
    • 标签
  • Computer
    • 最新
    • 标签
  • Coding
    • 最新
    • 标签
主页 / server / 问题

问题[ulimit](server)

Martin Hope
Ror
Asked: 2022-03-29 02:41:01 +0800 CST

Wildfly:打开的文件太多

  • 0

我们最近在 debian 9 上的生产 Wildfly 17 中遇到“打开的文件过多”错误。简单地重新启动 wildfly 服务即可消除该错误,但我想避免再次出现该问题。我想增加限制,但我不确定我应该更改什么以及如何知道已考虑的配置。

我检查了无登录 Wildfly 用户的 ulimit:

    sudo su - wildfly -c 'ulimit -a' -s '/bin/bash'
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 117724
max locked memory       (kbytes, -l) 64
max memory size         (kbytes, -m) unlimited
open files                      (-n) 1024
pipe size            (512 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) 117724
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

用户的限制似乎设置为 1024。但是我可以通过我的 wildfly 进程检查打开文件的数量,我有这个:

sudo ls -l /proc/PID/fd |wc -l
1296

这大于限制,我现在没有收到任何错误。有没有办法永久设置更高的限制?也许在wildfly配置文件中?我有点失落。

linux debian ulimit wildfly
  • 1 个回答
  • 331 Views
Martin Hope
Janez Kuhar
Asked: 2021-11-07 09:35:53 +0800 CST

如何为 Linux 主机上的 Docker 容器内运行的超过 500,000 个连接设置 HAProxy?

  • 0

我希望我的 HAProxy 负载均衡器能够处理至少 1M 的连接。我需要这个来部署压力测试。

我尝试设置:

maxconn 1000000

在我haproxy.cfg但 HAProxy 未能开始:

[haproxy.main()] Cannot raise FD limit to 2000029, limit is 1048576.

我在 Ubuntu Linux 20.04 LTS 上的 Docker 容器中运行 HAProxy,它是一个 Amazon AWS Lightsail VPS 实例。

我查看了互联网上有关如何手动增加open files限制(ulimit -n)并将粘贴的大量配置复制到我的主机中的各种问题。没有任何效果 - 我无法将此限制增加到高于 1048576 的任何值。

我发现以下有关打开文件数量硬限制的相关帖子:

  • 修复ulimit:打开文件:无法修改限制:不允许操作
  • 在 Linux 上 - 将最大打开文件数设置为无限制。可能的?

这个问题似乎与我的几乎相同:

  • 负载测试 HaProxy

我是否从错误的角度处理问题?是否有另一种方法来配置 HAProxy 以便它可以处理一百万个连接(即,不增加ulimit -n)?

linux ulimit docker haproxy
  • 1 个回答
  • 482 Views
Martin Hope
Eng7
Asked: 2021-07-09 02:04:19 +0800 CST

CentOS:ulimit 硬/软限制保持重置为默认值

  • 0

我CentOS7正在尝试更改以下值ulimit:

ulimit -Hn 262144
ulimit -Sn 100000

但在退出后,该值将被重置为其默认值:

[root@server001]# ulimit -Hn
4096
[root@server001]# ulimit -Sn
1024

我是否以这种方式永久设置值?如果没有,怎么办?

如果它是永久性的,为什么它会恢复到默认值?

linux centos ulimit
  • 1 个回答
  • 1183 Views
Martin Hope
alexus
Asked: 2020-06-27 13:03:50 +0800 CST

应设置为 65000 以避免操作中断

  • 6

我正在关注将 Solr 投入生产 Apache Solr 参考指南 8.5solr ,但是在重新启动服务时无法克服警告:

# service solr restart
*** [WARN] *** Your open file limit is currently 1024.
 It should be set to 65000 to avoid operational disruption.
 If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
*** [WARN] ***  Your Max Processes Limit is currently 1024.
 It should be set to 65000 to avoid operational disruption.
 If you no longer wish to see this warning, set SOLR_ULIMIT_CHECKS to false in your profile or solr.in.sh
Sending stop command to Solr running on port 8983 ... waiting up to 180 seconds to allow Jetty process 16065 to stop gracefully.
Waiting up to 180 seconds to see Solr running on port 8983 [\]
Started Solr server on port 8983 (pid=16320). Happy searching!

# 

我的系统:

# cat /etc/redhat-release
Red Hat Enterprise Linux Server release 6.10 (Santiago)
# uname -a
Linux X.X.X 2.6.32-754.30.2.el6.x86_64 #1 SMP Fri May 29 04:45:43 EDT 2020 x86_64 x86_64 x86_64 GNU/Linux
# 

之后man 5 limits.conf:

# cat /etc/security/limits.d/498-solr.conf
solr    hard    nofile  65000
solr    hard    nproc   65000
#

但是,在重新启动 solr 服务时,我仍然收到该警告消息。

请指教)

提前致谢!


@MirceaVutcovici:

# grep 'Max processes' /proc/$(pgrep solr)/limits
grep: /proc//limits: No such file or directory
# pgrep solr
# echo $?
1
# ps ax | grep solr
 1926 ?        Sl     2:37 java -server -Xms512m -Xmx512m -XX:+UseG1GC -XX:+PerfDisableSharedMem -XX:+ParallelRefProcEnabled -XX:MaxGCPauseMillis=250 -XX:+UseLargePages -XX:+AlwaysPreTouch -verbose:gc -XX:+PrintHeapAtGC -XX:+PrintGCDetails -XX:+PrintGCDateStamps -XX:+PrintGCTimeStamps -XX:+PrintTenuringDistribution -XX:+PrintGCApplicationStoppedTime -Xloggc:/var/solr/logs/solr_gc.log -XX:+UseGCLogFileRotation -XX:NumberOfGCLogFiles=9 -XX:GCLogFileSize=20M -Dsolr.jetty.inetaccess.includes= -Dsolr.jetty.inetaccess.excludes= -Dsolr.log.dir=/var/solr/logs -Djetty.port=8983 -DSTOP.PORT=7983 -DSTOP.KEY=solrrocks -Dhost=rlos.uftwf.local -Duser.timezone=UTC -Djetty.home=/opt/solr/server -Dsolr.solr.home=/var/solr/data -Dsolr.data.home= -Dsolr.install.dir=/opt/solr -Dsolr.default.confdir=/opt/solr/server/solr/configsets/_default/conf -Dlog4j.configurationFile=/var/solr/log4j2.xml -Xss256k -Dsolr.jetty.https.port=8983 -Dsolr.log.muteconsole -XX:OnOutOfMemoryError=/opt/solr/bin/oom_solr.sh 8983 /var/solr/logs -jar start.jar --module=http
 9029 pts/0    S+     0:00 grep solr
# grep 'Max processes' /proc/1926/limits
Max processes             1024                 65000                processes
#
ulimit solr rhel6
  • 1 个回答
  • 9048 Views
Martin Hope
Azeirah
Asked: 2020-05-03 07:50:11 +0800 CST

达到进程限制,但不确定如何

  • 0

我运行一个服务器,主要用于随机 Docker 容器和作为 Gitlab-CI 运行器。每隔一段时间,当服务器运行一周左右时,我就会遇到进程资源限制。

例如,我尝试配置 gitlab runner,

...
Registering runner... succeeded                     runner=gy1zjHEv
runtime: failed to create new OS thread (have 9 already; errno=11)
runtime: may need to increase max user processes (ulimit -u)
fatal error: newosproc
...

或者几分钟后,尝试安装该strace实用程序

(in dutch)
...
Instellen van strace (4.21-1ubuntu1) ...
Bezig met afhandelen van triggers voor man-db (2.8.3-2ubuntu0.1) ...
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
/usr/bin/mandb: fork failed: Hulpbron is tijdelijk onbeschikbaar
Bezig met afhandelen van triggers voor libc-bin (2.27-3ubuntu1) ...

它转化为fork failed: Resource is temporarily unavailable

有什么东西导致fork抛出EAGAIN。

超限

$ ulimit -u
core file size          (blocks, -c) 0
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 1029355
max locked memory       (kbytes, -l) 16384
max memory size         (kbytes, -m) unlimited
open files                      (-n) 32768
pipe size            (512 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) 62987
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

我的最大用户进程设置为62987,我离使用 62,000 个进程还差得很远。gitlab 异常还显示当前进程数为 9,这应该是“太高”了吗?

如果我离配置的 ulimit 不远,克隆怎么可能遇到进程资源限制?

ulimit cgroup fork
  • 1 个回答
  • 1056 Views
Martin Hope
hpy
Asked: 2020-04-10 19:36:53 +0800 CST

增加未在 RHEL 8.1 中应用的 ulimit 打开文件

  • 0

我有一个完全更新的 Red Hat Enterprise Linux (RHEL) 8.1 x86_64 系统,作为本地终端中的本地用户(即不是通过 SSH 远程),当我运行ulimit -Sn它时会说1024并ulimit -Hn产生4096. 我想增加这些数字,因为通常当我编译大型项目时gcc,该make步骤会因too many open files错误而失败。我什至尝试将编译移到podman容器中,但这并没有帮助,因为容器只是继承了我本地用户的ulimits。

这是我在主机上尝试过的:

  1. 在/etc/security/limits.conf我添加了:
*          soft nofile 32767
*          hard nofile 65535
[username] soft nofile 32767
[username] hard nofile 65535
  1. 我查了一下ls -a /etc/security/limits.d/,那里没有文件。
  2. /etc/sysctl.conf里面有一行说明fs.file-max = 65535。我也跑了sysctl -p。
  3. 我添加session required pam_limits.so到文件末尾/etc/pam.d/login。
  4. ls -a /etc/sysctl.d/显示了两个文件./ ../ 50-libreswan.conf 99-sysctl.conf@,它们都不包含与打开文件数量相关的任何内容。
  5. cat /proc/sys/fs/file-max说65535。
  6. /etc/systemd/user.conf是空的(所有行都被注释掉了),我试图明确地设置DefaultLimitNOFILE=65535.

尝试上述方法后,当我运行cat /proc/self/limitsor时prlimit,相关的输出行仍然显示:

NOFILE     max number of open files                1024      4096 files

我现在唯一的线索是,当我使用 Gnome 的系统活动应用程序查看我的进程时,当我打开一个终端窗口时,有两个 bash进程都在我的本地用户下。奇怪的是,当我cat /proc/[process id]/limits在两个进程上运行时,一个显示大32767限制,而另一个显示原始1024限制。我想检查我的~/.bashrc,~/.bash_profile但他们没有改变我的ulimit.

我难住了!

我还可以检查和尝试什么来增加我的ulimit -n? 或者 SELinux可能systemd与它有关吗?谢谢您的帮助。

编辑:根据@Gerrit 的建议,我运行systemd-cgls它说几乎所有在我的本地用户下运行的东西都在:

-.slice
├─user.slice
│ ├─user-1005.slice
│ │ ├─session-2.scope
│ │ │ └─[many entries here]
│ │ └─[email protected]
│ │   └─[many entries here]
ulimit rhel8
  • 1 个回答
  • 5609 Views
Martin Hope
beard black
Asked: 2020-01-30 01:27:38 +0800 CST

为了什么需要我为mysql之类的服务最大打开文件

  • 0

为什么我需要max_open_files来提供像 mysql 这样的服务?我正在使用一个 tomcat istance,只有 tomcat 服务可以访问我的 mysql 数据库。对于我的 tomcat istance 20 用户可以访问它们。是不是说mysql的max_open_files的limit 1就够了,因为只有tomcat访问mysql?

如果一些专家能给我一两个例子,我会很高兴。

亲切的问候

linux ubuntu mysql service ulimit
  • 1 个回答
  • 56 Views
Martin Hope
WebMaster
Asked: 2020-01-28 23:45:18 +0800 CST

Docker 无法启动

  • 0

今天我遇到了 docker 的问题,它停止了,我无法启动它

 systemctl status docker

● docker.service - Docker Application Container Engine
   Loaded: loaded (/usr/lib/systemd/system/docker.service; enabled; vendor preset: disabled)
   Active: failed (Result: exit-code) since Tue 2020-01-28 09:59:03 +0330; 1min 51s ago
     Docs: https://docs.docker.com
  Process: 2327 ExecStart=/usr/bin/dockerd -H fd:// --containerd=/run/containerd/containerd.sock (code=exited, status=205/LIMITS)
 Main PID: 2327 (code=exited, status=205/LIMITS)

Jan 28 09:59:03 example.com systemd[1]: Starting Docker Application Container Engine...
Jan 28 09:59:03 example.com systemd[1]: docker.service: main process exited, code=exited, status=205/LIMITS
Jan 28 09:59:03 example.com systemd[1]: Stopped Docker Application Container Engine.
Jan 28 09:59:03 example.com systemd[1]: Unit docker.service entered failed state.
Jan 28 09:59:03 example.com systemd[1]: docker.service failed.

我看到了status=205/LIMITS我记得 3 天前我更改了ulimit配置

# /etc/security/limits.d/custom.conf

root soft nofile 1000000
root hard nofile 1000000
* soft nofile 1000000
* hard nofile 1000000
# /etc/sysctl.conf

fs.file-max = 1000000
fs.nr_open = 1000000

在撤消更改docker成功启动后,我将fd增加到100万

这里到底有什么问题?

linux ulimit docker systemd
  • 1 个回答
  • 1762 Views
Martin Hope
DiViNe
Asked: 2019-03-19 02:16:04 +0800 CST

在 systemd 上更改 ulimit

  • 3

我找到了这个链接,展示了如何更改 systemd 上的 ulimit。

/etc/systemd/system/<servicename>.d/override.conf
[Service]
LimitNOFILE=49152

我发现一个网站建议在这些文件中更改 systemd 的 ulimit:

/etc/systemd/system.conf
/etc/systemd/user.conf

[Manager] 
DefaultLimitNOFILE=49152
  • 这两种方法有什么区别?
  • 什么是最好的做法?

感谢您的意见。

ulimit
  • 1 个回答
  • 4538 Views
Martin Hope
jouell
Asked: 2016-10-01 09:59:51 +0800 CST

Linux - 打开文件继承

  • 0

为了进行测试,我将全局打开文件限制更改为 3000:

#sysctl -w fs.file-max=3000
fs.file-max = 3000

#cat /proc/sys/fs/file-nr
2016    0       3000

我创建了一些文件:

 i=1; while [ "$i" -le 1000  ]; do : >> "$i"; i=$(($i + 1)); done

我把它们打开了:

i=1; while [ "$i" -le 1000  ]; do less  "$i" & ; i=$(($i + 1)); done

我已经看到了我刚刚制造的混乱:

ksh: /bin/less: cannot execute [Too many open files in system]

我知道我达到了极限......

# cat  /proc/sys/fs/file-nr
3008    0       3000

如果我现在提高打开文件限制(这样我就可以使用另一个控制台进行 ssh 了)并且如果我在将打开文件最大值设置为 3000 后检查最近生成的一个较少的文件,我会看到:

# cat /proc/28282/limits  | grep 'Max open files'
Limit                     Soft Limit           Hard Limit       Units
Max open files            1024                 16384            files

“硬限制”仍然设置得很高,虽然没有提到 3000。所以我们达到了系统限制,而不是每个进程的限制。

为什么不指示新创建的进程继承 3000 vs 16384?

我用一个新的 shell 登录了一个新的终端,那么为什么我的 shell 不被告知 3000 并将其传递给 less 呢?

这是一个 2.6.32 内核

ulimit linux-kernel
  • 1 个回答
  • 298 Views

Sidebar

Stats

  • 问题 205573
  • 回答 270741
  • 最佳答案 135370
  • 用户 68524
  • 热门
  • 回答
  • Marko Smith

    新安装后 postgres 的默认超级用户用户名/密码是什么?

    • 5 个回答
  • Marko Smith

    SFTP 使用什么端口?

    • 6 个回答
  • Marko Smith

    命令行列出 Windows Active Directory 组中的用户?

    • 9 个回答
  • Marko Smith

    什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同?

    • 3 个回答
  • Marko Smith

    如何确定bash变量是否为空?

    • 15 个回答
  • Martin Hope
    Tom Feiner 如何按大小对 du -h 输出进行排序 2009-02-26 05:42:42 +0800 CST
  • Martin Hope
    Noah Goodrich 什么是 Pem 文件,它与其他 OpenSSL 生成的密钥文件格式有何不同? 2009-05-19 18:24:42 +0800 CST
  • Martin Hope
    Brent 如何确定bash变量是否为空? 2009-05-13 09:54:48 +0800 CST
  • Martin Hope
    cletus 您如何找到在 Windows 中打开文件的进程? 2009-05-01 16:47:16 +0800 CST

热门标签

linux nginx windows networking ubuntu domain-name-system amazon-web-services active-directory apache-2.4 ssh

Explore

  • 主页
  • 问题
    • 最新
    • 热门
  • 标签
  • 帮助

Footer

AskOverflow.Dev

关于我们

  • 关于我们
  • 联系我们

Legal Stuff

  • Privacy Policy

Language

  • Pt
  • Server
  • Unix

© 2023 AskOverflow.DEV All Rights Reserve