Networking 在多网络上使用卡夫卡

Networking 在多网络上使用卡夫卡,networking,apache-kafka,apache-zookeeper,kafka-consumer-api,Networking,Apache Kafka,Apache Zookeeper,Kafka Consumer Api,我在不同的虚拟机上有一个卡夫卡集群。 我希望能够从两个不同的网络(10.X.X.X和172.X.X.X)生成和使用主题。 我试着配置不同的解决方案,比如不在监听器中指定任何内容,或者如下所示的配置,但似乎没有任何效果。有人能建议什么是正确的配置吗 # Licensed to the Apache Software Foundation (ASF) under one or more # contributor license agreements. See the NOTICE file di

我在不同的虚拟机上有一个卡夫卡集群。 我希望能够从两个不同的网络(10.X.X.X和172.X.X.X)生成和使用主题。 我试着配置不同的解决方案,比如不在监听器中指定任何内容,或者如下所示的配置,但似乎没有任何效果。有人能建议什么是正确的配置吗

# Licensed to the Apache Software Foundation (ASF) under one or more
# contributor license agreements.  See the NOTICE file distributed with
# this work for additional information regarding copyright ownership.
# The ASF licenses this file to You under the Apache License, Version 2.0
# (the "License"); you may not use this file except in compliance with
# the License.  You may obtain a copy of the License at
#
#    http://www.apache.org/licenses/LICENSE-2.0
#
# Unless required by applicable law or agreed to in writing, software
# distributed under the License is distributed on an "AS IS" BASIS,
# WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
# See the License for the specific language governing permissions and
# limitations under the License.

# see kafka.server.KafkaConfig for additional details and defaults

############################# Server Basics #############################

# The id of the broker. This must be set to a unique integer for each broker.
broker.id=3

############################# Socket Server Settings #############################

# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=PLAINTEXT://0.0.0.0:9092

# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=PLAINTEXT://172.X.X.X:9092

# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
还尝试配置以下选项:

# The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners= EXTERNAL://172.X.X:9093,INTERNAL://10.20.4.234:9092

# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners= EXTERNAL://172.X.X.X:9093,INTERNAL://10.X.X.X:9092

# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
    listener.security.protocol.map=PLAINTEXT:PLAINTEXT,EXTERNAL:PLAINTEXT,INTERNAL:PLAINTEXT
我一直得到以下错误:

[2021-03-30 08:30:02,798] ERROR Exiting Kafka due to fatal exception (kafka.Kafka$)
java.lang.IllegalArgumentException: requirement failed: inter.broker.listener.name must be a listener name defined in advertised.listeners. The valid options based on currently configured listeners are EXTERNAL,INTERNAL
        at scala.Predef$.require(Predef.scala:277)
        at kafka.server.KafkaConfig.validateValues(KafkaConfig.scala:1399)
        at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1374)
        at kafka.server.KafkaConfig.<init>(KafkaConfig.scala:1063)
        at kafka.server.KafkaConfig$.fromProps(KafkaConfig.scala:1043)
        at kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:28)
        at kafka.Kafka$.main(Kafka.scala:59)
        at kafka.Kafka.main(Kafka.scala)
[2021-03-30 08:30:02798]由于致命异常(Kafka.Kafka$)退出卡夫卡时出错
java.lang.IllegalArgumentException:要求失败:inter.broker.listener.name必须是在advised.listeners中定义的侦听器名称。基于当前配置的侦听器的有效选项包括外部、内部和外部
在scala.Predef$.require处(Predef.scala:277)
位于kafka.server.kafkanconfig.validateValues(kafkanconfig.scala:1399)
在kafka.server.kafkanconfig.(kafkanconfig.scala:1374)
在kafka.server.kafkanconfig.(kafkanconfig.scala:1063)
在kafka.server.kafkanconfig$fromProps(kafkanconfig.scala:1043)
在kafka.server.KafkaServerStartable$.fromProps(KafkaServerStartable.scala:28)
在kafka.kafka$.main(kafka.scala:59)
在卡夫卡.卡夫卡.梅因(卡夫卡.斯卡拉)

最终,我以这种方式对其进行了配置,它可以正常工作:

 The address the socket server listens on. It will get the value returned from
# java.net.InetAddress.getCanonicalHostName() if not configured.
#   FORMAT:
#     listeners = listener_name://host_name:port
#   EXAMPLE:
#     listeners = PLAINTEXT://your.host.name:9092
listeners=EXTERNAL://172.X.X.X:9093,INTERNAL://10.X.X.X:9092

# Hostname and port the broker will advertise to producers and consumers. If not set,
# it uses the value for "listeners" if configured.  Otherwise, it will use the value
# returned from java.net.InetAddress.getCanonicalHostName().
advertised.listeners=EXTERNAL://172.X.X.X:9093,INTERNAL://10.X.X.X:9092

# Maps listener names to security protocols, the default is for them to be the same. See the config documentation for more details
#listener.security.protocol.map=PLAINTEXT:PLAINTEXT,SSL:SSL,SASL_PLAINTEXT:SASL_PLAINTEXT,SASL_SSL:SASL_SSL
listener.security.protocol.map=EXTERNAL:PLAINTEXT,INTERNAL:PLAINTEXT
inter.broker.listener.name=INTERNAL