使用 kafka-configs 更新 Kafka advertised.listeners



我必须使用命令行工具"kafka-configs.sh"更新Kafka代理配置广告.listeners。使用命令行的原因是实例/代理在 AWS 中运行,要从外部访问它,我们需要将终端节点添加到其中。
目前从 ZkCLI 中,我们可以看到当前侦听器端点的列表:

{"listener_security_protocol_map":{"CLIENT":"PLAINTEXT","CLIENT_SECURE":"SSL","REPLICATION":"PLAINTEXT","REPLICATION_SECURE":"SSL"},"endpoints":["CLIENT://b-1:9092","CLIENT_SECURE://b-1:9094","REPLICATION://b-1:9093","REPLICATION_SECURE://b-1:9095"],"rack":"subnet-09d8","jmx_port":9099,"host":"b-1.amazonaws.com","timestamp":"1574664497892","port":9092,"version":4}

当我尝试为其中一个代理添加侦听器安全协议时,我们收到以下错误:

./kafka-configs.sh --bootstrap-server b-3.amazonaws.com:9094  --command-config client.properties --entity-type brokers --entity-name 1 --alter --add-config  listener.security.protocol.map="EXTERNAL:PLAINTEXT"
java.util.concurrent.ExecutionException: org.apache.kafka.common.errors.InvalidRequestException:
Caused by: org.apache.kafka.common.errors.InvalidRequestException: Invalid config value for resource ConfigResource(type=BROKER, name='1'): Error creating broker listeners from 'CLIENT://b-1.amazonaws.com:9092,CLIENT_SECURE://b-1.amazonaws.com:9094,REPLICATION://b-1amazonaws.com:9093,REPLICATION_SECURE://b-1.amazonaws.com:9095': No security protocol defined for listener CLIENT

如果我们尝试直接添加端点,我们会得到:

kafka-configs.sh --bootstrap-server b-3.amazonaws.com:9094  --command-config client.properties --entity-type brokers --entity-name 1 --alter --add-config advertised.listeners="PLAINTEXT://vpce-amazonaws.com:36379"
: No security protocol defined for listener PLAINTEXT

为了验证我们是否可以做到这一点,我们尝试添加一些其他参数,看起来它按预期工作:

./kafka-configs.sh --bootstrap-server b-3.amazonaws.com:9094  --command-config client.properties --entity-type brokers --entity-name 1 --alter --add-config log.cleaner.threads=2
Completed updating config for broker: 1.

看了这里和那里,尝试指定所有安全组(加上我们的添加(,但没有运气。我们在这里缺少什么?

正确的方法是:

./kafka-configs.sh --bootstrap-server b-3.amazonaws.com:9094    
--command-config client.properties    
--entity-type brokers --entity-name 1     
--alter --add-config listener.security.protocol.map=["CLIENT:PLAINTEXT,CLIENT_SECURE:SSL,REPLICATION:PLAINTEXT,REPLICATION_SECURE:SSL"]

在命令中,您只定义一个映射:

./kafka-configs.sh --bootstrap-server b-3.amazonaws.com:9094  
--command-config  client.properties 
--entity-type brokers --entity-name 1 
--alter --add-config  listener.security.protocol.map="EXTERNAL:PLAINTEXT"

您应该尝试添加完整列表:

./kafka-configs.sh --bootstrap-server b-3.amazonaws.com:9094  
--command-config  client.properties 
--entity-type brokers --entity-name 1 
--alter --add-config  listener.security.protocol.map="EXTERNAL:PLAINTEXT,CLIENT:PLAINTEXT,CLIENT_SECURE:SSL,REPLICATION:PLAINTEXT,REPLICATION_SECURE:SSL"

相关内容

最新更新