CouchbaseCluster setup for multiple nodes running data, query, index and analytics

Using java-client-2.7.0

In our cluster, there are 4 nodes running data, query, index and analytics.

10.xx.xx.xx -> data
10.xx.xx.xx -> query
10.xx.xx.xx -> index
10.xx.xx.xx -> analytics

What is the correct way to create com.couchbase.client.java.Cluster? Pass each IP address to CouchbaseCluster.create() method as an array of string?

Cluster cluster = CouchbaseCluster.create(“10.xx.xx.xx”, “10.xx.xx.xx”, “10.xx.xx.xx”, “10.xx.xx.xx”);

Is the above statement correct?

Hi Dony,

Yes, that should work.

You can pass only one of the addresses if you want, but then the client won’t be able to find the cluster if that one node is offline.

For a deep dive into this topic, check out Michael Nitschinger’s blog post:
https://blog.couchbase.com/inside-the-java-sdk-bootstrap/

Thanks,
David

Thanks for the reply, David.

This answer is valid only for SDK versions >= 2.70, right?
Answer here Java SDK can not access Query node in couchbase 5.0 recommends to not include query nodes in bootstrap list.
Also should Index nodes be included, or only kv nodes are compulsary ?

Hi @zxcvmnb,

This answer is valid only for SDK versions >= 2.70, right?

You’re right, I gave some bad advice in this case. Including non-KV nodes in the bootstrap list can cause problems for Java SDK versions prior to 2.7.5/2.7.6 [release notes].

Also should Index nodes be included, or only kv nodes are compulsary ?

Only KV nodes support the most efficient way of fetching cluster configuration. With SDK 2.7.5 and later you can bootstrap against any type of node, and the SDK will automatically switch to getting cluster configuration from a KV node if one is available. (In prior SDK versions, if you bootstrap against a non-KV node the client will stick with that node and continue to use the inefficient config fetching strategy, which can lead to other issues.)

If you’re using a Java SDK prior to 2.7.5, or if you want to bootstrap in the most efficient way, then include only KV nodes.

If you’re using SDK 2.7.5 or later and you want to be able to connect to the cluster even if all of the KV nodes are offline, it’s safe to include all nodes (of any kind).

2 Likes