如何在 Apache Kafka 中删除多个主题 [英] How to delete multiple topics in Apache Kafka

查看:30
本文介绍了如何在 Apache Kafka 中删除多个主题的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

假设我有许多具有相同前缀的主题,例如:

Assuming that I have a number of topics with the same prefix, e.g:

giorgos-topic1
giorgos-topic2
giorgos-topic3
...

用于删除单个主题的命令(例如 giorgos-topic1)如下:

The command used for deleting a single topic (say giorgos-topic1) is the following:

./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic giorgos-topic1

是否可以使用单个命令和可能的正则表达式/通配符(例如 giorgos-*)来删除多个主题,而不是一一输入所有需要删除的主题名称?

Is it possible to delete multiple topics using a single command and possibly a regular expression/wildcard (e.g. giorgos-*) instead of typing all the topic names that need to be deleted one by one?

推荐答案

是的,您可以在使用 kafka-topics.sh 工具删除主题时使用类似正则表达式的表达式:

Yes you can use regex-like expressions when deleting topics with the kafka-topics.sh tool:

例如,删除所有以 giorgos- 开头的主题:

For example, to delete all topics starting with giorgos-:

./bin/kafka-topics.sh --zookeeper localhost:2181 --delete --topic 'giorgos-.*'

<小时>

使用管理 API,您还可以一次删除多个主题,请参阅AdminClient.删除主题

这篇关于如何在 Apache Kafka 中删除多个主题的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆