zoukankan      html  css  js  c++  java
  • elasticsearch开机自启

    linux下开机自启:

    在/etc/init.d目录下新建文件elasticsearch

    并敲入shell脚本:

    #!/bin/sh
    #chkconfig: 2345 80 05
    #description: elasticsearch
     
    export JAVA_HOME=/home/hadoop/jdk/jdk1.8.0_172
    export JAVA_BIN=/home/hadoop/jdk/jdk1.8.0_172/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 hadoop<<!
        cd /opt/elasticsearch-5.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 hadoop<<!
        cd /opt/elasticsearch-5.1.1
        ./bin/elasticsearch -d
    !
        echo "elasticsearch startup"
        ;;  
    *)
        echo "start|stop|restart"
        ;;  
    esac
    
    exit $?

    前两行必须填写,且要注释掉

    第一行为shell前行代码,目的告诉系统使用shell。

    第二行分别代表运行级别,启动优先权,关闭优先权,且后面添加开机服务会用到

    shell脚本中的Java,es路径,开启账户要注意,此处我是在root用户下使用的,但是es是安装在hadoop下面的

    保存退出,并在/etc/init.d/下赋予执行权限

    chmod +x elasticsearch

    添加到开机启动任务

    chkconfig --add elasticsearch
  • 相关阅读:
    Linux install
    plafrom library
    lua 线程
    plafrom SDK
    CSS中的focus-within伪类选择器
    网站打开速度优化_如何提高网页访问速度技巧方法总结
    网页预加载_骨架屏Skeleton Screen的实现
    SASS简介及使用方法
    什么是BFC布局——浅析BFC布局的概念以及作用
    JAVA面试题(九):JVM
  • 原文地址:https://www.cnblogs.com/ymdphp/p/11418257.html
Copyright © 2011-2022 走看看