简体   繁体   English

Vagrant和Elasticsearch的端口问题

[英]Port issues with Vagrant and Elasticsearch

I've been trying to install Elasticsearch in a brand new Ubuntu box (ubuntu/trusty64) using Vagrant. 我一直在尝试使用Vagrant在一个全新的Ubuntu盒子(ubuntu / trusty64)中安装Elasticsearch。

This is what I get when I run curl localhost:9200 in my guest machine 这是我在客机中运行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"
}

It seems good. 看起来不错。 But when I run the same command on my host, this is what I get: 但是当我在我的主机上运行相同的命令时,这就是我得到的:

curl: (52) Empty reply from server

Here are my port forwarding data ( vagrant port ): 这是我的端口转发数据( vagrant port ):

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

So, ports seems to be properly forwarded and Elasticsearch service in guest VM is running good. 因此,端口似乎被正确转发,并且来宾VM中的Elasticsearch服务运行良好。

Here's my firewall configuration in the guest VM ( sudo ufw status ) 这是来宾VM中的防火墙配置( 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)

I've also have an Apache server that runs with no problem when using localhost:8080 (forwarded to localhost:80 ) 我还有一个Apache服务器在使用localhost:8080时运行没问题localhost:8080 (转发到localhost:80

Also, nothing weird in logs: cat /var/log/elasticsearch/elasticsearch.log : 此外,日志中没有什么奇怪的: 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

I know just the basics of servers. 我只知道服务器的基础知识。 Am I missing something? 我错过了什么吗? Maybe the issue has nothing to do with ports? 也许问题与端口无关?

I run the following on ubuntu box and install latest version of elastic search to try (there has been some breaking changed in 2.x). 我在ubuntu框上运行以下命令并安装最新版本的弹性搜索试试(在2.x中有一些突破性的变化)。 Here are the steps I've done to make it work 以下是我为使其发挥作用所采取的步骤

change the network binding. 更改网络绑定。

That is one of the breaking change 这是一个突破性的变化

Elasticsearch 2.x will only bind to localhost by default. Elasticsearch 2.x默认只绑定到localhost。 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. 它将尝试绑定到127.0.0.1(IPv4)和[:: 1](IPv6),但在只有IPv4或IPv6可用的环境中可以很好地工作。 This change prevents Elasticsearch from trying to connect to other nodes on your network unless you specifically tell it to do so 此更改可防止Elasticsearch尝试连接到网络上的其他节点,除非您明确告知它这样做

like it is mentioned 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. 我想添加一个额外的注释,这通常是由VM中的服务器引起的,因为它绑定到127.0.0.1,这是环回。 You'll want to make sure that the server is bound to 0.0.0.0 so that all interfaces can access it. 您需要确保服务器绑定到0.0.0.0,以便所有接口都可以访问它。

This is the case here and we need to change the host property. 这是这种情况,我们需要更改主机属性。 open the /etc/elasticsearch/elasticsearch.yml and add 打开/etc/elasticsearch/elasticsearch.yml并添加

network.bind_host: 0
network.host: 0.0.0.0

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM