Elasticsearch启动脚本

DevOps ELK评论1,424字数 738阅读2分27秒阅读模式

编写脚本

  • 说明:需指定JDK环境,要不然会默认使用es自带的JDK,自带的版本太新,去除了GC。
vim /etc/init.d/elasticsearch
#!/bin/sh
#chkconfig: 2345 80 05
 
export JAVA_HOME=/data/app/jdk-13.0.1
export PATH=$JAVA_HOME/bin:$PATH
export ES_HOME=/data/elasticsearch/
export PATH=$ES_HOME/bin:$PATH
 
 
case $1 in
    start)
        cd $ES_HOME
        ./bin/elasticsearch -d -p pid
        exit
!
        echo "elasticsearch is started"
        ;;
    stop)
        pid=`ps -ef | grep "Elasticsearch" |grep -v "grep" | awk '{print $2}'`
        kill -15 $pid
        echo "elasticsearch is stopped"
        ;;
    restart)
        pid=`ps -ef | grep "Elasticsearch" |grep -v "grep" | awk '{print $2}'`
        kill -15 $pid
        echo "elasticsearch is stopped"
        sleep 1
        cd $ES_HOME
        ./bin/elasticsearch -d -p pid
        exit
!
        echo "elasticsearch is started"
        ;;
    *)
        echo "start|stop|restart"
        ;;
esac
exit 0

添加到开机启动任务

chmod +x /etc/init.d/elasticsearch 
chkconfig --add elasticsearch 
service elasticsearch restart

DevOps
  • 本文由 发表于 2022年5月29日 18:04:03
  • 除非特殊声明,本站文章均为原创,转载请务必保留本文链接
EFK集群[案例] ELK

EFK集群[案例]

Elasticsearch集群配置信息 硬件配置信息 机器名/节点名 IP 内存 cpu 磁盘 us...
python定时清理ES 索引 ELK

python定时清理ES 索引

只保留三天 #!/usr/bin/env python3 # -*- coding:utf-8 -*- import os import datetime # 时间转化为字符串 n...
评论  0  访客  0

发表评论