Skip to content

Instantly share code, notes, and snippets.

@giangnth
giangnth / reassignment-kafka.sh
Created December 23, 2021 03:13
kafka reassignment topic and leader
#!/bin/bash
brokerids="10,20,30"
topics=`bin/kafka-topics.sh --list --zookeeper kafka1:2181`
while read -r line; do lines+=("$line"); done <<<"$topics"
echo '{"version":1,
"partitions":[' > tmp.json
for t in $topics; do
sep=","
@giangnth
giangnth / kafka_command.sh
Last active March 9, 2024 18:40
kafka command
Kafka shell command:
1) Get list all topic:
./kafka-topics.sh --zookeeper <zookeeper_host:port> --list
./bin/kafka-topics.sh --zookeeper kafka1:2181 --list
./bin/kafka-topics.sh --zookeeper kafka1:2181 --describe
2) Create topic:
./kafka-topics.sh --create --zookeeper <zookeeper_host:port> --replication-factor <number_replica> --partitions <number_partition> --topic <topic_name>
./bin/kafka-topics.sh --create --zookeeper kafka1:2181 --replication-factor 3 --partitions 8 --topic proximity