我一直在尝试使用Vagrant在一个全新的Ubuntu框(ubuntu / trusty64)中安装Elasticsearch。
这是我在访客计算机中运行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)
因此,端口似乎已正确转发,并且来宾VM中的Elasticsearch服务运行良好。
这是来宾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)
我还有一台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
我只知道服务器的基础知识。我错过了什么吗?也许问题与端口无关?
答案 0 :(得分:6)
我在ubuntu框上运行以下命令并安装最新版本的弹性搜索试试(2.x中有一些突破性的变化)。以下是我为使其发挥作用而采取的措施
更改网络绑定。
之一Elasticsearch 2.x默认只绑定到localhost。它将尝试绑定到127.0.0.1(IPv4)和[:: 1](IPv6),但在只有IPv4或IPv6可用的环境中可以很好地工作。此更改可防止Elasticsearch尝试连接到网络上的其他节点,除非您明确告知它这样做
就像提到here
一样我想添加一个额外的注释,通常这是由 VM中的服务器,因为它绑定到127.0.0.1,这是环回。 您需要确保服务器绑定到0.0.0.0以便这样做 所有接口都可以访问它。
这是这种情况,我们需要更改主机属性。打开/etc/elasticsearch/elasticsearch.yml
并添加
network.bind_host: 0
network.host: 0.0.0.0