解决elasticsearch配置network.host: 0.0.0.0导致elasticsearch服务启动不成功的问题

一、问题概述
在本地的虚拟机linux上安装的elasticsearch

当修改 elasticsearch.yml 文件的 network.host: 0.0.0.0 时,引起了一系列异常,导致服务无法成功启动

 network.host: 0.0.0.0

引起的问题:elasticsearch服务进程启动一会之后,通过jps命令查看到进程关闭,命令行不提示错误。打开另一个命令行窗口,输入 curl 127.0.0.1:9200 提示 curl: (7) couldn’t connect to host 错误。

二、解决思路
elasticsearch下有个logs包,里面有个elasticsearch.log 日志文件,可查看错误日志排查问题。

错误日志如下:

9-04-26T03:28:02,929][DEBUG][o.e.a.ActionModule       ] [localhost.localdomain] Using REST wrapper from plugin org.elasticsearch.xpack.security.Security
[2020-04-26T03:28:03,778][INFO ][o.e.d.DiscoveryModule    ] [localhost.localdomain] using discovery type [zen] and seed hosts providers [settings]
[2020-06-06T03:28:05,374][INFO ][o.e.n.Node               ] [localhost.localdomain] initialized
[2020-06-06T03:28:05,374][INFO ][o.e.n.Node               ] [localhost.localdomain] starting ...
[2020-06-06T03:28:05,856][INFO ][o.e.t.TransportService   ] [localhost.localdomain] publish_address {192.168.10.50:9300}, bound_addresses {192.168.33.121:9300}
[2020-06-06T03:28:05,862][INFO ][o.e.b.BootstrapChecks    ] [localhost.localdomain] bound or publishing to a non-loopback address, enforcing bootstrap checks
[2020-06-06T03:28:05,915][ERROR][o.e.b.Bootstrap          ] [localhost.localdomain] node validation exception
[4] bootstrap checks failed
[1]: max file descriptors [4096] for elasticsearch process is too low, increase to at least [65535]
[2]: max number of threads [3818] for user [admin] is too low, increase to at least [4096]
[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]
[4]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, discovery.seed_providers, cluster.initial_master_nodes] must be configured
[2020-06-06T03:28:05,928][INFO ][o.e.n.Node               ] [localhost.localdomain] stopping ...
[2020-06-06T03:28:05,939][INFO ][o.e.n.Node               ] [localhost.localdomain] stopped
[2020-06-06T03:28:05,940][INFO ][o.e.n.Node               ] [localhost.localdomain] closing ...
[2020-06-06T03:28:05,955][INFO ][o.e.n.Node               ] [localhost.localdomain] closed
[2020-06-06T03:28:05,956][INFO ][o.e.x.m.p.NativeController] [localhost.localdomain] Native controller process has stopped - no new native processes can be started

主要关注以下错误日志

异常日志1

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

解决方案:

vim /etc/security/limits.conf
* soft nofile 65535
* hard nofile 65535

异常日志2

[2]: max number of threads [3818] for user [admin] is too low, increase to at least [4096]

解决方案:

vim /etc/security/limits.conf
* soft nproc  4096
* hard nproc  4096

异常日志3

[3]: max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

解决方案:

vim /etc/sysctl.conf 
vm.max_map_count=655360 

异常日志4

[4]: the default discovery settings are unsuitable for production use; at least one of [discovery.seed_hosts, 

解决方案:

vim /usr/local/elasticsearch/elasticsearch-7.0.0/config/elasticsearch.yml      
cluster.initial_master_nodes: ["node-1"]                  //最后添加一下行即可解决

猜你喜欢

转载自blog.csdn.net/Xiao_Xiao_Niao_/article/details/106592910