设置参数 `node.name` 可以自定义 Elasticsearch 节点的名字。 此条 Tips 由 medcl 贡献。

es进程打开的最大文件数量可超过 limits.conf 配置的最大文件数设置?

Elasticsearch | 作者 hapjin | 发布于2019年06月02日 | 阅读数:4803

jps 可知ES的pid是9157
root@ubuntu:~# jps
9157 Elasticsearch
21223 Jps

lsof 得知 pid为9157的进程打开的文件描述符数量:763108,它超过了我配置的最大值262140,这是为什么?
root@ubuntu:~# lsof -n | awk '{print $2}' | sort | uniq -c | sort -nr | head -3
763108 9157
3315 34607
2108 42175

而我配置的线程可打开的最大文件符数量是262140,如下:
root@ubuntu:~# cat /etc/security/limits.conf 
* soft nofile 262140
* hard nofile 262140
root soft nofile 262140
root hard nofile 262140


root@ubuntu:~# ulimit -n
262140

参考ES官网文档查看配置,查看可打开的最大文件描述符也是262140
GET _nodes/stats/process?filter_path=**.max_file_descriptors
{
"nodes": {
"aEgc1DkAR2m3JadrPREfoQ": {
"process": {
"max_file_descriptors": 262140
}
},
"D2HDm2zGTl-hVUdKzpgPRQ": {
"process": {
"max_file_descriptors": 262140
}
},
"yFnfouyXTvONUxhOmMp--A": {
"process": {
"max_file_descriptors": 262140
}
},
"s3_MERRoTpSeWgk_AcG05w": {
"process": {
"max_file_descriptors": 262140
}
},
"mKkj4112T7aLeC2oNouOrg": {
"process": {
"max_file_descriptors": 262140
}
}
}
}




 
root@ubuntu:~# ulimit -a
core file size          (blocks, -c) unlimited
data seg size           (kbytes, -d) unlimited
scheduling priority             (-e) 0
file size               (blocks, -f) unlimited
pending signals                 (-i) 256086
max locked memory       (kbytes, -l) unlimited
max memory size         (kbytes, -m) unlimited
open files                      (-n) 262140
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) 256086
virtual memory          (kbytes, -v) unlimited
file locks                      (-x) unlimited

 我用的操作系统如下:
root@ubuntu:~# lsb_release -a
No LSB modules are available.
Distributor ID: Ubuntu
Description:    Ubuntu 16.04 LTS
Release:        16.04
Codename:       xenial
 
 
已邀请:

hapjin

赞同来自: rochy

找到原因了。我上面的那条命令统计的是PID=9157进程下打开的所有文件描述符(把它所创建的子进程打开的文件描述符也计算进去了)
pstree -p 9157
发现ES进程创建了很多子进程,这些子进程打开的文件描述符有一些和父进程是一样的。
 
所以用命令:lsof -n | awk '{print $2}' | sort | uniq -c | sort -nr | head -3 统计进程打开的文件描述符并不准确。

要回复问题请先登录注册