couchbase java 如何设置服务器IP和用户名密码

couchbase java how to set the server IP and the username and password

我像这样连接到本地主机上的 coucbhase:

Cluster cluster = CouchbaseCluster.create();

现在服务器不在我的机器上了,我必须设置服务器 IP 以及用户名和密码,有什么想法吗?

我试图在网上搜索,但我不能后悔。

我自己找到了解决方案

集群集群=CouchbaseCluster.create("here i put the ip");

注意,如果你有多个节点(生产中建议至少3个),你应该至少传入两个IP,这样如果一个节点挂了另一个可以用于bootstrap SDK:

Cluster cluster = CouchbaseCluster.create("IP1", "IP2");
Bucket bucket = cluster.openBucket("bucketName", "bucketPassword");

您需要管理员密码才能获得对 ClusterManager 的引用(可用于 cluster-wide 操作,如创建新存储桶等...):

cluster.clusterManager("adminUsername", "adminPassword");