Josh Elias
Josh Elias

Reputation: 3290

Connecting to Couchbase Server Cluster

I've been using Couchbase for my database solution and so far it looks very good.

I'm confused however with connecting to a Cluster. A Cluster is just a group of nodes so when you use the API to connect to a Cluster what do you use as the IP? Do you just use one of the nodes in the Cluster? Does it matter which one?

I'm personally using the Node.js API.

Upvotes: 3

Views: 437

Answers (2)

Nico AD
Nico AD

Reputation: 1709

I asked this question a few months ago on couchbase forums and the author of the node.js module answered that you should use "some" of them

like :

cluster.openBucket("couchbase://server1,server2,server3", function(err) {});

if you have server4 and 5 are added , they will be automatically added to the cluster as soon as they are available in the cluster.

Check here for details : https://forums.couchbase.com/t/couchnode-connection-to-cluster/6281

Upvotes: 1

NoSQLKnowHow
NoSQLKnowHow

Reputation: 4865

Technically all you need is just one node in the list. As soon as it connects to that one, it will get the cluster map of the entire cluster and know all of the rest of the nodes. No it does not matter which node.

That being said, best practice is to have at least 3 nodes of the cluster listed in the connection string or better yet if the SDK you are using supports it, use a DNS SRV record with at least 3 nodes in there. With three nodes in the list if for some reason (e.g. server failure or maintenance) one of the nodes is unavailable, you can still bootstrap an application server to get that cluster map with one of the other nodes in the list.

Upvotes: 2

Related Questions