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
  • 相关阅读:
    Jmater (十七) 命令行(非GUI)模式详解(二) 执行代理设置
    Jmater (十七) 命令行(非GUI)模式详解(一) 执行、输出结果及日志、简单分步执行脚本
    Jmeter (十六) IF控制器
    Jmeter (十五)用户定义变量&用户参数
    JMeter (十四) Cookie & Session
    Jmeter (十三)调试工具之--HTTP Mirror Server(转载)
    Jmeter (十二)调试工具之--Debug Processor(转载)
    Jmeter (十一)调试工具之--Debug Sampler(转载)
    Jmeter (十)脚本增强_关联
    Shell 变量的截取
  • 原文地址:https://www.cnblogs.com/lenmom/p/10951284.html
Copyright © 2011-2022 走看看