• kafka 设置开机启动


    #!/bin/sh
    #
    # chkconfig: 345 99 01
    # description: Kafka
    #
    # File : Kafka
    #
    # Description: Starts and stops the Kafka server
    #
    
    source /etc/rc.d/init.d/functions
    
    KAFKA_HOME=/data/local/kafka
    KAFKA_USER=kafka
    export JAVA_HOME=/data/local/java
    export CLASSPATH=$JAVA_HOME/lib/tools.jar:$JAVA_HOME/lib/dt.jar:$JAVA_HOME/lib
    export PATH=$JAVA_HOME/bin:$PATH
    
    export LOG_DIR=/data/kafka/runlog
    
    [ -e /etc/sysconfig/kafka ] && . /etc/sysconfig/kafka
    
    # See how we were called.
    case "$1" in
    
      start)
        echo -n "Starting Kafka:"
        /sbin/runuser -s /bin/sh $KAFKA_USER -c "nohup $KAFKA_HOME/bin/kafka-server-start.sh $KAFKA_HOME/config/server.properties > $LOG_DIR/server.out 2> $LOG_DIR/server.err &"
        echo " done."
        exit 0
        ;;
    
      stop)
        echo -n "Stopping Kafka: "
        /sbin/runuser -s /bin/sh $KAFKA_USER  -c "ps -ef | grep kafka.Kafka | grep -v grep | awk '{print $2}' | xargs kill"
        echo " done."
        exit 0
        ;;
      hardstop)
        echo -n "Stopping (hard) Kafka: "
        /sbin/runuser -s /bin/sh $KAFKA_USER  -c "ps -ef | grep kafka.Kafka | grep -v grep | awk '{print $2}' | xargs kill -9"
        echo " done."
        exit 0
        ;;
    
      status)
        c_pid=`ps -ef | grep kafka.Kafka | grep -v grep | awk '{print $2}'`
        if [ "$c_pid" = "" ] ; then
          echo "Stopped"
          exit 3
        else
          echo "Running $c_pid"
          exit 0
        fi
        ;;
    
      restart)
        stop
        start
        ;;
    
      *)
        echo "Usage: kafka {start|stop|hardstop|status|restart}"
        exit 1
        ;;
    
    esac 

    vim  /etc/rc.d/init.d/kafka

    加入上面的shell代码

    给予执行权限  chmod +x kafka

    service kafka start

    service kafka stop

    设置开机启动

    chkconfig --add kafka

    chkconfig kafka on

    相关kafka技术链接

    http://www.jb51.net/article/76397.htm

    常用命令

    http://www.jb51.net/article/99923.htm

  • 相关阅读:
    20210519日报
    20210518日报
    20210517日报
    20210514日报
    20210513日报
    20210512日报
    20210511日报
    数据挖掘提分三板斧-转
    特征变量和y值的可视化
    kaggle 2015年航班延误
  • 原文地址:https://www.cnblogs.com/fangyuan303687320/p/7741178.html
Copyright © 2020-2023  润新知