kafka经常使用的一些命令汇总

# 查看topic的详细信息
./kafka-topics.sh -zookeeper 127.0.0.1:2181 -describe -topic test-topic

# 为topic增加副本
./kafka-reassign-partitions.sh -zookeeper 127.0.0.1:2181 -reassignment-json-file json/partitions-to-move.json -execute

# 创建topic
./kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 1 --partitions 1 --topic test-topic

# 为topic增加partition
./bin/kafka-topics.sh –zookeeper 127.0.0.1:2181 –alter –partitions 20 –topic test-topic

# kafka生产者客户端命令
./kafka-console-producer.sh --broker-list localhost:9092 --topic test-topic

# kafka消费者客户端命令
./kafka-console-consumer.sh -zookeeper localhost:2181 --from-beginning --topic test-topic

# kafka服务启动
./kafka-server-start.sh -daemon ../config/server.properties 

# 下线broker
./kafka-run-class.sh kafka.admin.ShutdownBroker --zookeeper 127.0.0.1:2181 --broker #brokerId# --num.retries 3 --retry.interval.ms 60
shutdown broker

# 删除topic
./kafka-run-class.sh kafka.admin.DeleteTopicCommand --topic test-topic--zookeeper 127.0.0.1:2181