MongoDB 错误:无法连接到服务器...在 createPrivateMap 中打开/创建失败 [英] MongoDB errors: couldn't connect to server ... open/create failed in createPrivateMap

查看:18
本文介绍了MongoDB 错误:无法连接到服务器...在 createPrivateMap 中打开/创建失败的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

由于内存不足,mongod 自动关闭.(Debian)

Due to lack of memory mongod shut down automatically. (Debian)

~# reboot
~# mongo
MongoDB shell version: 2.0.6
connecting to: test
Thu Aug  2 13:12:26 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:8 4
exception: connect failed
~# mongo 127.0.0.1:27017
MongoDB shell version: 2.0.6
connecting to: 127.0.0.1:27017/test
> use database
> db.repairDatabase()
{
        "errmsg" : "exception: file /var/lib/mongodb/$tmp_repairDatabase_0/datab      ase.1 open/create failed in createPrivateMap (look in log for more information)"                            ,
        "code" : 13636,
        "ok" : 0
}

  1. Error: could not connect to server ... 配置中的错误,不知道为什么?
  2. /var/lib/mongodb/$tmp_repairDatabase_0 和/var/lib/mongodb/_tmp 是临时文件夹吗?我可以删除它们吗?

数据库运行良好,但我担心一周前会发生与我的基地相同的事情.我不得不完全重新安装 mongodb.链接

The database is working fine, but I'm afraid of what will happen the same thing as my base a week ago. I had to completely reinstall mongodb. link

UPD:

只是增加了服务器上的 RAM 大小并执行了高达 3Gb 的 db.repairDatabase() - 一切顺利.

Just increased the size of RAM on the server and performed up to 3Gb db.repairDatabase () - all went well.

问题是内存不足.(内存映射文件)没有启动 mongod - 占用了 136Kb 的内存.启动 mongod 后 - 1100Kb 内存被占用.在我的数据库对象 1165916 中.创建的对象越大,占用的内存就越多.如何减少mongodb内存的消耗?还是唯一的出路——更多内存?

The problem was a lack of memory. (Memory-Mapped Files) No start mongod - 136Kb of memory occupied. After starting mongod - 1100Kb memory is occupied. In my database objects 1165916. The larger the object is created, the more memory is occupied. How can I reduce the consumption of mongodb memory? Or the only way out - more memory?

推荐答案

我认为这个问题和你之前的问题有相同的根本原因——缺乏资源.您在之前的消息中指出您只有约 1.4GB 的内存,在这种情况下,当您分配更多内存时修复成功.修复必须遍历并重写整个数据集,因此会很密集.

I think this, and your previous issue, have the same root cause - lack of resources. You indicate in your previous message that you only had ~1.4GB of memory and in this case the repair succeeded when you had more memory allocated. A repair has to walk through and rewrite the entire set of data, so it is going to be intensive.

这里有详细描述MongoDB如何使用内存:

There is a detailed description of how MongoDB uses memory here:

http://www.mongodb.org/display/DOCS/检查+服务器+内存+使用情况

不要忘记,您在 RAM 中的工作集包括索引和数据,所以这不仅仅是对象数量的问题.

Don't forget, your working set in RAM includes indexes as well as the data, so it's not just a matter of the number of objects.

如果您的工作数据集大部分时间应该适合 1.4GB,那么您可能不需要额外的 RAM,但是,当它超过这些限制时,您将不得不配置一些交换(以避免OOM Killer 和其他问题 - 请参阅 这里这里了解更多信息).在不增加 RAM 的情况下,准备好这样的使用也很慢.在上一期中,您没有配置交换 - 如果您执行一些消耗所有可用内存的操作(例如修复),这不会让操作系统去任何地方.

If your working data set should fit inside the 1.4GB most of the time, then you likely don't need the extra RAM, but, you are going to have to configure some swap for when it exceeds those limits (to avoid the OOM Killer and other issues - see here and here for more information). Without increasing the RAM, be prepared to have such usage be very slow also. In the previous issue you had no swap configured - that does not give the OS anywhere to go if you do something that consumes all the available memory, like a repair.

关于初始连接失败,如果没有指定参数,我相信它可能会尝试在默认情况下连接 localhost:27017(而不是 IP) - 你的 /etc/hosts 文件返回 IPV6 地址或类似的东西.如果您尝试手动连接到 localhost 会失败吗?

Regarding the initial connection failure, I believe it may try to connect on localhost:27017 by default (rather than the IP) if no arguments are specified - is there any chance that your /etc/hosts file is returning the IPV6 address or something similar. Do you fail if you try connecting to localhost manually?

这篇关于MongoDB 错误:无法连接到服务器...在 createPrivateMap 中打开/创建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆