Reputation: 79
I have code for elasticsearch installation in Vagrant and I would like to run elasticsearch after vagrant up, but I get error described bellow
Error that I get, when vagrant runs elasticsearch-5.0.0
default: max file descriptors [4096] for elasticsearch process likely too low, increase to at least [65536]
install.sh file that installs elastic
# ELASTICSEARCH
# install openjdk-8
apt-get purge openjdk*
add-apt-repository ppa:webupd8team/java -y
apt-get update -y
echo "oracle-java8-installer shared/accepted-oracle-license-v1-1 select true" | sudo debconf-set-selections
apt-get install oracle-java8-installer -y
# install ES
curl -L -O https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-5.0.0.tar.gz
tar -xvf elasticsearch-5.0.0.tar.gz
sudo sysctl -w vm.max_map_count=262144
echo "vagrant soft nofile 65536" | sudo tee --append /etc/security/limits.conf
echo "vagrant hard nofile 65536" | sudo tee --append /etc/security/limits.conf
echo "session required pam_limits.so" | sudo tee --append /etc/pam.d/common-session
sudo -H -u vagrant bash -c 'ulimit -n'
# either of the next two lines is needed to be able to access "localhost:9200" from the host os
echo "network.bind_host: 0" >> elasticsearch-5.0.0/config/elasticsearch.yml
echo "network.host: 0.0.0.0" >> elasticsearch-5.0.0/config/elasticsearch.yml
# enable dynamic scripting
echo "script.inline: on" >> elasticsearch-5.0.0/config/elasticsearch.yml
# enable cors (to be able to use Sense)
echo "http.cors.enabled: true" >> elasticsearch-5.0.0/config/elasticsearch.yml
echo "http.cors.allow-origin: /https?:\/\/.*/" >> elasticsearch-5.0.0/config/elasticsearch.yml
sudo chown -R vagrant:vagrant elasticsearch-5.0.0
startup.sh that vagrant provisioner run: "always"
# elasticsearch settings and run
sudo sysctl -w vm.max_mapy_count=262144
su vagrant --shell /bin/bash --command "ulimit -n 65536"
sudo -H -u vagrant bash -c 'elasticsearch-5.0.0/bin/elasticsearch'
Upvotes: 2
Views: 1465
Reputation: 53733
I quickly tried using a ubuntu16.04 box and did not face this issue.
I changed a bit your startup script as there's a typo with vm.max_mapy_count
from Vagrantfile
config.vm.provision :shell, :path => "startup.sh", :run => 'always', :privileged => false
startup.sh
# elasticsearch settings and run
sudo sysctl -w vm.max_map_count=262144
ulimit -n 65536
nohup elasticsearch-5.0.0/bin/elasticsearch &> /home/vagrant/nohup.es.out&
Elasticsearch is starting correctly and the output is captured within a nohup file.
Upvotes: 1