zoukankan      html  css  js  c++  java
  • elasticsearch在CentOS环境下开机启动

    验证环境,OS版本:CentOS-7-x86_64-Minimal-1708;ES版本:elasticsearch-7.4.0。

    1、在/etc/init.d/目录创建es文件

    vi /etc/init.d/es

      文件内容:

    #!/bin/bash
    #
    #chkconfig: 345 63 37
    #description: elasticsearch
    #processname: elasticsearch-7.4.0
    
    ES_HOME=/usr/local//usr/local/elasticsearch-7.4.0
    
    case $1 in
      start)
        su - solr -c "$ES_HOME/bin/elasticsearch -d -p pid"
        echo "elasticsearch is started"
        ;;
      stop)
        pid=`cat $ES_HOME/pid`
        kill -9 $pid
        echo "elasticsearch is stopped"
        ;;
      restart)
        pid=`cat $ES_HOME/pid`
        kill -9 $pid
        echo "elasticsearch is stopped"
        sleep 1
        su - es -c "$ES_HOME/bin/elasticsearch -d -p pid"
        echo "elasticsearch is started"
        ;;
      *)
        echo "start|stop|restart"
        ;;  
    esac
    exit 0

    2、修改上面文件的权限,执行命令

    chmod 777 /etc/init.d/es

    3、添加和删除服务并设置启动方式(chkconfig具体使用另行百度)

    chkconfig --add es
    chkconfig --del es

    4、启动和关闭服务

    service es start    // 启动服务
    service es stop     // 关闭服务
    service es restart  // 重启服务

    5、设置服务的启动方式

    chkconfig es on  // 设置开机启动
    chkconfig es off // 关闭开机启动
  • 相关阅读:
    Thrift --- 支持双向通信
    Go -- 配置监控系统
    Go -- RPC 之 Thrift
    Go -- 一致性哈希算法
    Go -- runtime.Gosched()的作用分析
    Go -- import使用及. _的作用解析
    BNF 和 ABNF 扩充巴科斯范式 了解
    转 HTTP.SYS 详解
    转 HTTP/2: The Long-Awaited Sequel
    网站分析
  • 原文地址:https://www.cnblogs.com/zhi-leaf/p/8487404.html
Copyright © 2011-2022 走看看