zoukankan      html  css  js  c++  java
  • kafka shell file

    1. start kafka and schema_registry

    #!/bin/sh
    export KAFKA_HOME=/home/lenmom/workspace/software/confluent-community-5.1.0-2.11
    export KAFKA_PROCESS_ID=$(jps |grep SupportedKafka     |awk '{print $1}')
    export SCHEMA_REGISTRY_PROCESS_ID=$(jps |grep SchemaRegistryMain |awk '{print $1}')
    
    export reset_data=0
    
    
    if [ $# = 1 ] && [ "$1"=="reset" ]; then
        reset_data=1
    else
        reset_data=0
    fi
    
    
    start_kafka(){
        if [ "$KAFKA_PROCESS_ID" != "" ]; then
            if [ $reset_data -eq 1 ]; then
                echo "kafka process already running, kill it: "+ $KAFKA_PROCESS_ID
                kill -9 $KAFKA_PROCESS_ID
    
                echo "delete kafka data"
                # clean up kafka data.
                rm -rf $KAFKA_HOME/kafka-logs
                mkdir -p $KAFKA_HOME/kafka-logs
    
                rm -rf $KAFKA_HOME/logs
                mkdir -p $KAFKA_HOME/logs
    
                sleep 3
                echo "restart kafka"
                $KAFKA_HOME/bin/kafka-server-start -daemon  $KAFKA_HOME/etc/kafka/server.properties
            fi
        else
            echo "start kafka"
            $KAFKA_HOME/bin/kafka-server-start -daemon  $KAFKA_HOME/etc/kafka/server.properties
        fi
    }
    
    
    start_schema_registry(){
        if [ "$SCHEMA_REGISTRY_PROCESS_ID" != "" ]; then
            if [ $reset_data -eq 1 ]; then
                echo "SchemaRegistry process already running, kill it: "+ $SCHEMA_REGISTRY_PROCESS_ID
                kill -9 $SCHEMA_REGISTRY_PROCESS_ID
                echo "restart confluent schema registry"
                $KAFKA_HOME/bin/schema-registry-start -daemon $KAFKA_HOME/etc/schema-registry/schema-registry.properties
            fi
        else
            echo "start confluent schema registry"
            $KAFKA_HOME/bin/schema-registry-start -daemon $KAFKA_HOME/etc/schema-registry/schema-registry.properties
        fi
    }
    
    
    start_connect_distributed(){
        echo "start confluent kafka connect"
        connect_process_id=$(jps |grep ConnectDistributed |awk '{print $1}')
        if [ "$connect_process_id" != "" ]; then
            # process already started, if not reset then nothing to do.
            if [ $reset_data -eq 1 ]; then
                # process already started,and use reset, so kill the process.
                echo "kafka-connect process already running, kill it: "+ $connect_process_id
                kill -9  $connect_process_id
    
                echo "restart kafka-connect"
                $KAFKA_HOME/bin/connect-distributed  $KAFKA_HOME/etc/schema-registry/connect-avro-distributed.properties
            fi
        else
            echo "start kafka-connect"
            $KAFKA_HOME/bin/connect-distributed  $KAFKA_HOME/etc/schema-registry/connect-avro-distributed.properties
        fi
    }
    
    
    
    
    start_kafka
    sleep 5
    start_schema_registry
    start_connect_distributed
  • 相关阅读:
    xadmin进行全局配置(修改模块名为中文以及其他自定义的操作步骤)
    xadmin邮箱验证码 标题 EmailVerifyRecord object
    Django源码安装xadmin报错Apps aren't loaded yet.
    python虚拟环境virtualenv下安装MySQL-python(1.2.3)
    Pycharm界面的子窗口不见了,怎么办?
    MySQL-python终于安装成功了
    mysql-python 安装错误: Cannot open include file: 'config-win.h': No such file or directory
    配凑法
    双连不等式
    求参数的取值范围
  • 原文地址:https://www.cnblogs.com/lenmom/p/10951284.html
Copyright © 2011-2022 走看看