7.9. 修改主题配置
kafka-configs.sh 工具可用于修改主题配置。kafka-configs.sh 是 AMQ Streams 发行版本的一部分,可在 bin 目录中找到。
先决条件
- AMQ Streams 集群已安装并运行
-
存在主题
mytopic
修改主题配置
使用
kafka-configs.sh工具获取当前的配置。-
在
--bootstrap-server选项中指定 Kafka 代理的主机和端口。 -
将
--entity-type设置为topic,将--entity-name设置为主题的名称。 使用
--describe选项获取当前的配置。/opt/kafka/bin/kafka-configs.sh --bootstrap-server <broker_address> --entity-type topics --entity-name <TopicName> --describe
/opt/kafka/bin/kafka-configs.sh --bootstrap-server <broker_address> --entity-type topics --entity-name <TopicName> --describeCopy to Clipboard Copied! Toggle word wrap Toggle overflow 获取名为
mytopic的主题配置的命令示例/opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name mytopic --describe
/opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name mytopic --describeCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
在
使用
kafka-configs.sh工具更改配置。-
在
--bootstrap-server选项中指定 Kafka 代理的主机和端口。 -
将
--entity-type设置为topic,将--entity-name设置为主题的名称。 -
使用
--alter选项修改当前配置。 在选项
--add-config中指定您要添加或更改的选项。/opt/kafka/bin/kafka-configs.sh --bootstrap-server <broker_address> --entity-type topics --entity-name <TopicName> --alter --add-config <Option>=<Value>
/opt/kafka/bin/kafka-configs.sh --bootstrap-server <broker_address> --entity-type topics --entity-name <TopicName> --alter --add-config <Option>=<Value>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 更改名为
mytopic的主题配置的命令示例/opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name mytopic --alter --add-config min.insync.replicas=1
/opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name mytopic --alter --add-config min.insync.replicas=1Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
在
使用
kafka-configs.sh工具删除现有配置选项。-
在
--bootstrap-server选项中指定 Kafka 代理的主机和端口。 -
将
--entity-type设置为topic,将--entity-name设置为主题的名称。 -
使用
--delete-config选项删除现有配置选项。 在选项
--remove-config中指定您要删除的选项。/opt/kafka/bin/kafka-configs.sh --bootstrap-server <broker_address> --entity-type topics --entity-name <TopicName> --alter --delete-config <Option>
/opt/kafka/bin/kafka-configs.sh --bootstrap-server <broker_address> --entity-type topics --entity-name <TopicName> --alter --delete-config <Option>Copy to Clipboard Copied! Toggle word wrap Toggle overflow 更改名为
mytopic的主题配置的命令示例/opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name mytopic --alter --delete-config min.insync.replicas
/opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name mytopic --alter --delete-config min.insync.replicasCopy to Clipboard Copied! Toggle word wrap Toggle overflow
-
在