kafka命令

kafka:集群搭建位置:10.0.xx.xx,/home/bjsasc/soft/service/kafka_2.12-2.3.0/deployment

创建 TOPIC

bin/kafka-topics.sh --create --zookeeper localhost:2181 --replication-factor 3 --partitions 1 --topic testTopicDup3

查看 topic 列表:

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

产生消息

bin/kafka-console-producer.sh --broker-list localhost:9092 --topic testTopicDup3

消费消息

bin/kafka-console-consumer.sh --bootstrap-server localhost:9092 --topic testTopicDup3 --from-beginning

查看描述 TOPICS 信息

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

创建topic:

分区为6,复制因子为1,数据的保留时间为1小时:

bin/kafka-topics.sh --create --topic ttopic-p1-r1-60min --partitions 6 --replication-factor 1 --config retention.ms=86400000 --bootstrap-server 10.0.xx:9092

查看分区

bin/kafka-topics.sh --list --bootstrap-server 10.0.xx:9092

压测:生产者,300万条数据,每条消息的大小为1KB,-throughput设为-1时表示消息会尽快生成。

bin/kafka-producer-perf-test.sh --topic ttopic-p1-r1-60min --throughput -1 --num-records 3000000 --record-size 1024 --producer-props acks=all bootstrap.servers=10.0.xx:9092

压测:消费者

bin/kafka-consumer-perf-test.sh --topic ttopic-p1-r1-60min --broker-list 10.0.xx:9092 --messages 3000000

删除topic:

bin/kafka-topics.sh --delete --topic ttopic-p1-r1-60min --bootstrap-server 10.0.xx:9092

©著作权归作者所有,转载或内容合作请联系作者
【社区内容提示】社区部分内容疑似由AI辅助生成,浏览时请结合常识与多方信息审慎甄别。
平台声明:文章内容(如有图片或视频亦包括在内)由作者上传并发布,文章内容仅代表作者本人观点,简书系信息发布平台,仅提供信息存储服务。

相关阅读更多精彩内容

友情链接更多精彩内容