#!/bin/sh
export JAVA_HOME=/home/esuser/jdk1.8.0_101
export PATH=$JAVA_HOME/bin:$PATH
export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar
export ES_USER=esuser
export MAX_MAP_COUNT=65535
export ES_HEAP_SIZE=500M
kill $(cat /var/run/es.pid)
/home/esuser/elasticsearch-2.0.0/bin/elasticsearch -d -p /home/esuser/es.pid
系统自动es服务脚本es
#!/bin/bash
# chkconfig: 2345 90 60
# description:es service
start(){
echo "es serive ..."
cd /home/esuser
su - esuser -c "./start-es.sh"
}
stop(){
echo "es service is stoped..."
cd /home/esuser
kill $(cat es.pid)
}
case $1 in
start)
start
;;
stop)
stop
;;
*)
echo "error choice ! please input start or stop";;
esac
exit $RETVA
- 修改脚本
- 将es脚本拷贝到/etc/rc.d/init.d/
- 添加服务:chkconfig --add es
- 开启开机自启动: chkconfig es on
- 手动启动服务,并进行验证: service es start
另附其他方式启动
https://www.jianshu.com/p/053125111158