使用kafka配置更新kafka Adverted.listeners

nnvyjq4y  于 2021-06-04  发布在  Kafka
关注(0)|答案(2)|浏览(544)

我必须使用命令行工具“kafka configs.sh”更新kafka broker config adverted.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.

四处查看,尝试指定所有安全组(添加了我们的内容),但运气不佳。我们缺少什么?

dgiusagp

dgiusagp1#

正确的方法是:

./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"]
wbgh16ku

wbgh16ku2#

在命令中,只能定义一个Map:

./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"

相关问题