在 Debian 上“设主题”通常指 使用 Kafka 命令行工具创建 / 配置 Topic。下面按常见场景说明。
假设:
/opt/kafka常见目录:
/opt/kafka/bin/
/opt/kafka/bin/kafka-topics.sh \
--create \
--zookeeper localhost:2181 \
--replication-factor 1 \
--partitions 3 \
--topic test-topic
/opt/kafka/bin/kafka-topics.sh \
--create \
--bootstrap-server localhost:9092 \
--replication-factor 1 \
--partitions 3 \
--topic test-topic
参数说明:
--partitions:分区数--replication-factor:副本数(≤ broker 数量)--topic:主题名kafka-topics.sh --list --bootstrap-server localhost:9092
查看详情:
kafka-topics.sh --describe --topic test-topic --bootstrap-server localhost:9092
kafka-configs.sh \
--bootstrap-server localhost:9092 \
--entity-type topics \
--entity-name test-topic \
--alter \
--add-config retention.ms=86400000
kafka-topics.sh \
--alter \
--bootstrap-server localhost:9092 \
--topic test-topic \
--partitions 6
kafka-topics.sh \
--delete \
--bootstrap-server localhost:9092 \
--topic test-topic
⚠ 需确保:
delete.topic.enable=true
如果你用 systemd:
sudo systemctl start kafka
sudo systemctl start zookeeper
server.properties 中 listenersPATH如果你是指:
告诉我你的具体场景,我可以给你更精确的命令。