Please help me!..About three-node clustering and failover

Hello! I would like to ask a question. Currently, I have a cluster with three nodes, and I simulated a failure in one of the nodes ( At this moment, is it the only option to manually press Failover and Rebalance on the Web UI?

Regarding the Java SDK, is it unable to automatically connect to the functioning node during the failure period of (

I currently have three nodes. How can I set up failover on the Web UI?


my settings

my program

package ecomshop;

import java.time.Duration;


public class ClusterDBConfig {

     static final String connectionString=",,"; //ok
	 static final String username="Admin";
	 static final String password="ecom@168";
	 static final String bucketName="Test";
	 static final String scopeName="Commerce";
	 static final String collectionName="customers";
	public static void main(String[] args) {
		Cluster cluster = null;
		try {

			cluster = Cluster.connect(connectionString, ClusterOptions.clusterOptions(username, password));
			Bucket customerBucket = cluster.bucket(bucketName);
			Scope customerScope = customerBucket.scope(scopeName);
			Collection customerCollection= customerScope.collection(collectionName);
			 GetResult queryResult = customerCollection.get("a0001");

		} catch (Exception e) {
		}finally {
			if(cluster!=null) {


Failover is described in Failover | Couchbase Docs

I assume you stimulated the failure by killing the couchbase processes, shutting down the machine or by disconnecting it from the network. In all those cases, the couchbase processes on the node would not be reachable from any external process.

1 Like
1 Like
  1. thank you.
    As of the current situation, my application side doesn’t need to modify the code. It only
    requires configuration in the Couchbase Web UI, correct?

  2. I don’t know why?
    I have another question regarding what is mentioned on the official website and in the API
    documentation. In a production environment, the documentation suggests providing multiple
    nodes to prevent a single node failure and automatically redirecting to a connectable node. Is
    this completely accurate, or are there some prerequisites for this?

This is what we recommend in production:
Cluster cluster = Cluster.connect(“host1,host2,host3”, “user”, “password”); // recommended in production

  1. The SDK will automatically use the new (failed over and rebalanced) configuration if and when it is possible. Failover and rebalance need to complete for the new configuration to be completely usesble. Before failover and rebalance complete, the SDK will use the remaining nodes for query and kv operations. This means that active documents on the failed node(s) will not be accessible until failover and rebalance completed. Document replicas on remaining nodes (of documents that were on the failed nide(s)) will be readable via getReplica() APIs.

  2. Specifying multiple nodes in the connection string is a good idea because if the SDK ever goes back to the original connection string, and it is only “host1”, and host1 had failed, the SDK will have no place to get the cluster configuration from. That’s the only reason. Specifying multiple hosts does not give automatic failover or rebalance or anything else. It just gives the SDK multiple places to get the cluster configuration from

1 Like

This topic was automatically closed 90 days after the last reply. New replies are no longer allowed.