Cassandra Java驱动程序:有多少联系人是合理的? [英] Cassandra Java driver: how many contact points is reasonable?

查看:148
本文介绍了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?

推荐答案

我的方法是添加尽可能多的节点 - 原因很简单:种子仅仅用于集群启动,但是一旦集群启动并且运行种子只是公共节点 - 仅使用种子可能导致不可能在工作集群中连接 - 所以我给自己最好的机会连接到集群,保持一个合理数量的节点 - 足够一个工作节点获取当前集群配置。

My approach is to add as many nodes as I can -- The reason is simple: seeds are necessary only for cluster boot but once the cluster is up and running seeds are just common nodes -- using only seeds may result in the impossibility to connect in a working cluster -- So I give myself the best chances to connect to the cluster keeping a more than reasonable amount of nodes -- it's enough one working node to get the current cluster configuration.

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

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