博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
Kafka常用操作备忘
阅读量:4674 次
发布时间:2019-06-09

本文共 1600 字,大约阅读时间需要 5 分钟。

启动

nohup ./bin/zookeeper-server-start.sh config/zookeeper.properties &
nohup ./bin/kafka-server-start.sh config/server.properties &

创建topic

kafka-topics.sh --create --zookeeper localhost:2181/kafka --replication-factor 1 --partitions 1 --topic $TOPIC

topic状态

./kafka-topics.sh --describe --zookeeper localhost:2181 --topic test

topic列表

./kafka-topics.sh --list --zookeeper localhost:2181

限流(根据每秒字节数)

kafka-configs.sh --zookeeper localhost:2181 --alter --add-config 'producer_byte_rate=24576000,consumer_byte_rate=24576000' --entity-type clients --entity-default
./kafka-configs.sh --zookeeper localhost:2181 --alter --add-config 'producer_byte_rate=1024' --entity-type clients --entity-default
.kafka-configs.sh --zookeeper localhost:2181 --alter --add-config 'producer_byte_rate=1536000'--entity-type clients --entity-default

消费状态

./kafka-consumer-groups.sh --bootstrap-server localhost:9092 --describe --group group_name

生产消费

kafka-console-producer.sh --broker-list localhost:9092 --topic test
kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic test --from-beginning

动态增加副本:

./bin/kafka-reassign-partitions.sh --zookeeper localhost:2181/kafka --reassignment-json-file increase-replication-factor.json --execute
{"version":1,"partitions":[{"topic":"foo","partition":0,"replicas":[5,6,7]}]}

reassign检验:

kafka-reassign-partitions.sh --zookeeper localhost:2181 --reassignment-json-file increase-replication-factor.json --verify

jstack -l pid

jmap -dump:live,format=b,file=/opt/map.bin pid

jps|grep Kafka|awk '{print $1}'|xargs kill -9

转载于:https://www.cnblogs.com/showing/p/9856015.html

你可能感兴趣的文章