본문 바로가기

kafka

[command] kafka topic CLI

# topic list check
kafka-topics --bootstrap-server kafka01.host.com:9092,kafka02.host.com:9092,kafka03.host.com:9092 --list

# topic details
kafka-topics --bootstrap-server kafka01.host.com:9092,kafka02.host.com:9092,kafka03.host.com:9092 --topic topic1 --describe

# change topic partition
kafka-topics --bootstrap-server kafka01.host.com:9092,kafka02.host.com:9092,kafka03.host.com:9092 --alter --topic topic1 --partition 30

# Topic consumer execution
kafka-console-consumer --bootstrap-server kafka01.host.com:9092,kafka02.host.com:9092,kafka03.host.com:9092 --topic topic1
kafka-console-consumer --bootstrap-server kafka01.host.com:9092,kafka02.host.com:9092,kafka03.host.com:9092 --topic topic2

# create topic
kafka-topics --create --bootstrap-server kafka01.host.com:9092,kafka02.host.com:9092,kafka03.host.com:9092 --replication-factor 1 --partitions 30 --topic topic3
kafka-console-producer --broker-list kafka01.host.com:9092,kafka02.host.com:9092,kafka03.host.com:9092 --topic topic4