kafka shell 命令行操作

kafka的命令行操作
    1、产看当前集群中已存在的主题topic
        bin/kafka-topics.sh --list --zookeeper bigdata:2181 
    2、创建主题topic
        bin/kafka-topics.sh --create --zookeeper bigdata:2181 --replication-factor 1 --partitions 1 --topic test1
            --zookeeper 连接zk集群
            --create 创建
            --replication-factor    副本
            --partitions    分区
            --topic     主题名
    3、删除主题
        bin/kafka-topics.sh --delete --zookeeper bigdata:2181 --topic test1
    4、发送消息(producer)
        bin/kafka-console-producer.sh --broker-list bigdata:9092 --topic test
    5、接收消息(consumer)
        老版本
            bin/kafka-console-consumer.sh --zookeeper bigdata:2181 --topic test --from-beginning
        新版本启动方式:
            bin/kafka-console-consumer.sh --bootstrap-server bigdata:9092 --topic test --from-beginning
    6、查看主题详细信息
        bin/kafka-topics.sh --zookeeper bigdata:2181 --describe --topic test
            Topic:test1    PartitionCount:1    ReplicationFactor:1    Configs:
                Topic: test1    Partition: 0    Leader: 0    Replicas: 0    Isr: 0

猜你喜欢

转载自blog.csdn.net/weixin_42898914/article/details/85062889