Linux

  1. 建立/etc/init.d/cassandra 啟動指令碼。

  2. 編輯檔案的內容:

    #!/bin/sh
    #
    # chkconfig: - 80 45
    # description: Starts and stops Cassandra
    # update daemon path to point to the cassandra executable
    DAEMON=<Cassandra installed directory>/bin/cassandra
    start() {
            echo -n "Starting Cassandra... "
            $DAEMON -p /var/run/cassandra.pid
            echo "OK"
            return 0
    }
    stop() {
            echo -n "Stopping Cassandra... "
            kill $(cat /var/run/cassandra.pid)
            echo "OK"
            return 0
    }
    case "$1" in
      start)
            start
            ;;
      stop)
            stop
            ;;
      restart)
            stop
            start
            ;;
      *)
            echo $"Usage: $0 {start|stop|restart}"
            exit 1
    esac
    exit $?
    
  3. 使檔案可執行:

    sudo chmod + x /etc/init.d/cassandra

  4. 將新服務新增到列表中:

    sudo chkconfig –add cassandra

  5. 現在,你可以從命令列管理服務:

    sudo /etc/init.d/cassandra start
    sudo /etc/init.d/cassandra stop
    sudo /etc/init.d/cassandra restart