不绑定到localhost时,elasticsearch文件描述符和vm警告会出错吗?

时间:2018-05-16 01:30:29

标签: elasticsearch

对于那些试图为自己解决这些错误的帖子(而我只是询问他们意味着什么),我提供了我的步骤在这篇文章的底部是为了摆脱错误。

已安装elasticsearch并且可以从localhost访问,但在尝试从远程计算机连接时出现超时问题。在尝试修复之前尝试修复抛出错误,只是警告。

此其他帖子(Installed elastic search on server but cannot connect to it if from another machine)可能已过时,因为检查elasticsearch.yml时,似乎没有network.bind_host变量且该帖子似乎指的是旧版本。但是尽可能地遵循它,运行

[me@mapr07 config]$ netstat -ntlp | awk '/[j]ava/'
(Not all processes could be identified, non-owned process info
 will not be shown, you would have to be root to see it all.)          
tcp6       0      0 127.0.0.1:9200          :::*                    LISTEN      21109/java          
tcp6       0      0 ::1:9200                :::*                    LISTEN      21109/java  

表明我们绑定到localhost和"如果绑定到localhost(即127.0.0.1),则只能接受来自localhost的连接,而不能通过网络接受连接。"({{3 ()我不太了解网络内容。

在弹性搜索文档(https://stackoverflow.com/a/24057311/8236733)中,尝试将network.bind_host中的$ES_HOME/config/elasticsearch.yml变量设置为0.0.0.0(与原始帖子中一样)。但是,在重新进行弹性搜索之后,我们看到了输出:

[2018-05-15T14:49:54,395][INFO ][o.e.n.Node               ] [TjtCCG8] starting ...
[2018-05-15T14:49:54,603][INFO ][o.e.t.TransportService   ] [TjtCCG8] publish_address {127.0.0.1:9300}, bound_addresses {[::]:9300}
[2018-05-15T14:49:54,620][INFO ][o.e.b.BootstrapChecks    ] [TjtCCG8] 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]

[2018-05-15T14:49:54,641][INFO ][o.e.n.Node               ] [TjtCCG8] stopping ...
[2018-05-15T14:49:54,670][INFO ][o.e.n.Node               ] [TjtCCG8] stopped
[2018-05-15T14:49:54,670][INFO ][o.e.n.Node               ] [TjtCCG8] closing ...
[2018-05-15T14:49:54,701][INFO ][o.e.n.Node               ] [TjtCCG8] closed

我不知道这是怎么发生的,我也不知道为什么它甚至是一个真正的问题,因为它以前把这个错误当作绑定到localhost时的警告并且无论如何都会运行,例如。

[2018-05-15T15:01:32,017][INFO ][o.e.n.Node               ] [TjtCCG8] starting ...
[2018-05-15T15:01:32,283][INFO ][o.e.t.TransportService   ] [TjtCCG8] publish_address {127.0.0.1:9300}, bound_addresses {[::1]:9300}, {127.0.0.1:9300}

[2018-05-15T15:01:32,303][WARN ][o.e.b.BootstrapChecks    ] [TjtCCG8] max file descriptors [4096] for elasticsearch process is too low, increase to at least [65536]
[2018-05-15T15:01:32,304][WARN ][o.e.b.BootstrapChecks    ] [TjtCCG8] max virtual memory areas vm.max_map_count [65530] is too low, increase to at least [262144]

[2018-05-15T15:01:35,372][INFO ][o.e.c.s.MasterService    ] [TjtCCG8] zen-disco-elected-as-master ([0] nodes joined), reason: new_master {TjtCCG8}{TjtCCG8LQOWOE2HNFdcLxA}{ik_q1XYnTk-BBJXcBMNK_A}{127.0.0.1}{127.0.0.1:9300}

我的问题是,为什么会发生这种情况?在这两种情况下,似乎都使用了相同数量的文件描述符和vm空间,那么为什么在绑定到0.0.0.0时该数量不再仅仅是警告级别而是错误?

对于那些试图为自己解决这些错误的帖子(我只是询问他们的意思),我已经提供了以下步骤以消除错误

进行一些快速谷歌搜索,文档建议运行命令

sudo su  
ulimit -n 65536 
su elasticsearch (dont exit *back* to elasticsearch session, since new limit only applies to current session (which ends if you exit))

解决max file descriptors [4096] for elasticsearch process is too low错误,因为

  

Elasticsearch使用大量文件描述符或文件句柄。运行   超出文件描述符可能是灾难性的,并且最有可能导致   数据丢失。确保增加打开次数的限制   运行Elasticsearch的用户的文件描述符为65,536或   更高。

https://www.elastic.co/guide/en/elasticsearch/reference/current/modules-network.html#advanced-network-settings)。其次,要解决max virtual memory错误,请运行

(sudo) sysctl -w vm.max_map_count=262144

在Linux系统上,自

  

mmap计数的默认操作系统限制可能是   太低,可能导致内存不足异常

https://www.elastic.co/guide/en/elasticsearch/reference/current/file-descriptors.html#file-descriptors)。

1 个答案:

答案 0 :(得分:0)

自引导时 elasticsearch ,它会检查绑定地址是否为环回地址(127.0.0.1),如果它是环回地址它将忽略引导程序检查错误

参考:

BootstrapChecks.enforceLimits