当前位置:   article > 正文

Kafka3.0.0版本——主题(topic)命令行操作_kafka3.0查看topic列表命令

kafka3.0查看topic列表命令

一、Kafka集群部署

二、三台服务器信息

  • 三台服务器
    服务器名称服务器ip
    centos7虚拟机1192.168.136.27
    centos7虚拟机2192.168.136.28
    centos7虚拟机3192.168.136.29

三、命令行操作(topic命令)

3.1、查看操作主题(topic)命令参数

  • 查看topic命令参数

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh
    
    • 1

    在这里插入图片描述

3.2、查看操作主题(topic)命令参数详解

  • topic命令参数详解
    参数描述
    –bootstrap-server <String: server toconnect to>连接的 Kafka Broker主机名称和端口号。
    –topic <String: topic>操作的 topic名称。
    –create创建主题。
    –delete删除主题。
    –alter修改主题。
    –list看所有主题。
    –describe查看主题详细描述。
    –partitions <Integer: # of partitions>设置分区数。
    –replication-factor<Integer: replication factor>设置分区副本。
    –config <String: name=value>更新系统默认的配置。

3.3、查看当前服务器中的所有主题(topic)示例

  • 查看centos7虚拟机2 (192.168.136.28)服务器中的所有 topic

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.136.28:9092 --list
    
    • 1

    在这里插入图片描述

3.4、创建主题(topic)示例

  • 创建 一个新闻(news) topic

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.136.28:9092 --create --partitions 1 --replication-factor 3 --topic news
    
    • 1

    在这里插入图片描述

  • 选项说明

    选项选项说明
    –topic定义 topic 名
    –replication-factor定义副本数
    –partitions定义分区数

3.5、查看主题(topic)的详情示例

  • 查看新闻(news)topic的详情

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.136.28:9092 --describe --topic news
    
    • 1

    在这里插入图片描述

3.6、修改topic的分区数示例(注意:分区数只能增加,不能减少

  • 修改新闻(news)topic的分区数

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.136.28:9092 --alter --partitions 3 --topic news
    
    • 1

    在这里插入图片描述

  • 再次新闻(news)topic的详情

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.136.28:9092 --describe --topic news
    
    • 1

    在这里插入图片描述

3.7、删除 topic示例

  • 删除 新闻(news)topic

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.136.28:9092 --delete --topic news
    
    • 1
  • 再次查看新闻(news)topic的详情

    [root@localhost kafka-3.0.0]# bin/kafka-topics.sh --bootstrap-server 192.168.136.28:9092 --describe --topic news
    
    • 1

    在这里插入图片描述

声明:本文内容由网友自发贡献,不代表【wpsshop博客】立场,版权归原作者所有,本站不承担相应法律责任。如您发现有侵权的内容,请联系我们。转载请注明出处:https://www.wpsshop.cn/w/从前慢现在也慢/article/detail/925773
推荐阅读
相关标签
  

闽ICP备14008679号