I have set up 3 VMs for running elastic search using Vagrant, and ansible
(w/docker)
In my Hosts file:
I added these lines to define the 3 VM's addresses:
192.168.50.10 earth
192.168.50.11 hiveholm
192.168.50.12 moth
This just gives the private address of the VM a name
I use Vagrant to build and map 3 VM's on my Mac:
Vagrantfile:
-- mode: ruby --
vi: set ft=ruby :
ROOT = File.dirname(File.absolute_path(FILE))
Vagrantfile API/syntax version. Don't touch unless you know what you're
doing!
VAGRANTFILE_API_VERSION = '2'
Default env properties which can be overridden
Example overrides:
echo "ENV['PASSENGER_DOCKER_PATH'] ||=
'../../phusion/passenger-docker' " >> ~/.vagrant.d/Vagrantfile
echo "ENV['BASE_BOX_URL'] ||=
'd:/dev/vm/vagrant/boxes/phusion/'" >> ~/.vagrant.d/Vagrantfile
BASE_BOX_URL = ENV['BASE_BOX_URL'] ||
'https://oss-binaries.phusionpassenger.com/vagrant/boxes/'
VAGRANT_BOX_URL = ENV['VAGRANT_BOX_URL'] || BASE_BOX_URL +
'ubuntu-12.04.3-amd64-vbox.box'
VMWARE_BOX_URL = ENV['VMWARE_BOX_URL'] || BASE_BOX_URL +
'ubuntu-12.04.3-amd64-vmwarefusion.box'
BASEIMAGE_PATH = ENV['BASEIMAGE_PATH' ] || '.'
PASSENGER1_DOCKER_PATH = ENV['PASSENGER1_PATH' ] || '../vm1'
PASSENGER2_DOCKER_PATH = ENV['PASSENGER2_PATH' ] || '../vm2'
PASSENGER3_DOCKER_PATH = ENV['PASSENGER3_PATH' ] || '../vm3'
DOCKERIZER_PATH = ENV['DOCKERIZER_PATH'] || '../dockerizer'
$script = <<SCRIPT
wget -q -O - https://get.docker.io/gpg | apt-key add -
echo deb http://get.docker.io/ubuntu docker main >
/etc/apt/sources.list.d/docker.list
apt-get update -qq
apt-get install -q -y --force-yes lxc-docker
usermod -a -G docker vagrant
docker version
su - vagrant -c 'echo alias d=docker >> ~/.bash_aliases'
SCRIPT
class MyInstaller < VagrantVbguest::Installers::Linux
def install(opts=nil, &block)
super
communicate.sudo('ln -s
/opt/VBoxGuestAdditions-*/lib/VBoxGuestAdditions /usr/lib', opts, &block)
end
end
Vagrant.configure(VAGRANTFILE_API_VERSION) do |config|
config.vbguest.installer = MyInstaller
config.vm.define :vm1 do |vm1_config|
vm1_config.vm.box = 'phusion1-open-ubuntu-12.04-amd64'
vm1_config.vm.box_url = VAGRANT_BOX_URL
vm1_config.ssh.forward_agent = true
passenger_docker_path = File.absolute_path(PASSENGER1_DOCKER_PATH, ROOT)
if File.directory?(passenger_docker_path)
vm1_config.vm.synced_folder passenger_docker_path,
'/vagrant/passenger-docker'
end
baseimage_path = File.absolute_path(BASEIMAGE_PATH, ROOT)
if File.directory?(baseimage_path)
vm1_config.vm.synced_folder baseimage_path,
"/vagrant/baseimage-docker"
end
dockerizer_path = File.absolute_path(DOCKERIZER_PATH, ROOT)
if File.directory?(dockerizer_path)
vm1_config.vm.synced_folder dockerizer_path, '/vagrant/dockerizer'
end
vm1_config.vm.provider :vmware_fusion do |f, override|
override.vm.box_url = VMWARE_BOX_URL
f.vmx['displayName'] = 'baseimage-docker'
end
if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").
empty?
vm1_config.vm.provision :shell, :inline => $script
end
vm1_config.vm.network "private_network", ip: "192.168.50.10"
end
config.vm.define :vm2 do |vm2_config|
vm2_config.vm.box = 'phusion1-open-ubuntu-12.04-amd64'
vm2_config.vm.box_url = VAGRANT_BOX_URL
vm2_config.ssh.forward_agent = true
passenger_docker_path = File.absolute_path(PASSENGER2_DOCKER_PATH, ROOT)
if File.directory?(passenger_docker_path)
vm2_config.vm.synced_folder passenger_docker_path,
'/vagrant/passenger-docker'
end
baseimage_path = File.absolute_path(BASEIMAGE_PATH, ROOT)
if File.directory?(baseimage_path)
vm2_config.vm.synced_folder baseimage_path,
"/vagrant/baseimage-docker"
end
dockerizer_path = File.absolute_path(DOCKERIZER_PATH, ROOT)
if File.directory?(dockerizer_path)
vm2_config.vm.synced_folder dockerizer_path, '/vagrant/dockerizer'
end
vm2_config.vm.provider :vmware_fusion do |f, override|
override.vm.box_url = VMWARE_BOX_URL
f.vmx['displayName'] = 'baseimage-docker'
end
if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").
empty?
vm2_config.vm.provision :shell, :inline => $script
end
vm2_config.vm.network "private_network", ip: "192.168.50.11"
end
config.vm.define :vm3 do |vm3_config|
vm3_config.vm.box = 'phusion1-open-ubuntu-12.04-amd64'
vm3_config.vm.box_url = VAGRANT_BOX_URL
vm3_config.ssh.forward_agent = true
passenger_docker_path = File.absolute_path(PASSENGER3_DOCKER_PATH, ROOT)
if File.directory?(passenger_docker_path)
vm3_config.vm.synced_folder passenger_docker_path,
'/vagrant/passenger-docker'
end
baseimage_path = File.absolute_path(BASEIMAGE_PATH, ROOT)
if File.directory?(baseimage_path)
vm3_config.vm.synced_folder baseimage_path,
"/vagrant/baseimage-docker"
end
dockerizer_path = File.absolute_path(DOCKERIZER_PATH, ROOT)
if File.directory?(dockerizer_path)
vm3_config.vm.synced_folder dockerizer_path, '/vagrant/dockerizer'
end
vm3_config.vm.provider :vmware_fusion do |f, override|
override.vm.box_url = VMWARE_BOX_URL
f.vmx['displayName'] = 'baseimage-docker'
end
if Dir.glob("#{File.dirname(__FILE__)}/.vagrant/machines/default/*/id").
empty?
vm3_config.vm.provision :shell, :inline => $script
end
vm3_config.vm.network "private_network", ip: "192.168.50.12"
end
end
This builds and runs 3 VM's in a private network, using the phusion
baseimage-docker base:
I then run anansible playbook to setup the VM's so they have their own sash
ansible-playbook (terra1.yml)
- name: terra
hosts: all
user: $user
remote_user: root
sudo: yes
gather_facts: yes
tasks:
- name: install pip
shell: apt-get -y install python-pip
- name: install docker-py
pip: name=docker-py state=present
- name: Do the docker build
shell: cd /vagrant/image && docker build -t traintracks_image_9 .
- name: Run the container
docker: ports=45678:22,54328:54328,9200:9200,9201:9201,9202:9202,9300:
9300,9301:9301,9302:9302
name=test_traintracks_image_9g image=traintracks_image_9
Run using this command:
ansible-playbook terra1.yml -i hosts.ini -user=root --ask-pass -vvvv
this installs a couple of things and builds the base image inside the
container with the build step and then runs it.
(Note this is applied to all 3 VMs but in this testing I am just building
out the first vm (earth))
Last step install and setup and run ElastciSearch:
I have reused the "the-ansibles" project playbook as a base for out
playbook to setup and run elastic search
Project is called traintracks
ansible-playbook: terra_es1.yml:
file: terra_es1.yml
-
name: terra
hosts: allremote_user: root
sudo: yesgather_facts: yes
vars_files:
- host_vars/earth
roles:
- role: auth
tags: step Begin - role: common
tags: step Common - role: security
tags: Step Security - role: ssl
tags: step SSL - role: monit
tags: step MONIT - role: python
tags: step PYTHON - role: jdk
tags: step JDK - role: elasticsearch
tags: step ElasticSearch
Run with this command:
ansible-playbook terra_es1.yml -i terra1.ini -user=root -vvvv
installs and sets up all the required packages and finally installs elastic
search
All these installation steps seem to SUCCEED or more correctly show no
errors and we basically have not changed anything.
But when you go into the docker container
(ssh root@earth -p 45678)
and look at the supervisord log and the elasticsearch log it shows this
problem it shows this error:
[2014-05-22 10:15:57,306][INFO ][node ] [Apryll] version
[0.90.5], pid[2456], build[c8714e8/2013-09-17T12:50:20Z]
[2014-05-22 10:15:57,307][INFO ][node ] [Apryll]initializing
...
[2014-05-22 10:15:57,313][INFO ][plugins ] [Apryll] loaded
[], sites []
[2014-05-22 10:15:59,390][INFO ][node ] [Apryll]initialized
[2014-05-22 10:15:59,390][INFO ][node ] [Apryll]starting
...
[2014-05-22 10:15:59,467][ERROR][bootstrap ] [Apryll] {0.90.5
}: Startup Failed ...
- BindTransportException[Failed to bind to [9300]]
ChannelException[Failed to bind to: /192.168.50.10:9300]
BindException[Cannot assign requested address]
I run netstat andit shows nothing is using the 9300 port but ES fails to
bind it!
netstat -lc
Active Internet connections (only servers)
Proto Recv-Q Send-Q Local Address Foreign Address State
tcp 0 0 82346d809c2f:domain : LISTEN
tcp 0 0 *:ssh : LISTEN
tcp6 0 0 [::]:ssh [::]:* LISTEN
udp 0 0 82346d809c2f:domain :
udp 0 0 82346d809c2f:ntp :
udp 0 0 localhost:ntp :
udp 0 0 *:ntp :
udp6 0 0 fe80::34db:98ff:fe1:ntp [::]:*
udp6 0 0 localhost:ntp [::]:*
udp6 0 0 [::]:ntp [::]:*
Active UNIX domain sockets (only servers)
Proto RefCnt Flags Type State I-Node Path
unix 2 [ ACC ] STREAM LISTENING 55239 @/tmp/fam-root-
unix 2 [ ACC ] STREAM LISTENING 55224 /var/run/fail2ban
/fail2ban.sock
This seems to indicate that nothing is using port 9300
but I run the elastic search command from the command line inside the
docker Container:
So I killed supervisord and ran the elasticsearch command from the ssh shell
/usr/local/etc/elasticsearch/bin/elasticsearch -f
I GET THIS:
root@82346d809c2f:~# /usr/local/etc/elasticsearch/bin/elasticsearch -f
[2014-05-22 10:42:03,447][INFO ][node ] [Fan Boy]version
[0.90.5], pid[11886], build[c8714e8/2013-09-17T12:50:20Z]
[2014-05-22 10:42:03,448][INFO ][node ] [Fan Boy]initializing
...
[2014-05-22 10:42:03,454][INFO ][plugins ] [Fan Boy]loaded
[], sites []
[2014-05-22 10:42:05,564][INFO ][node ] [Fan Boy]initialized
[2014-05-22 10:42:05,564][INFO ][node ] [Fan Boy]starting
...
[2014-05-22 10:42:05,639][ERROR][bootstrap ] [Fan Boy] {0.90.
5}: Startup Failed ...
- BindTransportException[Failed to bind to [9300]]
ChannelException[Failed to bind to: /192.168.50.10:9300]
BindException[Cannot assign requested address]
But I dont get more information
Any help would be appreciated!
Jeff Wilson
heisenberg@traintracks.io
--
You received this message because you are subscribed to the Google Groups "elasticsearch" group.
To unsubscribe from this group and stop receiving emails from it, send an email to elasticsearch+unsubscribe@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/elasticsearch/53c94b26-94b1-4cfb-ba3f-892f1d4a1edf%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.