使用kafka-configs更新

时间:2019-11-26 14:14:45

标签: amazon-web-services apache-kafka

我必须使用命令行工具“ kafka-configs.sh”更新Kafka代理配置advertised.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.

四处寻找,尝试指定所有安全组(加上我们的添加),但是没有运气。我们在这里缺少什么?

2 个答案:

答案 0 :(得分:0)

在您的命令上,您仅定义一张地图:

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

答案 1 :(得分:0)

正确的方法是:

   this.setState({
      data:reponseJson,
      isLoading:false
   }, () => {
      console.log(this.state.data.awayTeam.logo)
 })