“打开的文件太多"在 Tomcat 密钥库上 [英] "Too many open files" on Tomcat Keystore

查看:28
本文介绍了“打开的文件太多"在 Tomcat 密钥库上的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我最近开始在我们的 Tomcat 服务器上收到错误:打开的文件太多",并且错误继续引用用于服务器 SSL 连接器的密钥库文件.有谁知道这可能来自哪里?我们的服务器接收到大量连接,但是如果我将最大可接受连接数推到 150 以上,服务器甚至不会启动(无论出于何种原因).有什么方法可以让 Tomcat 将密钥库缓存在内存中,这样连接就不必重复读取文件了吗?

I've recently started getting an error on our Tomcat servers : "Too Many Open Files" and the error goes on to reference the keystore file used for the server's SSL connector. Does anybody have any idea where this could be coming from ? Our server receives a considerable number of connections, but if I push the maximum acceptable connections past 150, the server won't even start (for whatever reason). Is there any way to get Tomcat to cache the keystore in memory so that connections don't have to read from the file repeatedly ?

推荐答案

我假设您在 Linux 上运行,因为那是我有答案的地方.

I'm going to assume that you're running on Linux, because that's where I have an answer.

第一步是检查打开文件的ulimit,并尝试在shell中将其设置得更高:

First step is to check the ulimit for open files, and try to set it higher in the shell:

ulimit -n

这可能会打印 1024,这是 Linux 的正常"用户限制.尝试设置更高的数字:

This will probably print 1024, which is the "normal" user limit for Linux. Try setting a higher number:

ulimit -n 2048

如果成功,那就太好了.将该命令放在您的登录脚本中,您应该很高兴.如果没有,那么您需要增加每个用户的限制.根据本文档,您要编辑的文件是<代码>/etc/security/limits.conf

If this succeeded, great. Put that command in your login script and you should be good to go. If not, then you need to increase the per-user limit. According to this document, the file that you want to edit is /etc/security/limits.conf

顺便说一句,您(可能)没有看到这一点,因为 Tomcat 一直在读取同一个文件.JVM 通常会打开(和内存映射)您的应用程序使用的所有 JAR 文件,并且还可能为配置文件保留打开的文件句柄.刚好在打开keystore文件时达到了限制.

Incidentally, you're (probably) not seeing this because Tomcat keeps reading the same file. The JVM normally opens (and memory-maps) all the JAR files used by your application, and may keep open file handles for config files as well. It just happens to hit the limit when opening the keystore file.

这篇关于“打开的文件太多"在 Tomcat 密钥库上的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆