Reputation: 9647
I have recently upgraded my machine from Ubuntu 14.04
to 16.04
. I am facing problem of using the elasticsearch
as a service. I installed elasticsearch
using:
sudo apt-get install elasticsearch
Now sudo service elasticsearch status
command shows me this result:
elasticsearch.service - LSB: Starts elasticsearch
Loaded: loaded (/etc/init.d/elasticsearch; bad; vendor preset: enabled)
Active: active (exited) since Sat 2016-07-30 18:28:13 BDT; 1h 19min ago
Docs: man:systemd-sysv-generator(8)
Main PID: 7988 (code=exited, status=1/FAILURE)
CGroup: /system.slice/elasticsearch.service
Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found
Jul 30 18:28:13 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 18:28:46 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 18:35:30 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 19:04:36 dimik systemd[1]: Started A search engine.
Jul 30 19:07:48 dimik systemd[1]: Started A search engine.
Jul 30 19:27:01 dimik systemd[1]: Started A search engine.
Jul 30 19:27:51 dimik systemd[1]: Started A search engine.
Jul 30 19:28:54 dimik systemd[1]: Started A search engine.
Jul 30 19:29:18 dimik systemd[1]: Started LSB: Starts elasticsearch.
Although Java is installed in my machine and I can start the server using this command.
sudo /usr/share/elasticsearch/bin/elasticsearch
I am kind of stuck here. Any help will be appreciated.
Edit
After setting up JAVA_HOME
for root the error:
elasticsearch.service - LSB: Starts elasticsearch
Loaded: loaded (/etc/init.d/elasticsearch; bad; vendor preset: enabled)
Active: active (exited) since Sat 2016-07-30 18:28:13 BDT; 3h 32min ago
Docs: man:systemd-sysv-generator(8)
Main PID: 7988 (code=exited, status=1/FAILURE)
CGroup: /system.slice/elasticsearch.service
Jul 30 18:35:30 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 19:04:36 dimik systemd[1]: Started A search engine.
Jul 30 19:07:48 dimik systemd[1]: Started A search engine.
Jul 30 19:27:01 dimik systemd[1]: Started A search engine.
Jul 30 19:27:51 dimik systemd[1]: Started A search engine.
Jul 30 19:28:54 dimik systemd[1]: Started A search engine.
Jul 30 19:29:18 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 20:02:07 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 20:20:21 dimik systemd[1]: Started LSB: Starts elasticsearch.
Jul 30 21:59:21 dimik systemd[1]: Started LSB: Starts elasticsearch.
Upvotes: 19
Views: 46772
Reputation: 1582
Have you enabled the service ?
systemctl enable elasticsearch
Upvotes: 0
Reputation: 1
Remove unnecessary java packages using
sudo apt autoremove
Then install elasticsearch again and start it as
sudo apt install elasticsearch
service elasticsearch status
Upvotes: 0
Reputation: 21
Open /etc/init.d/elasticsearch
file in editor, Comment below lines
. /usr/share/java-wrappers/java-wrappers.sh
find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
Set JAVA_HOME manually like so:
export JAVA_HOME="/usr"
service elasticsearch start
Upvotes: 2
Reputation: 9647
I found the solution for this issue. The solution comes from this discussion thread- Can’t start elasticsearch with Ubuntu 16.04 on elastic's website.
It seems that to get Elasticsearch to run on
16.04
you have to setSTART_DAEMON
to true on/etc/default/elasticsearch
. It comes commented out by default, and uncommenting it makes Elasticsearch start again just fine.Be sure to use
systemctl restart
instead of juststart
because the service is started right after installation, and apparently there's somesocket/pidfile/something
thatsystemd
keeps that must be released before being able to start the service again.
Upvotes: 40
Reputation: 570
My problem was different, I started elasticsearch manually as root user, so some files were created with wrong ownership, so elasticsearch user cannot write on them.
You can try to start elasticsearch from console to see errors:
sudo -u elasticsearch /usr/share/elasticsearch/bin/elasticsearch \
-Des.default.config=/etc/elasticsearch/elasticsearch.yml \
-Des.default.path.home=/usr/share/elasticsearch \
-Des.default.path.logs=/var/log/elasticsearch \
-Des.default.path.data=/var/lib/elasticsearch \
-Des.default.path.work=/tmp/elasticsearch \
-Des.default.path.conf=/etc/elasticsearch
To fix on my machine I had to do:
rm -rf /var/log/elasticsearch/*
rm -rf /var/lib/elasticsearch/*
Upvotes: 4
Reputation: 874
The problem lies on log files, "No java runtime was found."
Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found
Here's my solution to the problem.
Check elasticsearch init file
sudo nano /etc/init.d/elasticsearch
search for
. /usr/share/java-wrappers/java-wrappers.sh
find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
export JAVA_HOME
Check java-wrappers.sh file
sudo nano /usr/share/java-wrappers/java-wrappers.sh
Now you could see the warning comes from
#Displays a warning
java_warning() {
echo "[warning] $0: $@" >&2;
}
Now edit the jvm-list.sh file
sudo nano /usr/lib/java-wrappers/jvm-list.sh
Edit the line add your java directories files, in my case add /usr/lib/jvm/java-8-oracle*
__jvm_oracle8="/usr/lib/jvm/jdk-8-oracle-* /usr/lib/jvm/jre-8-oracle-* /usr/lib/jvm/java-8-oracle*"
Now restart the service and check elasticsearch services
sudo systemctl restart elasticsearch
sudo systemctl elasticsearch status
curl -X GET "http://localhost:9200"
Hopes this would help
Upvotes: 9