启动elasticsearch报错
报错信息如下
[2020-06-21T17:19:49,618][INFO ][o.e.n.Node ] [xKxJzr3] starting ...
[2020-06-21T17:19:49,948][INFO ][o.e.t.TransportService ] [xKxJzr3] publish_address {192.168.91.128:9300}, bound_addresses {192.168.91.128:9300}
[2020-06-21T17:19:49,978][INFO ][o.e.b.BootstrapChecks ] [xKxJzr3] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [2] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[2020-06-21T17:19:50,033][INFO ][o.e.n.Node ] [xKxJzr3] stopping ...
[2020-06-21T17:19:50,103][INFO ][o.e.n.Node ] [xKxJzr3] stopped
[2020-06-21T17:19:50,104][INFO ][o.e.n.Node ] [xKxJzr3] closing ...
[2020-06-21T17:19:50,124][INFO ][o.e.n.Node ] [xKxJzr3] closed
解决方案:
1、报错 max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]是因为操作系统vm.max_map_count参数设置太小导致的,至于设置多大的数值,我这里就直接参照报错信息的建议直接设置为262144
解决方案一:
切换到root用户下,执行以下命令:
sysctl -w vm.max_map_count=262144
检查配置是否生效
[root@localhost elasticsearch-6.1.2]# sysctl -a | grep "vm.max_map_count"
vm.max_map_count = 262144
[root@localhost elasticsearch-6.1.2]#
如果正常输出262144,则说明修改成功,然后再次启动elasticsearch,输出如下:
[2018-01-29T00:24:36,619][INFO ][o.e.n.Node ] initialized
[2018-01-29T00:24:36,619][INFO ][o.e.n.Node ] [qR5cyzh] starting ...
[2018-01-29T00:24:36,949][INFO ][o.e.t.TransportService ] [qR5cyzh] publish_address {172.19.26.110:9300}, bound_addresses {172.19.26.110:9300}
[2018-01-29T00:24:37,015][INFO ][o.e.b.BootstrapChecks ] [qR5cyzh] bound or publishing to a non-loopback address, enforcing bootstrap checks
ERROR: [1] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2018-01-29T00:24:37,038][INFO ][o.e.n.Node ] [qR5cyzh] stopping ...
[2018-01-29T00:24:37,089][INFO ][o.e.n.Node ] [qR5cyzh] stopped
[2018-01-29T00:24:37,089][INFO ][o.e.n.Node ] [qR5cyzh] closing ...
[2018-01-29T00:24:37,128][INFO ][o.e.n.Node ] [qR5cyzh] closed
这时候会发现只有一个错了,说明以上配置处理成功。
解决方案二(推荐):永久性修改
切换到root用户,备份原有配置
[root@localhost elasticsearch-6.1.2]# cd /etc
[root@localhost etc]# cp sysctl.conf sysctl.conf.bak
编辑sysctl.conf,增加如下内容
[root@localhost etc]# vim sysctl.conf
# elasticsearch config start
vm.max_map_count=262144
# elasticsearch config end
下面我们来解决另一个问题
2、报错max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]是因为操作系统安全检测配置影响的,我们需要切换到root用户下做如下配置:
先做一个配置备份
[root@localhost elasticsearch-6.1.2]# cd /etc/security/
[root@localhost security]# cp limits.conf limits.conf.bak
然后编辑limits.conf增加如下配置:
# elasticsearch config start
* soft nofile 65536
* hard nofile 131072
* soft nproc 2048
* hard nproc 4096
# elasticsearch config end
执行启动命令 ./bin/elasticsearch ,会发现指定IP已经配置好了,也正常启动。