Tomcat在我的工作站上运行了好几天,现在它没有响应,lsof命令输出大量的close_wait状态连接,tomcat pid是25422,但是ulimit命令显示“打开文件”是1024,怎么会发生这种情况?
[root@localhost home]# lsof -p 25422 | wc -l
10309
[root@localhost home]# ulimit -a
core file size (blocks, -c) 0
data seg size (kbytes, -d) unlimited
scheduling priority (-e) 0
file size (blocks, -f) unlimited
pending signals (-i) 399360
max locked memory (kbytes, -l) 32
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) 10240
cpu time (seconds, -t) unlimited
max user processes (-u) 399360
virtual memory (kbytes, -v) unlimited
file locks (-x) unlimited
答案 0 :(得分:1)
对于打开文件,我们在linux os上有软/硬打开文件限制。
如果达到软限制,它只会将限制扩展到更高限制但在硬限制下。
通过检查硬限制,您只需运行:
# ulimit -Hn
这篇文章可以帮助您了解更多信息:
Guide to limits.conf / ulimit /open file descriptors under linux
答案 1 :(得分:0)
并不是lso中的每种类型的条目都属于ulimit。取消运行以下命令,仅获取那些计入ulimit的fds
lsof -p <pid> -d '^cwd,^err,^ltx,^mem,^mmap,^pd,^rtd,^txt' -a
答案 2 :(得分:0)
在没有任何选项的情况下,lsof 列出所有属于 所有活动进程。
如果你想获得内核级别的限制,使用下面的命令
//https://www.typescriptlang.org/docs/handbook/compiler-options.html
{
"compilerOptions": {
"lib": ["es2016", "es6", "es5", "dom"],
"declaration": true,
"target": "es5",
"module": "commonjs",
"jsx": "react",
// Report errors for fallthrough cases in switch statement.
"noFallthroughCasesInSwitch": true,
// Report errors on unused locals.
"noUnusedLocals": true,
// Report errors on unused parameters.
"noUnusedParameters": false,
"moduleResolution": "node",
// enabled to skip annoying issue with @types/react-native conflict with @types/node
"skipLibCheck": true,
"outDir": "es5",
"experimentalDecorators": true,
"sourceMap": true,
"allowSyntheticDefaultImports": true,
"baseUrl": "."
},
"include": ["src/**/*", "tst/**/*"],
"exclude": ["build", "dist", "node_modules/**/*", "tst/**/*"]
}
你会得到一个非常大的数字。
综上所述,lsof可能大于ulimit,肯定小于file-max。