我最近将我的机器从Ubuntu 14.04
升级到16.04
。我遇到使用elasticsearch
作为服务的问题。我installed elasticsearch
使用:
sudo apt-get install elasticsearch
现在sudo service elasticsearch status
命令显示了这个结果:
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.
虽然我的机器上安装了Java,但我可以使用此命令启动服务器。
sudo /usr/share/elasticsearch/bin/elasticsearch
我有点被困在这里。任何帮助将不胜感激。
修改
为root设置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.
答案 0 :(得分:34)
我找到了解决这个问题的方法。解决方案来自弹性网站上的讨论主题Can’t start elasticsearch with Ubuntu 16.04。
似乎要让Elasticsearch在
16.04
上运行,您必须在START_DAEMON
上将/etc/default/elasticsearch
设置为true。默认情况下它会被注释掉,并且取消注释它会使Elasticsearch再次启动。请务必使用
systemctl restart
代替start
,因为。{ 服务在安装后立即开始,显然有socket/pidfile/something
保留必须释放的systemd
个/* Input incrementer*/ $(".numbers-row").append('<div class="inc button_inc">+</div><div class="dec button_inc">-</div>'); $(".button_inc").on("click", function () { var $button = $(this); var oldValue = $button.parent().find("input").val(); if ($button.text() == "+") { var newVal = parseFloat(oldValue) + 1; } else { // Don't allow decrementing below zero if (oldValue > 1) { var newVal = parseFloat(oldValue) - 1; } else { newVal = 0; } } $button.parent().find("input").val(newVal); }); });
在能够再次启动服务之前。
答案 1 :(得分:9)
问题在于日志文件,&#34;没有找到java运行时。&#34;
Jul 30 18:28:13 dimik elasticsearch[10266]: [warning] /etc/init.d/elasticsearch: No java runtime was found
这是我解决问题的方法。
检查elasticsearch init文件
sudo nano /etc/init.d/elasticsearch
搜索
. /usr/share/java-wrappers/java-wrappers.sh
find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
export JAVA_HOME
检查java-wrappers.sh文件
sudo nano /usr/share/java-wrappers/java-wrappers.sh
现在您可以看到警告来自
#Displays a warning
java_warning() {
echo "[warning] $0: $@" >&2;
}
现在编辑jvm-list.sh文件
sudo nano /usr/lib/java-wrappers/jvm-list.sh
编辑行添加你的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*"
现在重启服务并检查elasticsearch服务
sudo systemctl restart elasticsearch
sudo systemctl elasticsearch status
curl -X GET&#34; http://localhost:9200&#34;
希望这会有所帮助
答案 2 :(得分:2)
在编辑器中打开/etc/init.d/elasticsearch文件,注释下面的行
. /usr/share/java-wrappers/java-wrappers.sh
find_java_runtime openjdk8 oracle8 openjdk7 oracle7 openjdk6 sun6 default
手动设置JAVA_HOME:
export JAVA_HOME="/usr"
service elasticsearch start
答案 3 :(得分:1)
我的问题不同了,我以root用户手动启动了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
要修理我的机器,我必须这样做:
rm -rf /var/log/elasticsearch/*
rm -rf /var/lib/elasticsearch/*