1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43
| #!/bin/sh #chkconfig: 2345 80 05 #description: elasticsearch
#jdk相关路径 export JAVA_HOME=/var/local/java/jdk1.8.0_241 export JAVA_BIN=/var/local/java/jdk1.8.0_241/bin export PATH=$PATH:$JAVA_HOME/bin export CLASSPATH=.:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib/tools.jar export JAVA_HOME JAVA_BIN PATH CLASSPATH
case "$1" in start) #es的启动账号名 su es<<! #es的安装路径 cd /data/elasticsearch-6.8.11/ ./bin/elasticsearch -d ! echo "elasticsearch startup" ;; stop) es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'` kill -9 $es_pid echo "elasticsearch stopped" ;; restart) es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'` kill -9 $es_pid echo "elasticsearch stopped" su es<<! cd /data/elasticsearch-6.8.11/ ./bin/elasticsearch -d ! echo "elasticsearch startup" ;; *) echo "start|stop|restart" ;; esac
exit $?
|