nginx mongo 和 gridfs 错误
我试图将 gridfs/nginx/mongo 设置到位,但遇到一些奇怪的错误。
我在最新的 Ubuntu 上尝试使用 nginx 0.8.53 和 0.8.54 以及最新的 mongo 1.6.5 64 位。 使用 gridfs 模块编译效果很好: https://github.com/mdirolf/nginx-gridfs
server {
listen xx.xx.xx.xx;
server_name media.foo.com;
access_log /home/cloudy/log/nginx/media-access.log;
error_log /home/cloudy/log/nginx/media-error.log;
location /gridfs/ {
gridfs db_name;
mongo 127.0.0.1:27017;
}
}
我当我尝试获取文件时得到空响应:
curl -X GET -i 'http://media.foo.com/gridfs/4d4d526cea26b05041000015'
curl: (52) Empty reply from server
My error.log
2011/02/05 15:28:50 [alert] 7112#0: *1 zero size buf in writer t:0 r:0 f:0 0000000000000000 0000000000000000-0000000000000000 0000000000000000 0-0, client: 80.11.52.189, server: media.uk.cloudy.fr, request: "GET /gridfs/4d4d526dea26b05041000016 HTTP/1.1", host: "media.foo.com"
2011/02/05 15:28:52 [alert] 7112#0: *2 zero size buf in writer t:0 r:0 f:0 0000000000000000 0000000000000000-0000000000000000 0000000000000000 0-0, client: 80.11.52.189, server: media.uk.cloudy.fr, request: "GET /gridfs/4d4d526dea26b05041000016 HTTP/1.1", host: "media.foo.com"
欢迎任何建议:)
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(2)
实际上,我破解了 gridFS 模块来访问 mongo 中的其他内容。然后我的同事提交了一个拉取请求,我认为这是最后完成的事情。如果您需要补丁,我也发现其中存在内存泄漏。该模块自 7 月份以来就没有开发过。可能是与新的 nginx 不兼容。我们大量使用它,因此如果我发现它与 .8x/Mongo 1.7.5 不兼容,我会修复它并通知您。同时我会询问 github 上的维护者。
此外,这不是由 10gen 开发的,因此您可能无法获得有关 mongodb-user 的帮助。这不是 Mongo 的错误。自 7 月以来 Mongo 发生了很大变化,因此这也可能是一个问题。 nginx 插件也依赖于 mongo C 驱动程序,该驱动程序可能已过时。我们在 nginx/0.7.67 和 mongo 1.6.5 上成功使用它。
使用 verbose (-vvv) 运行 mongo,跟踪 mongo 日志并点击它。查看您的请求是否实际上是在进行 mongo 查询以及是否存在错误
I actually hacked the gridFS module to access something else in mongo. My coworker submitted a pull request then, and I think that is the last thing that was done. I found a memory leak in it too if you would like the patch. This module has not been developed since July. It could be that it may not be compatible with new nginx. We are using this heavily so if I find it is not compatible with .8x/Mongo 1.7.5 I will fix it and let you know. I would ask the maintainer on github in the meantime.
Also this is not developed by 10gen, so you may not be able to get help on mongodb-user. It is not a bug with Mongo. Mongo has changed a lot since July so that may be a problem too. The nginx plugin relies on the mongo C driver too which may be out of date. We are using it successfully with nginx/0.7.67 and mongo 1.6.5.
Run your mongo with verbose (-vvv) and tail the mongo log and hit it. See if your request is actually making a mongo query and if there are errors with that
好吧,我找到了问题的根源,
我的文件是空的。
使用 mongoengine python GridFsProxy read() 给了我 0 但我仍然可以在 mongoterm、db.fs.files 集合中看到它们,其大小不同于 0 :/
我查看了在测试代码中添加文件的位置,这就是我的内容发现:
第一个日志图像有效,但所有其他日志图像为空,导致前面提到的错误。
将文件实例化位置更改为:
完全解决了问题。
结论是mongoengine中可能某个地方有问题。
我将在 mongo 上尝试详细(-vvv)以查明问题。
Ok I found the root of the problem,
My files were empty.
Using mongoengine python GridFsProxy read() gives me 0 but I could still see them in the mongoterm, db.fs.files collection with a size different than 0 :/
I looked where I was adding files in my test code and here is what I found:
First log images were valid but all the others where empty resulting in the bug mentioned earlier.
Changing the files instantiation position to:
Solved the problem completely.
The conclusion is that there is a problem somewhere probably in mongoengine.
I will try verbose (-vvv) on mongo in order to pinpoint the problem.