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:
我最近把我的机器从Ubuntu 14.04升级到16.04。我面临着使用弹性搜索作为服务的问题。我安装了elasticsearch使用:
sudo apt-get install elasticsearch
Now sudo service elasticsearch status
command shows me this result:
现在sudo服务elasticsearch状态命令显示如下结果:
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.
尽管Java安装在我的机器中,我可以使用这个命令启动服务器。
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:
将JAVA_HOME设置为根错误后:
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.
4 个解决方案
#1
28
I found the solution for this issue. The solution comes form this discussion thread- Can’t start elasticsearch with Ubuntu 16.04 on elastic's website.
我找到了解决这个问题的办法。解决方案来自于这个讨论线程——无法在elastic的网站上启动Ubuntu 16.04的弹性搜索。
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.似乎要在16.04上运行弹性搜索,您必须将START_DAEMON设置为true,在/etc/default/elasticsearch上。它会在默认情况下被注释掉,取消注释会让弹性搜索重新启动。
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.一定要使用systemctl restart而不是仅仅启动,因为服务在安装之后就开始了,而且显然还有一些socket/pidfile/一些systemd保存的东西必须在能够再次启动服务之前释放出来。
#2
5
The problem lies on log files, "No java runtime was found."
问题在于日志文件,“没有找到java运行时。”
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
检查elasticsearch init文件
sudo nano /etc/init.d/elasticsearch
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
检查java包装器。sh文件
sudo nano /usr/share/java-wrappers/java-wrappers.sh
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;
}
- Somehow, java directories are not listed in jvm-list.sh files
- 不知何故,java目录不在jvm-list中列出。sh文件
Now edit the jvm-list.sh file
现在编辑jvm-list。sh文件
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*
编辑行添加java目录文件,在我的示例中是添加/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
现在重新启动服务并检查elasticsearch服务
sudo systemctl restart elasticsearch
sudo systemctl elasticsearch status
curl -X GET "http://localhost:9200"sudo systemctl重启弹性搜索sudo系统ctl弹性搜索状态curl -X获得“http://localhost:9200”
Hopes this would help
希望这将有助于
#3
2
-
Open /etc/init.d/elasticsearch file in editor, Comment below lines
打开/etc/init.d/elasticsearch文件在编辑器中,注释在下行
. /usr/share/java-wrappers/java-wrappers.sh find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
Set JAVA_HOME manually like so:
手动设置JAVA_HOME,如下所示:
export JAVA_HOME="/usr"
-
service elasticsearch start
服务elasticsearch开始
#4
1
My problem was different, I started elasticsearch manually as root user, so some files were created but elasticsearch user cannot write on it.
我的问题不同,我以根用户的身份手动启动了elasticsearch,因此创建了一些文件,但用户无法在其上写入。
You can test running manually elasticsearch:
您可以测试运行手动弹搜索:
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/*
#1
28
I found the solution for this issue. The solution comes form this discussion thread- Can’t start elasticsearch with Ubuntu 16.04 on elastic's website.
我找到了解决这个问题的办法。解决方案来自于这个讨论线程——无法在elastic的网站上启动Ubuntu 16.04的弹性搜索。
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.似乎要在16.04上运行弹性搜索,您必须将START_DAEMON设置为true,在/etc/default/elasticsearch上。它会在默认情况下被注释掉,取消注释会让弹性搜索重新启动。
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.一定要使用systemctl restart而不是仅仅启动,因为服务在安装之后就开始了,而且显然还有一些socket/pidfile/一些systemd保存的东西必须在能够再次启动服务之前释放出来。
#2
5
The problem lies on log files, "No java runtime was found."
问题在于日志文件,“没有找到java运行时。”
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
检查elasticsearch init文件
sudo nano /etc/init.d/elasticsearch
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
检查java包装器。sh文件
sudo nano /usr/share/java-wrappers/java-wrappers.sh
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;
}
- Somehow, java directories are not listed in jvm-list.sh files
- 不知何故,java目录不在jvm-list中列出。sh文件
Now edit the jvm-list.sh file
现在编辑jvm-list。sh文件
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*
编辑行添加java目录文件,在我的示例中是添加/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
现在重新启动服务并检查elasticsearch服务
sudo systemctl restart elasticsearch
sudo systemctl elasticsearch status
curl -X GET "http://localhost:9200"sudo systemctl重启弹性搜索sudo系统ctl弹性搜索状态curl -X获得“http://localhost:9200”
Hopes this would help
希望这将有助于
#3
2
-
Open /etc/init.d/elasticsearch file in editor, Comment below lines
打开/etc/init.d/elasticsearch文件在编辑器中,注释在下行
. /usr/share/java-wrappers/java-wrappers.sh find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
Set JAVA_HOME manually like so:
手动设置JAVA_HOME,如下所示:
export JAVA_HOME="/usr"
-
service elasticsearch start
服务elasticsearch开始
#4
1
My problem was different, I started elasticsearch manually as root user, so some files were created but elasticsearch user cannot write on it.
我的问题不同,我以根用户的身份手动启动了elasticsearch,因此创建了一些文件,但用户无法在其上写入。
You can test running manually elasticsearch:
您可以测试运行手动弹搜索:
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/*