2015-05-20 126 views
0

建立连接 -如何在Mac OS上建立couchbase服务器和couchbase同步网关之间的连接? couchbase服务器和couchbase在Mac OS中同步网关之间

$ ../sync_gateway 
==== Couchbase Sync Gateway/1.0.4(34;04138fd) ==== 

Configured Go to use all 2 CPUs; `setenv GOMAXPROCS` to override this 
Opening db /sync_gateway as bucket "sync_gateway", pool "default", server <walrus:> 
Opening Walrus database sync_gateway on <walrus:> 
Using default sync function `'channel(doc.channels)'` for database "sync_gateway" 
Starting profile server on 
***Starting admin server on 127.0.0.1:4985 
Starting server on :4984 ...*** 

我创建了一个config.json文件,并试图将它连接到服务器,但它不是发生在默认情况下它要127.0.0.1: 4985

任何人都可以帮我吗?

回答

1

以下配置值添加到您的config.json文件:

“adminInterface”: “[YOUR_PREFERRED_IP_FOR_ADMIN_INTERFACE]:4985”,

的adminInterface场,让我们的sync_gateway知道哪个IP :PORT来运行管理界面。

此外,您需要告诉sync_gateway在哪里激发桶的其余API(以下示例中的todos)。如下例所示,您可以在数据库的配置中添加“server”:“http://[COUCHBASE_SERVER_IP]:8091”,

所以,

  1. 你会开枪[YOUR_PREFERRED_IP_FOR_ADMIN_INTERFACE]管理的REST API:4985。
  2. 而且,sync_gateway将针对[COUCHBASE_SERVER_IP]:8091上的“todos”存储桶的CRUD操作启动rest apis。

下面是示例的配置文件:

{ 
    "interface":"192.168.1.117:4984", 
    "adminInterface":"127.0.0.1:4985", 
    "log": ["CRUD", "REST+", "Access"], 
    "facebook": { "register": true }, 
    "databases": { 
    "todos": { 
     "server": "http://[COUCHBASE_SERVER_IP]:8091", 
     "users": { 
     "GUEST": {"disabled": true} 
     }, 
     "sync": 
    ` 
     function(doc, oldDoc) { 
     // NOTE this function is the same across the iOS, Android, and PhoneGap versions. 
     if (doc.type == "task") { 
      if (!doc.list_id) { 
      throw({forbidden : "Items must have a list_id"}) 
      } 
      channel("list-"+doc.list_id); 
     } else if (doc.type == "list") { 
      channel("list-"+doc._id); 
      if (!doc.owner) { 
      throw({forbidden : "List must have an owner"}) 
      } 
      if (oldDoc) { 
      var oldOwnerName = oldDoc.owner.substring(oldDoc.owner.indexOf(":")+1); 
      requireUser(oldOwnerName) 
      } 
      var ownerName = doc.owner.substring(doc.owner.indexOf(":")+1); 
      access(ownerName, "list-"+doc._id); 
      if (Array.isArray(doc.members)) { 
      var memberNames = []; 
      for (var i = doc.members.length - 1; i >= 0; i--) { 
       memberNames.push(doc.members[i].substring(doc.members[i].indexOf(":")+1)) 
      }; 
      access(memberNames, "list-"+doc._id); 
      } 
     } else if (doc.type == "profile") { 
      channel("profiles"); 
      var user = doc._id.substring(doc._id.indexOf(":")+1); 

      if (user !== doc.user_id) { 
      throw({forbidden : "Profile user_id must match docid : " + user + " : " + doc.user_id}) 
      } 
      requireUser(user); 
      access(user, "profiles"); // TODO this should use roles 
     } 
     } 
    ` 
    } 
    } 
}