我一直在尝试在我的 webfusion 虚拟服务器上安装 CouchDB。我遵循了 webfusion 论坛的最新说明(请参阅:http://forum.webfaction.com/viewtopic.php?id=2355) 并且它运行(只是)Futon 非常缓慢,我收到 502 错误。无论如何,当我运行测试套件时,它在多个测试中失败。Webfaction 支持很棒,但没有 erlang 经验来解释错误日志。有人能帮助我知道可能出了什么问题吗?
测试套件结果:basics、all_docs、attachments、attachments_multipart、attachment_names、compact、config、conflicts、delayed_commits、design_docs、design_options
所有错误是:
引发异常:{“error”:“unknown”,“reason”:“\u000d\u000a502 Bad Gateway\u000d\u000a\u000d\u000a502 Bad Gateway\u000d\u000a nginx\u000d\u000a\u000d\u000a\u000d\u000a”}
除了 'compact; 之外,它还有:
断言失败:xhr.responseText == “这是一个 base64 编码的文本” 断言失败:xhr.getResponseHeader(“Content-Type”) == “text/plain”
我困惑了。
有人知道这些表示什么吗?
艾尔
答案1
我也遇到过这个问题。似乎是 nginx-CouchDB 通信问题。在“基础”测试中,有一个命令用于重新启动 CouchDB。执行此操作后,nginx 日志如下所示:
2010/12/02 03:21:09 [error] 708#0: *132 upstream prematurely closed connection while reading response header from upstream, client: 70.205.249.118, server: localhost, request: "POST /_restart HTTP/1.1", upstream: "http://127.0.0.1:5984/_restart", host: "79.125.20.163", referrer: "http://79.125.20.163/_utils/couch_tests.html?script/couch_tests.js"
2010/12/02 03:21:10 [error] 708#0: *132 connect() failed (111: Connection refused) while connecting to upstream, client: 70.205.249.118, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5984/", host: "79.125.20.163", referrer: "http://79.125.20.163/_utils/couch_tests.html?script/couch_tests.js"
2010/12/02 03:21:10 [error] 708#0: *132 connect() failed (111: Connection refused) while connecting to upstream, client: 70.205.249.118, server: localhost, request: "GET / HTTP/1.1", upstream: "http://127.0.0.1:5984/", host: "79.125.20.163", referrer: "http://79.125.20.163/_utils/couch_tests.html?script/couch_tests.js"
这意味着重置后 CouchDB 会主动拒绝连接,我们只需再发出一两个请求即可。
解决方案是在 nginx 配置中添加类似这样的内容,以便它在向用户显示错误之前发出 5 个请求(注意 max_fails 部分):
upstream couchdb {
server 127.0.0.1:5984 max_fails=5 fail_timeout=30s;
}
server {
...
location / {
proxy_pass http://couchdb;
proxy_redirect off;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
}
}
希望这可以帮助。
更新:经过一些测试,这种方法也没有帮助。nginx 发出的请求太快了。也许有人有足够的知识来详细说明?