无法启动Elasticsearch作为服务

时间:2015-07-30 12:07:30

标签: ubuntu service elasticsearch

我正在尝试在我的ubuntu(12.04)计算机上安装Elasticsearch(0.90.5)作为服务。

我试过

wget https://download.elasticsearch.org/elasticsearch/elasticsearch/elasticsearch-0.90.5.deb
sudo dpkg -i elasticsearch-0.90.5.deb

它的响应为

Selecting previously unselected package elasticsearch.
(Reading database ... 51009 files and directories currently installed.)
Unpacking elasticsearch (from elasticsearch-0.90.5.deb) ...
Setting up elasticsearch (0.90.5) ...
Adding system user `elasticsearch' (UID 107) ...
Adding new user `elasticsearch' (UID 107) with group `elasticsearch' ...
Not creating home directory `/usr/share/elasticsearch'.
* Starting ElasticSearch Server                                               [ OK ] 
Processing triggers for ureadahead ...

然后用

启动服务
 sudo service elasticsearch start
* Starting ElasticSearch Server                                               [ OK ]

在我检查状态之后,显示

sudo service elasticsearch status
* elasticsearch is not running

我检查了我的日志,但它是空的。

端口9200上没有其他进程在运行

我的java版本:“1.6.0_31”

有谁知道为什么会这样?

提前感谢您的帮助

2 个答案:

答案 0 :(得分:2)

我认为你应该尝试减少记忆。 进行以下更改:

  1. vi /opt/elasticsearch-1.3.4/bin/service/elasticsearch.conf
  2. 您需要减少内存(ES_HEAP_SIZE)限制。 [1024到512等]
  3. 保存文件。
  4. service elasticsearch start
  5. 希望它能解决问题。

答案 1 :(得分:0)

我刚刚更新了用于运行elasticsearch作为服务的脚本(/etc/init.d/elasticsearch)。下面的脚本解决了这个问题。

#! /bin/sh
### BEGIN INIT INFO
# Provides:          elasticsearch
# Required-Start:    $all
# Required-Stop:     $all
# Default-Start:     2 3 4 5
# Default-Stop:      0 1 6
# Short-Description: Starts elasticsearch
# Description:       Starts elasticsearch using start-stop-daemon
### END INIT INFO

ES_HOME=/usr/share/elasticsearch
ES_MIN_MEM=256m
ES_MAX_MEM=2g
DAEMON=$ES_HOME/bin/elasticsearch
NAME=elasticsearch
DESC=elasticsearch
PID_FILE=/var/run/$NAME.pid
#LOG_DIR=/var/log/$NAME
LOG_DIR=/extn1/es_log/
#DATA_DIR=/var/lib/$NAME
DATA_DIR=/extn1/data/
WORK_DIR=/tmp/$NAME
CONFIG_FILE=/etc/$NAME/elasticsearch.yml
DAEMON_OPTS="-p $PID_FILE -Des.config=$CONFIG_FILE -Des.path.home=$ES_HOME -Des.path.logs=$LOG_DIR -Des.path.data=$DATA_DIR -Des.path.work=$WORK_DIR"


test -x $DAEMON || exit 0

set -e

case "$1" in
  start)
    echo -n "Starting $DESC: "
    mkdir -p $LOG_DIR $DATA_DIR $WORK_DIR
    if start-stop-daemon --start --pidfile $PID_FILE --startas $DAEMON -- $DAEMON_OPTS
then
        echo "started."
    else
        echo "failed."
    fi
    ;;
  stop)
    echo -n "Stopping $DESC: "
    if start-stop-daemon --stop --pidfile $PID_FILE
    then
        echo "stopped."
    else
        echo "failed."
    fi
    ;;
  restart|force-reload)
    ${0} stop
    sleep 0.5
    ${0} start
    ;;
  *)
    N=/etc/init.d/$NAME
    echo "Usage: $N {start|stop|restart|force-reload}" >&2
    exit 1
    ;;
esac

exit 0