Kafka 运行 在 zookeeper 子上下文或 chroot 上

Kafka running on zookeeper subcontext or chroot

状态:我们正在与 kafka 和几个不同的服务共享 zookeeper,这些服务使用 zookeeper 进行协调。他们在 zookeeper 子上下文中运行良好。看起来像这样:

/
   /service1/...
   /service2/...
   /brokers/...
   /consumers/...

我的问题是.. 是否可以设置 kafka 以使用子上下文?因此,其他服务最终无法修改其他服务的子上下文。它将是:

/
   /service1/...
   /service2/...
   /kafka/brokers/...
   /kafka/consumers/...

我在其他项目中看到过这种语法:

zk://10.0.0.1,10.0.0.2/kafka

让我们说。因此,kafka 只会看到 brokersconsumers 路径,并且不会弄乱其他子上下文。

恐怕kafka当时不支持这种格式。另一个问题是,有解决方法吗?想以某种方式结束动物园管理员?有任何想法吗?或者kafka应该专门使用zookeeper。这是最佳实践吗?我们应该为每个项目生成 zookeeper,这太过分了,因此 zookeeper 需要集成至少包含 3 个节点。

感谢您的回答!

您可以在 Kafka 中使用 zk chroot 语法,详见 Kafka 配置 documentation

Zookeeper also allows you to add a "chroot" path which will make all kafka data for this cluster appear under a particular path. This is a way to setup multiple Kafka clusters or other applications on the same zookeeper cluster. To do this give a connection string in the form hostname1:port1,hostname2:port2,hostname3:port3/chroot/path which would put all this cluster's data under the path /chroot/path. Note that you must create this path yourself prior to starting the broker and consumers must use the same connection string.

最佳做法是维护单个 ZooKeeper 集群(至少我所见如此)。否则,您将创建更多的操作工作负载来维护良好的 ZK 集成。

关于操作化 ZK 的 Kafka documentation 建议使用多个 ZK:

Application segregation: Unless you really understand the application patterns of other apps that you want to install on the same box, it can be a good idea to run ZooKeeper in isolation (though this can be a balancing act with the capabilities of the hardware).