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