I'm trying to get Elasticsearch 2.0 up and running in a Vagrant VM. The method I was using for 1.7 no longer works, so I'm trying to update my method. I can get ES 2.0 installed in the VM, and it seems to work fine from within the VM, but I can't access it from outside the VM. It's like the VM isn't port-forwarding port 9200 for some reason, even though I'm telling it to. So I'm trying to figure out what I'm doing wrong.
Given this 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
my old bootstrap.sh
works fine:
#!/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
I mean that it works in the sense that, from the host OS (OS X 10.9.5) I can curl ES just fine:
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"
}
But when I use this new version of bootstrap.sh
which I cooked up by trying to follow the Elasticsearch documents (always an arduous task):
#!/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
does NOT work. From inside the VM, curl localhost:9200
works as expected, but from the host OS I get:
es200 > curl localhost:9200
curl: (52) Empty reply from server
What am I missing here? Can anybody tell me why isn't the new version port forwarding?