Amazon ec2 can';t运行具有多个节点的couchbase群集

Amazon ec2 can';t运行具有多个节点的couchbase群集,amazon-ec2,couchbase,Amazon Ec2,Couchbase,我试着坐沙发。我写了一些代码(借助couchbase文档)。当我有1服务器时,读写工作非常出色 当我安装第二台服务器时,我无法写入/或读取。。。连接很长(1台服务器的连接速度很快) 我做错了什么 代码显然是有效的。这是我在EC2上添加节点时所做的事情?所有港口都(向全世界)开放。当我加入集群时,再平衡是可以的 示例:我的集群已启动并正在运行(此处EC2上有5个节点): 这是我的日志: 连接: 2014-07-04 17:25:20.600 INFO net.spy.memcached.auth

我试着坐沙发。我写了一些代码(借助couchbase文档)。当我有1服务器时,读写工作非常出色

当我安装第二台服务器时,我无法写入/或读取。。。连接很长(1台服务器的连接速度很快)

我做错了什么

代码显然是有效的。这是我在EC2上添加节点时所做的事情?所有港口都(向全世界)开放。当我加入集群时,再平衡是可以的

示例:我的集群已启动并正在运行(此处EC2上有5个节点):

这是我的日志:

连接:

2014-07-04 17:25:20.600 INFO net.spy.memcached.auth.AuthThread:  Authenticated to /54.247.158.182:11210
2014-07-04 17:25:20.811 INFO com.couchbase.client.vbucket.provider.BucketConfigurationProvider:  Could bootstrap through carrier publication.
写:

2014-07-04 17:25:20.817 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=/10.57.35.15:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-07-04 17:25:20.818 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=/10.250.110.205:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-07-04 17:25:20.818 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=/10.250.153.230:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-07-04 17:25:20.819 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=/10.59.13.200:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
2014-07-04 17:25:20.819 INFO com.couchbase.client.CouchbaseConnection:  Added {QA sa=/10.65.51.132:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0} to connect queue
阅读:

2014-07-04 17:25:30.820 INFO com.couchbase.client.vbucket.provider.BucketConfigurationProvider:  Could bootstrap through carrier publication.
2014-07-04 17:25:45.847 INFO com.couchbase.client.CouchbaseClient:  CouchbaseConnectionFactory{bucket='Users', nodes=[http://54.247.158.182:8091/pools], order=RANDOM, opTimeout=2500, opQueue=16384, opQueueBlockTime=10000, obsPollInt=10, obsPollMax=500, obsTimeout=5000, viewConns=10, viewTimeout=75000, viewWorkers=1, configCheck=10, reconnectInt=1100, failureMode=Redistribute, hashAlgo=NATIVE_HASH, authWaitTime=2500}
Connected to CouchbaseConnectionFactory{bucket='Users', nodes=[http://54.247.158.182:8091/pools], order=RANDOM, opTimeout=2500, opQueue=16384, opQueueBlockTime=10000, obsPollInt=10, obsPollMax=500, obsTimeout=5000, viewConns=10, viewTimeout=75000, viewWorkers=1, configCheck=10, reconnectInt=1100, failureMode=Redistribute, hashAlgo=NATIVE_HASH, authWaitTime=2500}
2014-07-04 17:26:10.908 INFO com.couchbase.client.CouchbaseClient:  viewmode property isn't defined. Setting viewmode to production mode
2014-07-04 17:26:10.989 INFO com.couchbase.client.CouchbaseConnection:  Node for key "user101" is not active (yet). Queueing up for retry and checking for stale configuration.
2014-07-04 17:26:11.362 INFO com.couchbase.client.CouchbaseConnection:  Node for key "user101" is not active (yet). Queueing up for retry and checking for stale configuration.
2014-07-04 17:26:12.363 INFO com.couchbase.client.CouchbaseConnection:  Node for key "user101" is not active (yet). Queueing up for retry and checking for stale configuration.
2014-07-04 17:26:13.365 INFO com.couchbase.client.CouchbaseConnection:  Node for key "user101" is not active (yet). Queueing up for retry and checking for stale configuration.
2014-07-04 17:26:13.490 WARN net.spy.memcached.MemcachedConnection:  handling node for operation is not set
java.lang.RuntimeException: Timed out waiting for operation
    at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:142)
    at com.t2s.injector.Injector.insertData(Injector.java:71)
    at com.t2s.injector.Injector.main(Injector.java:27)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: net.spy.memcached.internal.CheckedOperationTimeoutException: Timed out waiting for operation - failing node: <unknown>
    at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:167)
    at net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:140)
    ... 7 more
2014-07-04 17:27:27.995 INFO com.couchbase.client.CouchbaseConnection:  Reconnecting due to failure to connect to {QA sa=10.250.110.205/10.250.110.205:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connexion terminée par expiration du délai d'attente
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:735)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:677)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:436)
    at com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:324)
java.lang.RuntimeException: Timed out waiting for operation
    at com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:75)
    at com.couchbase.client.CouchbaseClient.getView(CouchbaseClient.java:430)
    at com.t2s.injector.Injector.queryView(Injector.java:85)
    at com.t2s.injector.Injector.main(Injector.java:33)
    at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
    at sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)
    at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)
    at java.lang.reflect.Method.invoke(Method.java:606)
    at com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
Caused by: java.util.concurrent.TimeoutException: Timed out waiting for operation
    at com.couchbase.client.internal.HttpFuture.waitForAndCheckOperation(HttpFuture.java:93)
    at com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:82)
    at com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:72)
    ... 8 more
2014-07-04 17:27:53.249 WARN com.couchbase.client.CouchbaseConnection:  Closing, and reopening {QA sa=10.250.110.205/10.250.110.205:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}, attempt 1.
2014-07-04 17:27:53.249 INFO com.couchbase.client.CouchbaseConnection:  Reconnecting due to failure to connect to {QA sa=10.250.153.230/10.250.153.230:11210, #Rops=0, #Wops=0, #iq=0, topRop=null, topWop=null, toWrite=0, interested=0}
java.net.ConnectException: Connexion terminée par expiration du délai d'attente
    at sun.nio.ch.SocketChannelImpl.checkConnect(Native Method)
    at sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:735)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:677)
    at net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:436)
    at com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:324)
2014-07-04 17:28:08.534 INFO com.couchbase.client.ViewConnection:  I/O reactor terminated
2014-07-04 17:25:30.820信息com.couchbase.client.vbucket.provider.BucketConfigurationProvider:可以通过运营商发布引导。
2014-07-04 17:25:45.847 INFO com.couchbase.client.CouchbaseClient:CouchbaseConnectionFactory{bucket='Users',节点=[http://54.247.158.182:8091/pools],order=RANDOM,opTimeout=2500,opQueue=16384,opQueueBlockTime=10000,obsPollInt=10,obsPollMax=500,obspoltimeout=5000,viewConns=10,viewWorkers=1,configCheck=10,reconnect=1100,failureMode=Redistribute,hashAlgo=NATIVE_散列,authWaitTime=2500}
已连接到CouchbaseConnectionFactory{bucket='Users',节点=[http://54.247.158.182:8091/pools],order=RANDOM,opTimeout=2500,opQueue=16384,opQueueBlockTime=10000,obsPollInt=10,obsPollMax=500,obspoltimeout=5000,viewConns=10,viewWorkers=1,configCheck=10,reconnect=1100,failureMode=Redistribute,hashAlgo=NATIVE_散列,authWaitTime=2500}
2014-07-04 17:26:10.908 INFO com.couchbase.client.CouchbaseClient:未定义viewmode属性。将viewmode设置为生产模式
2014-07-04 17:26:10.989 INFO com.couchbase.client.couchbase连接:密钥“user101”的节点未处于活动状态(尚未)。排队等待重试并检查过时的配置。
2014-07-04 17:26:11.362 INFO com.couchbase.client.CouchbaseConnection:密钥“user101”的节点未激活(尚未激活)。排队等待重试并检查过时的配置。
2014-07-04 17:26:12.363 INFO com.couchbase.client.couchbase连接:密钥“user101”的节点未处于活动状态(尚未)。排队等待重试并检查过时的配置。
2014-07-04 17:26:13.365 INFO com.couchbase.client.couchbase连接:密钥“user101”的节点未处于活动状态(尚未)。排队等待重试并检查过时的配置。
2014-07-04 17:26:13.490警告net.spy.memcached.memcached连接:未设置操作的处理节点
java.lang.RuntimeException:等待操作时超时
net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:142)
位于com.t2s.injector.injector.insertData(injector.java:71)
位于com.t2s.injector.injector.main(injector.java:27)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)中
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:606)
位于com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
原因:net.spy.memcached.internal.CheckedOperationTimeoutException:等待操作超时-失败节点:
net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:167)
net.spy.memcached.internal.OperationFuture.get(OperationFuture.java:140)
... 还有7个
2014-07-04 17:27:27.995 INFO com.couchbase.client.CouchbaseConnection:由于无法连接到{QA sa=10.250.110.205/10.250.110.205:11210,#Rops=0,#Wops=0,#iq=0,topRop=null,topWop=null,toWrite=0,Interest=0}
Java.NET.java连接异常:连接席
在sun.nio.ch.socketchannel.checkConnect(本机方法)
位于sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:735)
位于net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:677)
位于net.spy.memcached.MemcachedConnection.handleIO(MemcachedConnection.java:436)
在com.couchbase.client.CouchbaseConnection.run(CouchbaseConnection.java:324)
java.lang.RuntimeException:等待操作时超时
位于com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:75)
位于com.couchbase.client.CouchbaseClient.getView(CouchbaseClient.java:430)
位于com.t2s.injector.injector.queryView(injector.java:85)
位于com.t2s.injector.injector.main(injector.java:33)
在sun.reflect.NativeMethodAccessorImpl.invoke0(本机方法)处
在sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:57)中
在sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43)中
位于java.lang.reflect.Method.invoke(Method.java:606)
位于com.intellij.rt.execution.application.AppMain.main(AppMain.java:120)
原因:java.util.concurrent.TimeoutException:等待操作超时
位于com.couchbase.client.internal.HttpFuture.waitForAndCheckOperation(HttpFuture.java:93)
位于com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:82)
位于com.couchbase.client.internal.HttpFuture.get(HttpFuture.java:72)
... 8个以上
2014-07-04 17:27:53.249警告com.couchbase.client.couchbase连接:关闭并重新打开{QA sa=10.250.110.205/10.250.110.205:11210,#Rops=0,#Wops=0,#iq=0,topRop=null,topWop=null,toWrite=0,interest=0},尝试1。
2014-07-04 17:27:53.249 INFO com.couchbase.client.couchbase连接:由于无法连接到{QA sa=10.250.153.230/10.250.153.230:11210,#Rops=0,#Wops=0,#iq=0,topRop=null,topWop=null,toWrite=0,INTERGED=0}
Java.NET.java连接异常:连接席
在sun.nio.ch.socketchannel.checkConnect(本机方法)
位于sun.nio.ch.SocketChannelImpl.finishConnect(SocketChannelImpl.java:735)
在net.spy.memcached.MemcachedConnection.handleIO(MemcachedC
import com.couchbase.client.CouchbaseClient;
import com.couchbase.client.protocol.views.Query;
import com.couchbase.client.protocol.views.View;
import com.couchbase.client.protocol.views.ViewResponse;
import com.couchbase.client.protocol.views.ViewRow;
import com.google.gson.Gson;
import com.t2s.injector.data.User;

import java.io.IOException;
import java.net.URI;
import java.net.URISyntaxException;
import java.util.ArrayList;
import java.util.List;
import java.util.concurrent.ExecutionException;
import java.util.concurrent.TimeUnit;

public class Injector {

    public static void main(String[] args) throws Exception {
        System.out.println("Starting...");
        try {
            CouchbaseClient client = createClient("Users", "54.247.158.182");//, "54.74.200.186");

            try {
                insertData(client);
            } catch (Exception e) {
                e.printStackTrace();
            }

            try {
                queryView(client, "users", "by_firstname");
            } catch (Exception e) {
                e.printStackTrace();
            }

            // Shutting down properly
            client.shutdown(5, TimeUnit.SECONDS);
            System.exit(0);
        } catch (Exception e) {
            e.printStackTrace();
            System.exit(1);
        }
    }

    private static CouchbaseClient createClient(String bucket, String... ips) throws URISyntaxException, IOException {
        // (Subset) of nodes in the cluster to establish a connection
        Integer port = 8091;
        List<URI> nodes = new ArrayList<>();
        for (String ip : ips) {
            nodes.add(new URI("http://" + ip + ":" + port + "/pools"));
        }

        // Password of the bucket (empty) string if none
        String password = "";

        // Connect to the Cluster
        CouchbaseClient client = new CouchbaseClient(nodes, bucket, password);
        System.out.println("Connected to " + client);
        return client;
    }

    private static void insertData(CouchbaseClient client) throws InterruptedException, ExecutionException {
        Gson gson = new Gson();

        User user1 = new User("John", "Doe");
        User user2 = new User("Matt", "Ingenthron");
        User user3 = new User("Michael", "Nitschinger");

        client.set("user101", gson.toJson(user1)).get();
        client.set("user201", gson.toJson(user2)).get();
        client.set("user301", gson.toJson(user3)).get();
    }

    private static void queryView(CouchbaseClient client, String designDoc, String viewName) {
        /*
        function (doc, meta) {
          if(doc.firstname) {
            emit(doc.firstname, doc.lastname);
          }
        }
         */
        // 1: Load the View infos
        View view = client.getView(designDoc, viewName);

        // 2: Create a Query object to customize the Query
        Query query = new Query();
        query.setIncludeDocs(true); // Include the full document body

        // 3: Actually Query the View and return the results
        ViewResponse response = client.query(view, query);

        // 4: Iterate over the Data and print out the full document
        for (ViewRow row : response) {
            System.out.println(row.getId() + ": " + row.getDocument());
        }
    }
}