我在用以下命令删除topic和查看topic的时候
./kafka-topics.sh --delete --zookeeper node1:2181 --topic test-topic
./kafka-topics.sh --list --zookeeper node1:2181
都出现了以下错误

错误的原因可能是你使用的Kafka 版本是 2.8.0或以上,而集群模式是KRaft而不是Zookeeper
- 如果 Kafka 集群是基于 Zookeeper 的,请确保您下载的 Kafka 脚本支持
--zookeeper
参数。 - 如果 Kafka 集群是基于 KRaft 模式,您需要改用
--bootstrap-server
参数。
换以下命令试试
./kafka-topics.sh --delete --bootstrap-server localhost:9093 --topic test-topic
./kafka-topics.sh --list --bootstrap-server localhost:9092

已成功删除topic