ubuntu – 无法从主机操作系统访问Vagrant VM中的Elasticsearch 2.0

前端之家收集整理的这篇文章主要介绍了ubuntu – 无法从主机操作系统访问Vagrant VM中的Elasticsearch 2.0前端之家小编觉得挺不错的,现在分享给大家,也给大家做个参考。
我正在尝试让Elasticsearch 2.0在Vagrant VM中运行.我用于1.7的方法不再有效,所以我正在尝试更新我的方法.我可以在VM中安装ES 2.0,它似乎可以在VM中正常工作,但我无法从VM外部访问它.这就像VM由于某种原因而不是端口转发端口9200,即使我告诉它.所以我想弄清楚我做错了什么.

鉴于此Vagrantfile:

Vagrant.configure(2) do |config|

  config.vm.Box = "hashicorp/precise64"
  config.vm.hostname = "ES-2.0.0"
  config.vm.provision :shell,path: "bootstrap.sh"
  config.vm.network :forwarded_port,host: 9200,guest: 9200
  config.vm.synced_folder "/Users/sloan/code","/srv/code"

  config.vm.provider "virtualBox" do |v|
    v.memory = 2048
    v.cpus = 1
    v.name = config.vm.hostname.to_s
  end

end

我的旧bootstrap.sh工作正常:

#!/usr/bin/env bash

sudo apt-get update
sudo apt-get upgrade

# install openjdk-7 
sudo apt-get purge openjdk*
sudo apt-get -y install openjdk-7-jdk

# install curl
sudo apt-get -y install curl

# install Elasticsearch 1.7.3
wget https://download.elastic.co/elasticsearch/elasticsearch/elasticsearch-1.7.3.tar.gz -O elasticsearch.tar.gz
tar -xf elasticsearch.tar.gz
rm elasticsearch.tar.gz
sudo mv elasticsearch-* elasticsearch
sudo mv elasticsearch /usr/local/share

# set up ES as service
curl -L http://github.com/elasticsearch/elasticsearch-servicewrapper/tarball/master | tar -xz
sudo mv *servicewrapper*/service /usr/local/share/elasticsearch/bin/
rm -Rf *servicewrapper*
sudo /usr/local/share/elasticsearch/bin/service/elasticsearch install
sudo ln -s 'readlink -f /usr/local/share/elasticsearch/bin/service/elasticsearch' /usr/local/bin/rcelasticsearch

# start ES service
sudo service elasticsearch start

# enable cors (to be able to use Sense)
sudo echo "http.cors.enabled: true" >> /usr/local/share/elasticsearch/config/elasticsearch.yml
# enable dynamic scripting
sudo echo "script.disable_dynamic: false" >> /usr/local/share/elasticsearch/config/elasticsearch.yml

sudo service elasticsearch restart

我的意思是它的工作原理是,从主机操作系统(OS X 10.9.5)我可以很好地卷曲ES:

es173 > curl localhost:9200
{
  "status" : 200,"name" : "Gibbon","cluster_name" : "elasticsearch","version" : {
    "number" : "1.7.3","build_hash" : "05d4530971ef0ea46d0f4fa6ee64dbc8df659682","build_timestamp" : "2015-10-15T09:14:17Z","build_snapshot" : false,"lucene_version" : "4.10.4"
  },"tagline" : "You Know,for Search"
}

但是当我使用这个新版本的bootstrap.sh时,我试图遵循Elasticsearch文档(总是一项艰巨的任务)来制作它:

#!/usr/bin/env bash

sudo apt-get update
sudo apt-get upgrade

# install curl
sudo apt-get -y install curl

# install openjdk-7 
sudo apt-get purge openjdk*
sudo apt-get -y install openjdk-7-jdk

wget -qO - https://packages.elastic.co/GPG-KEY-elasticsearch | sudo apt-key add -
echo "deb http://packages.elastic.co/elasticsearch/2.x/debian stable main" | sudo tee -a /etc/apt/sources.list.d/elasticsearch-2.x.list
sudo apt-get update && sudo apt-get install elasticsearch

sudo update-rc.d elasticsearch defaults 95 10
sudo /etc/init.d/elasticsearch start

# enable cors (to be able to use Sense)
sudo echo "http.cors.enabled: true" >> /etc/elasticsearch/elasticsearch.yml
# enable dynamic scripting
sudo echo "script.disable_dynamic: false" >> /etc/elasticsearch/elasticsearch.yml

sudo /etc/init.d/elasticsearch restart

不起作用.从VM内部,curl localhost:9200按预期工作,但是从主机操作系统我得到:

es200 > curl localhost:9200
curl: (52) Empty reply from server

我在这里想念的是什么?任何人都可以告诉我为什么不是新版本的端口转发?

在/etc/elasticsearch/elasticsearch.yml配置文件中设置network.host:0.0.0.0,以便可以在localhost之外访问elasticsearch.记得做一个服务elasticsearch重启.
原文链接:https://www.f2er.com/ubuntu/347262.html

猜你在找的Ubuntu相关文章