标签:code $2 esc sea restart useradd etc print search
前提条件useradd es
chown -R es:es /usr/elasticsearch/
chmod 755 /etc/init.d/elasticsearch
vim /etc/init.d/elasticsearch
#!/bin/bash
#chkconfig: 2345 80 05
#description: elasticsearch
export JAVA_HOME=/usr/java/jre1.8.0_191-amd64/
export JAVA_BIN=/usr/java/jre1.8.0_191-amd64/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)
su es<<!
cd /usr/elasticsearch/
./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 /usr/elasticsearch
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
标签:code $2 esc sea restart useradd etc print search
原文地址:https://blog.51cto.com/13950323/2372254