6.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> --describe
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 --describe
/opt/kafka/bin/kafka-configs.sh --bootstrap-server localhost:9092 --entity-type topics --entity-name mytopic --describe
Copy 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=1
Copy 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.replicas
Copy to Clipboard Copied! Toggle word wrap Toggle overflow
-
在