Can't get elasticsearch to run as a service on

2020-07-24 04:08发布

问题:

I've read three of the solutions provided here and here and here. Followed those three however it doesn't work. Whenever I tried running elasticsearch as a service:

/etc/init.d/elasticsearch start

it always gives me:

Waiting for ElasticSearch................................
WARNING: ElasticSearch may have failed to start.

Now when I try to find the error log (/var/log/elasticsearch), it's never there. ANy idea?

回答1:

Make sure that you have the JDK and you have specified the JAVA_HOME and the ES_HOME vars.

The following snippet works for me:

sudo apt-get install openjdk-6-jdk # if you haven't
sudo export JAVA_HOME=/usr/lib/jvm/java-6-openjdk-amd64 >> /etc/bash.bashrc
wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.6.tar.gz
tar xvf elasticsearch-0.90.6.tar.gz
mv elasticsearch-0.90.6 elasticsearch
cd elasticsearch
sudo export ES_HOME=`(pwd)` >> /etc/bash.bashrc
cd ./bin
./elasticsearch -f  # to run in the foreground

Whenever you want, you can type the following, in order to see what the program do:

tail -f ES_HOME/logs/elasticsearch.log

Finally, you can kill the program with the pid. There are a lot of ways. A simple is the following:

ps -ef |grep elasticsearch
kill #PID result of previous command

of more easy:

pkill -f elasticsearch


回答2:

Configure the elastic search in ubuntu. Please check here for the proper guidance.

Installing ElasticSearch on Ubuntu 12.04