如何运行两个Kafka实例休息

How to run two instances of 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

The only requirement for multiple instances is that you set a unique id for each instance.

但是,当我 运行 与其他 id 的第二个实例时,会抛出一个异常,提示该地址已在使用中:

WARN FAILED io.confluent.rest.Application@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)

...

ID不控制端口。文档中的"Multiple instances"表示独立机器

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

listeners
Comma-separated list of listeners that listen for API requests over either HTTP or HTTPS

Default: “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 个动物园管理员、3 个代理、2 个注册表和 2 个代理,你基本上是在乞求 运行 内存不足