Cassandra Java 驱动程序:多少个接触点是合理的? [英] Cassandra Java driver: how many contact points is reasonable?

查看:34
本文介绍了Cassandra Java 驱动程序:多少个接触点是合理的?的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

在 Java 中,我连接到 Cussandra 集群如下:

In Java I connect to Cussandra cluster as this:

Cluster cluster = Cluster.builder().addContactPoints("host-001","host-002").build();

我需要在那里指定集群的所有主机吗?如果我有一个 1000 个节点的集群怎么办?我随机选择几个?有多少,我真的是随机做的吗?

Do I need to specify all hosts of the cluster in there? What If I have a cluster of 1000 nodes? Do I randomly choose few? How many, and do I really do that randomly?

推荐答案

我想说,将您的客户端配置为使用与您配置 Cassandra 使用的种子节点列表相同的节点列表将为您提供最佳结果.

I would say that configuring your client to use the same list of nodes as the list of seed nodes you configured Cassandra to use will give you the best results.

如您所知,Cassandra 节点使用种子节点来寻找彼此并发现环的拓扑结构.驱动程序将仅使用列表中提供的节点之一来建立控制连接,该节点用于发现集群拓扑,但是为客户端提供种子节点会增加客户端的机会在节点故障的情况下继续运行.

As you know Cassandra nodes use the seed nodes to find each other and discover the topology of the ring. The driver will use only one of the nodes provided in the list to establish the control connection, the one used to discover the cluster topology, but providing the client with the seed nodes will increase the chance for the client to continue to operate in case of node failures.

这篇关于Cassandra Java 驱动程序:多少个接触点是合理的?的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆