kafka topic的應用
阿新 • • 發佈:2021-02-06
kafka的使用
topic檢視和建立
1、檢視建立的topic,進入topic bin目錄
sh kafka-topics.sh --list --zookeeper 192.168.80.100:2181,192.168.80.109:2181,192.168.80.121:2181
2、建立topic(三種方式)
sh kafka-topics.sh --create --zookeeper 192.168.80.100:2181,192.168.80.109:2181,192.168.80.121:2181 --replication-factor 1 --partitions 1 --topic kafka_statice_data sh kafka-topics.sh --create --zookeeper 192.168.80.100:2181,192.168.80.109:2181,192.168.80.121:2181 --topic kafka_statice_data --replication-factor 3 --partitions 10 --config cleanup.policy=compact sh kafka-topics.sh --create --zookeeper 192.168.80.100:2181,192.168.80.109:2181,192.168.80.121:2181 --topic kafka_statice_data --partitions 1 --replication-factor 1 --config max.message.bytes=64000 --config flush.messages=1 #檢視某topic具體情況 bin/kafka-topics.sh --zookeeper 192.168.80.100:2181,192.168.80.109:2181,192.168.80.121:2181 --describe --topic kafka_statice_data
partitions -->分割槽數
replication-factor -->備份數 (叢集時才會有備份)
3、consumer-group相關
1、列出當前所有的消費組 sh kafka-consumer-groups.sh --bootstrap-server 192.168.80.100:9092,192.168.80.109:9092,192.168.80.121:9092 --list 2、檢視某消費組 bin/kafka-consumer-groups.sh --bootstrap-server 192.168.80.100:9092,192.168.80.109:9092,192.168.80.121:9092 --group test_group --describe