2016-07-13 57 views
1

我想连接到Couchbase数据库服务器槽couchbase gemRuby:连接到Couchbase

require 'couchbase' 
c = Couchbase.connect('http://<server>:<port>/pools/default/buckets/auth') 

我得到一个错误:

*** Couchbase::Error::BucketNotFound Exception: bootstrap error, The bucket requested does not exist 

下面的代码与(couchbase python package)工作原理:

from couchbase.bucket import Bucket 
c = Bucket('couchbase://<server>/auth') 

我怎样才能从红宝石通过使用连接字符串连接couchbase://<server>/auth

回答

0

需要指定桶,如果它是custom

Couchbase.connect("http://<server>:8091/pools/default", :bucket => 'auth') 
2

这是我在我的机器上看到的。

# ruby --version 
ruby 1.8.7 (2013-06-27 patchlevel 374) [x86_64-linux] 

# gem --version 
1.3.7 

# gem list --local 

*** LOCAL GEMS *** 

connection_pool (2.2.0) 
couchbase (1.3.14) 
multi_json (1.12.1) 
yaji (0.3.5) 

# cat test.ruby 
require 'couchbase' 
c = Couchbase.connect('http://localhost:8091/pools/default/buckets/BUCKETNAME') 
puts c.get('test123') 


# cbc get test123 -U couchbase://localhost/BUCKETNAME 
test123    CAS=0x8f1269ea6014, Flags=0x0. Size=17 
{"hello":"there"} 

# ruby -rubygems test.ruby 
[WARNING] MultiJson is using the default adapter (ok_json). We recommend loading a different JSON library to improve performance. 
hellothere 

这是我的一个Couchbase节点。我已经叫斗BUCKETNAME,它包含键“test123”和文档的内容的文档是

{ 
    "hello": "there" 
} 
+0

但是,当我从蟒蛇连接'桶('couchbase:// /auth')' - 成功,并且当我从ruby连接到同一个服务器'Couchbase.connect('http:// /pools/default/bucket/auth')'我有错误'Couchbase :: Error :: Auth:引导程序错误,身份验证失败。您可能提供了无效的用户名/密码组合。两个库都使用相同的Web管理端口 - 8091 –