无法从服务器外部访问ElasticSearch示例- Azure Windows 2012

aiazj4mn  于 2023-01-12  发布在  ElasticSearch
关注(0)|答案(5)|浏览(152)

我已在安装了Windows Server 2012 R2的Azure虚拟机中将ElasticSearch2.3.0设置为服务。我可以使用

http://localhost:9200

但我无法从服务器外部访问。
我试过什么?

  • 只是为了测试,我让VM在虚拟网络之外可用。
  • 已在Windows防火墙设置中打开端口9200作为入站流量规则
  • 在开放端口9200的Azure门户设置中添加了终结点

在VM Classic中也尝试了此操作。
同样为了测试VM是否正常,我在那台机器上设置了IIS,打开了80端口。默认的IIS页面可以从外部访问。
我唯一没有尝试过的是在Linux VM中设置ES。
我在elasticsearch日志中找不到任何东西。在浏览器(Chrome)上,网络中没有日志。它只是旋转,等待服务器,并与“ERR_EMPTY_RESPONSE”快照。
做过这件事的人能给我们一些启示吗?
更新:以下是我在netstat中看到的内容:

TCP    127.0.0.1:9200         machine-name:0       LISTENING
TCP    127.0.0.1:9300         machine-name:0       LISTENING
0mkxixxg

0mkxixxg1#

从ES 2.0开始,elasticsearch进程只绑定到localhost,这就解释了为什么您可以从内部查询ES而不能从外部查询。
您需要在elasticsearch.yml配置文件中更改以下设置:

network.host: 0.0.0.0
gk7wooem

gk7wooem2#

我也有同样的案子。查了一下记录

tail -f /var/log/elasticsearch/NODE.log

我看到了这个:

[NODE_NAME] publish_address {10.XXX.XXX.XXX:9300}, bound_addresses {10.XXX.XXX.XXX:9300}
 [NODE_NAME] bound or publishing to a non-loopback address, enforcing bootstrap checks
 [NODE_NAME] node validation exception
 [1] bootstrap checks failed
 [1]: 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
 [NODE_NAME] stopping ...
 [NODE_NAME] stopped

解决方案:

使用以下命令修改discorverseed行中的归档文件/etc/elasticsearch/elasticsearch.yml

discovery.seed_hosts: ["127.0.0.1", "[::1]"]

好的。

lrpiutwd

lrpiutwd3#

我建议将www.example.com设置network.host为特殊值
例如

network.host: [_local_, _site_]

这对我有用。

mspsb9vt

mspsb9vt4#

请注意,对我来说,成功是在设置后才取得的

http.host: 0.0.0.0

代替

http.host: "localhost"
pu3pd22g

pu3pd22g5#

解决了我在Windows Server 2012上与ElasticSearch7.1.1添加到C:\ProgramData\Elastic\ElasticSearch\配置\ElasticSearch.yml以下配置:

http.host: 0.0.0.0

相关问题