elk es配置开机自动
#!/bin/sh
#chkconfig: 2345 80 05
#description: elasticsearch
case "$1" in
start)
su elasticsearch<<!
cd /usr/local/elasticsearch/elasticsearch-7.1.1
./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 elasticsearch<<!
cd /usr/local/elasticsearch/elasticsearch-7.1.1
./bin/elasticsearch -d
!
echo "elasticsearch startup"
;;
*)
echo "start|stop|restart"
;;
esac
exit $?
#!/bin/sh
#chkconfig: 2345 80 05
#description: es
es_dir=/data/software/es/elasticsearch-7.7.0
file_name=elasticsearch
case $1 in
start)
#echo "stoping ${file_name}"
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
#for pid in ${es_pid}
#do
# echo "结束进程:${pid}"
# kill -9 $pid
#done
echo "starting ${file_name}"
su es<<!
cd ${es_dir}/bin
./${file_name} -d
exit
!
echo "start ${file_name} done"
;;
stop)
echo "stoping ${file_name}"
es_pid=`ps aux|grep elasticsearch | grep -v 'grep elasticsearch' | awk '{print $2}'`
for pid in ${es_pid}
do
echo "结束进程:${pid}"
kill -9 $pid
done
echo "stop ${file_name} done"
;;
*)
echo "start|stop"
esac
为启动脚本增加执行权限:
chmod +x /etc/init.d/elastisearch
配置开机启动es:
chkconfig --add elastisearch
检查ES是否启动:
jps
配置kibana
#!/bin/sh
#chkconfig: 2345 80 05
#description: kibana
kibana_dir=/data/software/es/kibana-7.7.0-linux-x86_64
file_name=kibana
case $1 in
start)
echo "starting ${file_name}"
su es<<!
cd ${kibana_dir}/bin
./kibana
exit
!
echo "start ${file_name} done"
;;
stop)
echo "stoping ${file_name}"
kibana_pid=`ps aux|grep node/bin | awk '{print $2}'`
for pid in ${kibana_pid}
do
echo "结束进程:${pid}"
done
echo "stop ${file_name} done"
;;
*)
echo "start|stop"
esac
可用,先用这个
case "$1" in
start)
echo "starting kibana"
su es<<!
cd /data/software/es/kibana-7.7.0-linux-x86_64
./bin/kibana
!
echo "kibana startup"
;;
stop)
es_pid=`ps aux|grep node/bin | grep -v 5601 | awk '{print $2}'`
kill -9 $es_pid
echo "kibana stopped"
;;
esac
exit $?
为启动脚本增加执行权限:
chmod +x /etc/init.d/kibana
配置开机启动es:
chkconfig --add kibana
检查ES是否启动:
jps