Topic 相关操作(创建,查看,修改,删除)

创建 topic

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --zookeeper localhost:2181 --create --topic heilu --partitions 2 --replication-factor 1     // 创建 topic 命令
Created topic heilu.

查看 topic

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh  --zookeeper localhost:2181 --describe --topic heilu  // 查看topic详细信息
Topic:heilu	PartitionCount:2	ReplicationFactor:1	Configs:
	Topic: heilu	Partition: 0	Leader: 0	Replicas: 0	Isr: 0
	Topic: heilu	Partition: 1	Leader: 0	Replicas: 0	Isr: 0

修改 topic

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --alter --zookeeper 192.168.131.130:2181 --topic heilu --config flush.messages=1
WARNING: Altering topic configuration from this script has been deprecated and may be removed in future releases.
         Going forward, please use kafka-configs.sh for this functionality
Updated config for topic heilu.

删除 topic

若 delete.topic.enable=true,直接彻底删除topic。
若 delete.topic.enable=false,如果当前topic没有使用过即没有传输过信息,可以彻底删除。
如果当前topic有使用过即有传输过信息,并没有真正删除topic,只是标记为删除(marked for deletion),重启kafka server 后删除。

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --delete --zookeeper 192.168.131.130:2181 --topic heilu  // 删除命令
Topic heilu is marked for deletion.  // 结果是 标记为删除
Note: This will have no impact if delete.topic.enable is not set to true.
[root@localhost kafka_2.12-2.2.1]# 

添加 partitions

只能添加,不能减少

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --alter --zookeeper 192.168.131.130:2181 --topic heilu --partitions 3
WARNING: If partitions are increased for a topic that has a key, the partition logic or ordering of the messages will be affected
Adding partitions succeeded!

查看所有topic

[root@localhost kafka_2.12-2.2.1]# bin/kafka-topics.sh --zookeeper localhost:2181 --list   // 查看存在 topic 命令 
heilu
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值