gpt4 book ai didi

elasticsearch - Vagrant 和 Elasticsearch 的端口问题

转载 作者:行者123 更新时间:2023-11-29 02:49:34 25 4
gpt4 key购买 nike

我一直在尝试使用 Vagrant 在全新的 Ubuntu 机器 (ubuntu/trusty64) 中安装 Elasticsearch。

这是我在 guest 机器上运行 curl localhost:9200 时得到的结果

{
"name" : "Base",
"cluster_name" : "elasticsearch",
"version" : {
"number" : "2.3.4",
"build_hash" : "e455fd0c13dceca8dbbdbb1665d068ae55dabe3f",
"build_timestamp" : "2016-06-30T11:24:31Z",
"build_snapshot" : false,
"lucene_version" : "5.5.0"
},
"tagline" : "You Know, for Search"
}

看起来不错。但是当我在我的主机上运行相同的命令时,这就是我得到的:

curl: (52) Empty reply from server

这是我的端口转发数据(vagrant port):

    22 (guest) => 2222 (host)
80 (guest) => 8080 (host)
9200 (guest) => 9200 (host)
9300 (guest) => 9300 (host)

因此,端口似乎已正确转发, guest VM 中的 Elasticsearch 服务运行良好。

这是我在 guest 虚拟机中的防火墙配置(sudo ufw status)

To                         Action      From
-- ------ ----
22 ALLOW Anywhere
9200/tcp ALLOW Anywhere
9300/tcp ALLOW Anywhere
22 (v6) ALLOW Anywhere (v6)
9200/tcp (v6) ALLOW Anywhere (v6)
9300/tcp (v6) ALLOW Anywhere (v6)

我也有一个 Apache 服务器,在使用 localhost:8080 时运行没有问题(转发到 localhost:80)

此外,日志中没有任何异常:cat/var/log/elasticsearch/elasticsearch.log:

[2016-07-12 18:49:37,838][INFO ][node                     ] [Raymond Sikorsky] version[2.3.4], pid[2138], build[e455fd0/2016-06-30T11:24:31Z]
[2016-07-12 18:49:37,839][INFO ][node ] [Raymond Sikorsky] initializing ...
[2016-07-12 18:49:38,439][INFO ][plugins ] [Raymond Sikorsky] modules [lang-groovy, reindex, lang-expression], plugins [], sites []
[2016-07-12 18:49:38,464][INFO ][env ] [Raymond Sikorsky] using [1] data paths, mounts [[/ (/dev/sda1)]], net usable_space [35.8gb], net total_space [39.3gb], spins? [possibly], types [ext4]
[2016-07-12 18:49:38,464][INFO ][env ] [Raymond Sikorsky] heap size [1007.3mb], compressed ordinary object pointers [true]
[2016-07-12 18:49:38,464][WARN ][env ] [Raymond Sikorsky] max file descriptors [65535] for elasticsearch process likely too low, consider increasing to at least [65536]
[2016-07-12 18:49:40,455][INFO ][node ] [Raymond Sikorsky] initialized
[2016-07-12 18:49:40,455][INFO ][node ] [Raymond Sikorsky] starting ...
[2016-07-12 18:49:40,521][INFO ][transport ] [Raymond Sikorsky] publish_address {127.0.0.1:9300}, bound_addresses {127.0.0.1:9300}, {[::1]:9300}
[2016-07-12 18:49:40,527][INFO ][discovery ] [Raymond Sikorsky] elasticsearch/HqATev5kScKOXLXdl44ZLA
[2016-07-12 18:49:43,585][INFO ][cluster.service ] [Raymond Sikorsky] new_master {Raymond Sikorsky}{HqATev5kScKOXLXdl44ZLA}{127.0.0.1}{127.0.0.1:9300}, reason: zen-disco-join(elected_as_master, [0] joins received)
[2016-07-12 18:49:43,622][INFO ][http ] [Raymond Sikorsky] publish_address {127.0.0.1:9200}, bound_addresses {127.0.0.1:9200}, {[::1]:9200}
[2016-07-12 18:49:43,622][INFO ][node ] [Raymond Sikorsky] started
[2016-07-12 18:49:43,625][INFO ][gateway ] [Raymond Sikorsky] recovered [0] indices into cluster_state

我只知道服务器的基础知识。我错过了什么吗?也许这个问题与端口无关?

最佳答案

我在 ubuntu box 上运行以下命令并安装最新版本的 Elasticsearch 来尝试(2.x 中有一些重大变化)。以下是我为使其正常工作所做的步骤

更改网络绑定(bind)。

那是 breaking change 之一

Elasticsearch 2.x will only bind to localhost by default. It will try to bind to both 127.0.0.1 (IPv4) and [::1] (IPv6), but will work happily in environments where only IPv4 or IPv6 is available. This change prevents Elasticsearch from trying to connect to other nodes on your network unless you specifically tell it to do so

就像提到的一样here

I wanted to add an additional note that often this is caused by the server within the VM because it binds to 127.0.0.1, which is loopback. You'll want to make sure that the server is bound to 0.0.0.0 so that all interfaces can access it.

这里就是这种情况,我们需要更改主机属性。打开 /etc/elasticsearch/elasticsearch.yml 并添加

network.bind_host: 0
network.host: 0.0.0.0

关于elasticsearch - Vagrant 和 Elasticsearch 的端口问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38334938/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com