CentOS7安装elasticsearch

第一步安装:

wget https://artifacts.elastic.co/downloads/elasticsearch/elasticsearch-6.2.4.rpm

rpm -ivh elasticsearch-6.2.4.rpm 

systemctl daemon-reload

第二步修改java环境变量:

vi /usr/share/elasticsearch/bin/elasticsearch

增加下面标红部分:

#   ES_PATH_CONF -- Path to config directory
#   ES_JAVA_OPTS -- External Java Opts on top of the defaults set
#
# Optionally, exact memory values can be set using the `ES_JAVA_OPTS`. Note that
# the Xms and Xmx lines in the JVM options file must be commented out. Example
# values are "512m", and "10g".
#
#   ES_JAVA_OPTS="-Xms8g -Xmx8g" ./bin/elasticsearch

export JAVA_HOME=/usr/local/jdk/jdk1.8.0_161
export PATH=$JAVA_HOME/bin:$PATH

source "`dirname "$0"`"/elasticsearch-env

ES_JVM_OPTIONS="$ES_PATH_CONF"/jvm.options
JVM_OPTIONS=`"$JAVA" -cp "$ES_CLASSPATH" org.elasticsearch.tools.launchers.JvmOptionsParser "$ES_JVM_OPTIONS"`
ES_JAVA_OPTS="${JVM_OPTIONS//\$\{ES_TMPDIR\}/$ES_TMPDIR} $ES_JAVA_OPTS"

if [ -x "$JAVA_HOME/bin/java" ]; then
        JAVA="/usr/local/jdk/jdk1.8.0_161/bin/java"
else
        JAVA=`which java`
fi

cd "$ES_HOME"
# manual parsing to find out, if process should be detached
if ! echo $* | grep -E '(^-d |-d$| -d |--daemonize$|--daemonize )' > /dev/null; then
  exec \
    "$JAVA" \
    $ES_JAVA_OPTS \
    -Des.path.home="$ES_HOME" \
    -Des.path.conf="$ES_PATH_CONF" \
    -cp "$ES_CLASSPATH" \
    org.elasticsearch.bootstrap.Elasticsearch \
    "$@"
else
  exec \
    "$JAVA" \
    $ES_JAVA_OPTS \
    -Des.path.home="$ES_HOME" \
    -Des.path.conf="$ES_PATH_CONF" \
    -cp "$ES_CLASSPATH" \
    org.elasticsearch.bootstrap.Elasticsearch \
    "$@" \
    <&- &
  retval=$?
  pid=$!
  [ $retval -eq 0 ] || exit $retval
  if [ ! -z "$ES_STARTUP_SLEEP_TIME" ]; then
    sleep $ES_STARTUP_SLEEP_TIME
  fi
  if ! ps -p $pid > /dev/null ; then
    exit 1
  fi
  exit 0
fi

exit $?

第三步,启动和查看状态


systemctl enable elasticsearch
systemctl start elasticsearch
systemctl status elasticsearch

第四步,查看版本信息

curl -XGET "127.0.0.1:9200"

 第五步,修改ip和端口

vi /etc/elasticsearch/elasticsearch.yml

network.host: 192.168.31.202

http.port: 9200

posted on 2018-04-23 14:43  小泥人的医生  阅读(339)  评论(0编辑  收藏  举报