From 57878cf6445fe8dee0232371d385bd3eae982f1e Mon Sep 17 00:00:00 2001 From: Chia-Ping Tsai Date: Wed, 26 Jun 2024 23:35:45 +0800 Subject: [PATCH] [COMMON] strat_broker.sh supports to run migration --- docker/start_broker.sh | 25 ++++++++++++++++++------- 1 file changed, 18 insertions(+), 7 deletions(-) diff --git a/docker/start_broker.sh b/docker/start_broker.sh index fc7ab9b8dd..f3996300ae 100755 --- a/docker/start_broker.sh +++ b/docker/start_broker.sh @@ -263,6 +263,7 @@ fi checkNetwork quorum="unknown" +migration="false" while [[ $# -gt 0 ]]; do if [[ "$1" == "help" ]]; then showHelp @@ -275,6 +276,9 @@ while [[ $# -gt 0 ]]; do if [[ "$1" == "zookeeper.connect"* ]]; then quorum="zookeeper" fi + if [[ "$1" == "zookeeper.metadata.migration.enable=true"* ]]; then + migration="true" + fi shift done @@ -302,14 +306,21 @@ setLogDirs command="./bin/kafka-server-start.sh /tmp/broker.properties" if [[ "$quorum" == "kraft" ]]; then - if [[ -z "$CLUSTER_ID" ]]; then - echo "please set CLUSTER_ID for krafe mode" - exit 2 + if [[ "$migration" == "false" ]]; then + if [[ -z "$CLUSTER_ID" ]]; then + echo "please set CLUSTER_ID for krafe mode" + exit 2 + fi + setPropertyIfEmpty "node.id" "$NODE_ID" + setPropertyIfEmpty "process.roles" "broker" + setPropertyIfEmpty "controller.listener.names" "CONTROLLER" + command="./bin/kafka-storage.sh format -t $CLUSTER_ID -c /tmp/broker.properties --ignore-formatted && ./bin/kafka-server-start.sh /tmp/broker.properties" + else + setPropertyIfEmpty "broker.id" "$NODE_ID" + setPropertyIfEmpty "broker.id.generation.enable" "false" + setPropertyIfEmpty "listener.security.protocol.map" "PLAINTEXT:PLAINTEXT,CONTROLLER:PLAINTEXT" + setPropertyIfEmpty "controller.listener.names" "CONTROLLER" fi - setPropertyIfEmpty "node.id" "$NODE_ID" - setPropertyIfEmpty "process.roles" "broker" - setPropertyIfEmpty "controller.listener.names" "CONTROLLER" - command="./bin/kafka-storage.sh format -t $CLUSTER_ID -c /tmp/broker.properties --ignore-formatted && ./bin/kafka-server-start.sh /tmp/broker.properties" fi docker run -d --init \