记一次环境变量导致的elasticsearch启动错误:max file descriptors [65535] for elasticsearch process is too low, incre

问题描述,elasticsearch启动时报max file descriptors错误:

[hadoop@node-33 elasticsearch-5.4.0]$ bin/elasticsearch

[2017-11-10T14:14:46,268][INFO ][o.e.n.Node ] [node-3] initializing ...

[2017-11-10T14:14:46,344][INFO ][o.e.e.NodeEnvironment ] [node-3] using [1] data paths, mounts [[/ (/dev/mapper/rootvg-lvroot)]], net usable_space [245.7gb], net total_space [1.9tb], spins? [possibly], types [ext4]

[2017-11-10T14:14:46,344][INFO ][o.e.e.NodeEnvironment ] [node-3] heap size [1.9gb], compressed ordinary object pointers [true]

[2017-11-10T14:14:46,345][INFO ][o.e.n.Node ] [node-3] node name [node-3], node ID [piHlIcmsQyKuqfqiYtjyYw]

[2017-11-10T14:14:46,346][INFO ][o.e.n.Node ] [node-3] version[5.4.0], pid[25779], build[780f8c4/2017-04-28T17:43:27.229Z], OS[Linux/2.6.32-642.el6.x86_64/amd64], JVM[Oracle Corporation/Java HotSpot(TM) 64-Bit Server VM/1.8.0_131/25.131-b11]

[2017-11-10T14:14:46,978][INFO ][o.e.p.PluginsService ] [node-3] loaded module [aggs-matrix-stats]

[2017-11-10T14:14:46,978][INFO ][o.e.p.PluginsService ] [node-3] loaded module [ingest-common]

[2017-11-10T14:14:46,978][INFO ][o.e.p.PluginsService ] [node-3] loaded module [lang-expression]

[2017-11-10T14:14:46,978][INFO ][o.e.p.PluginsService ] [node-3] loaded module [lang-groovy]

[2017-11-10T14:14:46,979][INFO ][o.e.p.PluginsService ] [node-3] loaded module [lang-mustache]

[2017-11-10T14:14:46,979][INFO ][o.e.p.PluginsService ] [node-3] loaded module [lang-painless]

[2017-11-10T14:14:46,979][INFO ][o.e.p.PluginsService ] [node-3] loaded module [percolator]

[2017-11-10T14:14:46,979][INFO ][o.e.p.PluginsService ] [node-3] loaded module [reindex]

[2017-11-10T14:14:46,979][INFO ][o.e.p.PluginsService ] [node-3] loaded module [transport-netty3]

[2017-11-10T14:14:46,979][INFO ][o.e.p.PluginsService ] [node-3] loaded module [transport-netty4]

[2017-11-10T14:14:46,980][INFO ][o.e.p.PluginsService ] [node-3] no plugins loaded

[2017-11-10T14:14:48,325][INFO ][o.e.d.DiscoveryModule ] [node-3] using discovery type [zen]

[2017-11-10T14:14:48,779][INFO ][o.e.n.Node ] [node-3] initialized

[2017-11-10T14:14:48,780][INFO ][o.e.n.Node ] [node-3] starting ...

[2017-11-10T14:14:48,957][INFO ][o.e.t.TransportService ] [node-3] publish_address {172.25.114.59:9302}, bound_addresses {172.25.114.59:9302}

[2017-11-10T14:14:48,963][INFO ][o.e.b.BootstrapChecks ] [node-3] bound or publishing to a non-loopback or non-link-local address, enforcing bootstrap checks

ERROR: bootstrap checks failed

max file descriptors [65535] for elasticsearch process is too low, increase to at least [65536]

[2017-11-10T14:14:48,970][INFO ][o.e.n.Node ] [node-3] stopping ...

[2017-11-10T14:14:48,982][INFO ][o.e.n.Node ] [node-3] stopped

[2017-11-10T14:14:48,982][INFO ][o.e.n.Node ] [node-3] closing ...

[2017-11-10T14:14:48,990][INFO ][o.e.n.Node ] [node-3] closed

网上的解决办法都是修改/etc/security/limits.conf文件,增加hadoop hard nofile 131072一行

vi /etc/security/limits.conf
hadoop soft nofile 65536
hadoop hard nofile 131072
hadoop soft nproc 2048
hadoop hard nproc 4096

可是,我的配置本来就已经设置成这样了的
网上找来找去,都是修改limits.conf文件这个答案,最怕这种了,所有的人都指向同一个答案,却不能解决自己的问题
后来突然想到是不是环境变量的问题,仔细检查了一遍,发现一个可疑的设置

vi /etc/profile
ulimit -n 65535

使用 ulimit -Hn 查看当前值,果然是65535,

ulimit -Hn
65535

也就是说每次更新环境变量的时候limits.conf的hard nofile 131072设置被覆盖掉了
这就好办了,vi /etc/profile 将 ulimit -n 65535 行注释掉,退出重新进入当前用户,再使用 ulimit -Hn 查看当前值,已经是131072了,设置成功!

vi /etc/profile
# ulimit -n 65535
ulimit -Hn
131072

再去启动elasticsearch,OK!

上一篇:【CCNA学习笔记】1.思科路由器的基本配置


下一篇:max virtual memory areas vm.max_map_count [65530] likely too low, increase to at least [262144]