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