如何运行两个Kafka Rest实例

时间:2018-06-28 06:57:19

标签: apache-kafka confluent kafka-rest

我正在尝试为Kafka Rest运行第二个实例。这是第一个属性文件:

id=kafka-rest-test-server-1
schema.registry.url=http://localhost:8081,http://localhost:9081
zookeeper.connect=localhost:2181,localhost:2182,localhost:2183
bootstrap.servers=PLAINTEXT://localhost:9092,PLAINTEXT://localhost:9093,PLAINTEXT://localhost:9094

根据Confluent's docs

  

多个实例的唯一要求是您设置唯一   每个实例的ID。

但是,当我与其他id运行第二个实例时,抛出一个异常,指出该地址已被使用:

WARN FAILED io.confluent.rest.Application$1@41294f8: java.net.BindException: Address already in use (org.eclipse.jetty.util.component.AbstractLifeCycle:212)
java.net.BindException: Address already in use
at sun.nio.ch.Net.bind0(Native Method)
at sun.nio.ch.Net.bind(Net.java:433)
at sun.nio.ch.Net.bind(Net.java:425)
at sun.nio.ch.ServerSocketChannelImpl.bind(ServerSocketChannelImpl.java:223)
at sun.nio.ch.ServerSocketAdaptor.bind(ServerSocketAdaptor.java:74)

...

1 个答案:

答案 0 :(得分:1)

该ID不能控制端口。文档中的“多个实例”表示独立的机器

就像架构注册表一样,配置listeners

  

listeners
  逗号分隔的侦听器列表,用于通过HTTP或HTTPS监听API请求

     

默认:“ http://0.0.0.0:8082

https://docs.confluent.io/current/kafka-rest/docs/config.html#kafkarest-config

port属性已被弃用,但是如果您运行的是旧版本,则对其进行设置也不会造成伤害

例如,首先保留默认值

第二个实例,使用任何可用的端口

listeners=http://0.0.0.0:18082

通常建议您使用一台以上的计算机来实现高可用性和分布式处理。运行3个Zookeeper,3个经纪人,2个注册表和2个代理,您基本上是在请求RAM耗尽