美文网首页
centos7 批量启动程序的shell样例

centos7 批量启动程序的shell样例

作者: 假程序猿 | 来源:发表于2019-05-10 09:56 被阅读0次
    #!/bin/bash
    
    zk_home=/home/app/zookeeper
    kafka_home=/home/app/kafka
    kafka_manager_home=/home/app/kafka/kafka-manager-2.0.0.2 
    zipkin_home=/home/app/zipkin
    
    zkStart(){
        echo ">>>zookeeper 2181 starting..."
        cd ${zk_home}/2181/ && zookeeper-3.4.14/bin/zkServer.sh start
        sleep 3
        echo ">>>zookeeper 2182 starting..."
        cd ${zk_home}/2182/ && zookeeper-3.4.14/bin/zkServer.sh start
        sleep 3
        echo ">>>zookeeper 2183 starting..."
        cd ${zk_home}/2183/ && zookeeper-3.4.14/bin/zkServer.sh start
        sleep 3
        jps | grep QuorumPeerMain
    }
    
    kafkaStart(){
        echo ">>>kafka 9092 starting..."
        cd ${kafka_home}/9092/kafka_2.12-2.2.0/bin/ && ./kafka-server-start.sh -daemon ../config/server.properties
        sleep 3
        echo ">>>kafka 9093 starting..."
        cd ${kafka_home}/9093/kafka_2.12-2.2.0/bin/ && ./kafka-server-start.sh -daemon ../config/server.properties
        sleep 3
        echo ">>>kafka 9094 starting..."
        cd ${kafka_home}/9094/kafka_2.12-2.2.0/bin/ && ./kafka-server-start.sh -daemon ../config/server.properties
        sleep 3
        jps | grep Kafka
    }
    
    kafkaManagerStart(){
        echo ">>>kafka-maneger 9090 starting..."
        rm -rf ${kafka_manager_home}/RUNNING_PID
        nohup ${kafka_manager_home}/bin/kafka-manager -Dconfig.file=${kafka_manager_home}/conf/application.conf -Dhttp.port=9090 >/dev/null 2>&1 &
        sleep 3
        jps | grep ProdServerStart
    }
    
    zipkinStart() {
        echo ">>>zipkin-server 9411 starting..."
        zipkin_opts="-DKAFKA_TOPIC=zipkin -DKAFKA_BOOTSTRAP_SERVERS=10.30.2.222:9092,10.30.2.222:9093,10.30.2.222:9094 -DSTORAGE_TYPE=elasticsearch -DES_HOSTS=http://10.30.2.222:9200/"
        nohup java ${zipkin_opts} -jar ${zipkin_home}/zipkin-server-2.12.9-exec.jar >/dev/null 2>&1 &
        sleep 3
        ps -ef|grep zipkin-server | grep -v grep
    }
    
    case $1 in
        zookeeper)
            zkStart
            ;;
        kafka)
            kafkaStart
            ;;
        kafka-manager)
            kafkaManagerStart
            ;;
        zipkin)
            zipkinStart
            ;;
        all)
            zkStart
            kafkaStart
            kafkaManagerStart
            zipkinStart
            ;;
    esac
    

    相关文章

      网友评论

          本文标题:centos7 批量启动程序的shell样例

          本文链接:https://www.haomeiwen.com/subject/jtjooqtx.html