zoukankan      html  css  js  c++  java
  • 配置Cassandra开机启动(CentOS 7)

    配置环境:centOS 7

    1. 编写开机启动脚本
    [root@cassandra-01 ~]# cd /etc/rc.d/init.d/
    [root@cassandra-01 init.d]# vi cassandra
    写入以下内容并保存关闭

    #!/bin/sh
    # chkconfig: 2345 60 60
    # description: service for cassandra 3.11.4
    # processname: cassandra

    CASSANDRA_DIR="/usr/local/apache-cassandra-3.11.4"

    case "$1" in
    start)
    echo "Starting cassandra"
    su - cassandra -c nohup -c "$CASSANDRA_DIR/bin/cassandra" >> $CASSANDRA_DIR/logs/system.log 2>&1 &
    echo "Cassandra started"
    ;;
    stop)
    echo "Stopping cassandra"
    PID_COUNT=`ps aux |grep CassandraDaemon |grep -v grep | wc -l`
    PID=`ps aux |grep CassandraDaemon |grep -v grep | awk {'print $2'}`
    if [ $PID_COUNT -gt 0 ];then
    echo "Try stop cassandra"
    kill -9 $PID
    echo "Kill cassandra SUCCESS!"
    else
    echo "There is no cassandra!"
    fi
    ;;
    restart)
    echo "Restarting cassandra"
    $0 stop
    $0 start
    ;;
    status)
    -c "$CASSANDRA_DIR/bin/nodetool status"
    ;;
    *)
    echo "Usage:$0 {start|stop|restart|status}"
    exit 1
    esac


    赋予权限
    [root@cassandra-01 init.d]# chmod 755 cassandra


    2. 配置开机自启动
    加入系统服务

    [root@cassandra-01 init.d]# chkconfig --add cassandra
    设置开机自启动

    [root@cassandra-01 init.d]# chkconfig cassandra on


    3. 服务启动停止
    [root@cassandra-01 init.d]# service cassandra start
    [root@cassandra-01 init.d]# service cassandra stop
    [root@cassandra-01 init.d]# service cassandra restart

  • 相关阅读:
    c++单例设计模式---17
    c++友元函數---16
    c++const关键字---15
    c++浅拷贝和深拷贝---14
    linux shell 基本语法
    Linux静态库生成
    alsa wav
    Android Butterknife使用方法总结 IOC框架
    利用cglib给javabean动态添加属性,不用在建VO
    钢铁雄心三 通过事件做修改器
  • 原文地址:https://www.cnblogs.com/Soy-technology/p/11313362.html
Copyright © 2011-2022 走看看