一、修改主题
### --- 为topic_x加入segment.bytes配置
[root@hadoop ~]# kafka-topics.sh --zookeeper localhost:2181/myKafka --alter \
--topic topic_x --config segment.bytes=10485760
~~~ # Configs:segment.bytes=10485760:参数已经设置
[root@hadoop ~]# kafka-topics.sh --zookeeper localhost:2181/myKafka --describe --topics-with-overrides
Topic:topic_x PartitionCount:3 ReplicationFactor:1 Configs:segment.bytes=10485760
### --- 在topic_z下删除message.bytes配置
[root@hadoop ~]# kafka-topics.sh --zookeeper localhost:2181/myKafka --describe --topics-with-overrides
Topic:topic_z PartitionCount:5 ReplicationFactor:1 Configs:compression.type=gzip,max.message.bytes=512
~~~ # 删除topic_z下message.bytes配置
[root@hadoop ~]# kafka-topics.sh --zookeeper localhost:2181/myKafka --alter --delete-config \
max.message.bytes --topic topic_z
[root@hadoop ~]# kafka-topics.sh --zookeeper localhost:2181/myKafka --describe --topics-with-overrides
Topic:topic_z PartitionCount:5 ReplicationFactor:1 Configs:compression.type=gzip
二、删除主题
### --- 删除主题
~~~ kafka在v1.0.0之前是不可以删除的,最多标注一下是删除状态
~~~ 在kafkaV1.0.0之后是可以删除的
~~~ 官方说明:在1.0.0之前技术不是很成熟,不能删除
~~~ # 删除策略
~~~ 第一步:在zookeeper下把这个主题删除掉
~~~ 第二步:在正真存储数据的地方,把这个分区的文件夹删除掉
~~~ 同时这个分区有副本的话,副本也需要删除掉
### --- 删除主题
[zk: localhost:2181(CONNECTED) 1] get /myKafka/config/topics/topic_z
{"version":1,"config":{"compression.type":"gzip"}}
cZxid = 0x51f
ctime = Wed Sep 22 21:37:24 CST 2021
mZxid = 0x558
mtime = Wed Sep 22 21:52:41 CST 2021
pZxid = 0x51f
cversion = 0
dataVersion = 1
aclVersion = 0
ephemeralOwner = 0x0
dataLength = 50
numChildren = 0
~~~ # 删除主题
[root@hadoop ~]# kafka-topics.sh --zookeeper localhost:2181/myKafka --delete --topic topic_z
### --- 给主题添加删除的标记:待会直接删除掉
[root@hadoop ~]# ls /opt/yanqi/servers/kafka/kafka-logs/ | grep topic_z
topic_z-0.29b5cb37fe47476d9b66b4d296b2949b-delete
topic_z-1.abad93ad134644b1882066e03838acbf-delete
topic_z-2.b62f5ea622ff48b4b9b430aba81870a0-delete
topic_z-3.ff350278c0eb4a758e12bb79ccc3b059-delete
topic_z-4.72303fbddcce430ebfa680d881634508-delete
### --- zokkeeper下数据已经被删除掉
[zk: localhost:2181(CONNECTED) 3] ls /myKafka/config/topics
[topic_x, topic_y]