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

问题描述

由于缺少内存,mongod会自动关闭。 (Debian)

 〜#reboot 
〜#mongo
MongoDB shell版本:2.0.6
连接到:test
Thu Aug 2 13:12:26错误:无法连接到服务器127.0.0.1 shell / mongo.js:8 4
异常:连接失败
〜 #mongo 127.0.0.1:27017
MongoDB shell版本:2.0.6
连接到:127.0.0.1:27017/test
>使用数据库
> db.repairDatabase()
{
errmsg:exception:file / var / lib / mongodb / $ tmp_repairDatabase_0 / datab ase.1 open / create在createPrivateMap中失败(查看日志获取更多信息) ,
code:13636,
ok:0
}




  1. 错误:无法连接到服务器...配置中的错误,您不知道为什么?

  2. / var / lib / mongodb / $ tmp_repairDatabase_0和/ var / lib / mongodb / _tmp一个临时文件夹?我可以删除它们吗?

数据库工作正常,但我担心会发生什么,一周前。我不得不完全重新安装mongodb。



UPD:



只是增加了服务器上RAM的大小,并执行了高达3Gb的db.repairDatabase

问题是缺乏内存。 (内存映射文件)
无启动mongod - 136Kb的内存被占用。
启动mongod后 - 1100Kb内存被占用。
在我的数据库对象1165916.
创建对象越大,占用的内存越多。
如何减少mongodb内存的消耗?

解决方案

我认为这和你以前的问题有相同的根本原因 - 缺乏资源。您在上一条消息中指出您只有〜1.4GB的内存,在这种情况下,当您分配更多内存时,修复成功。



这里有一个MongoDB如何使用内存的详细说明:

/ p>



不要忘记,RAM中的工作集包括索引



如果你的工作数据集大部分时间都在1.4GB内,那么你的工作数据集可能不需要额外的RAM,但是,当你超过这些限制时,你将不得不配置一些交换(为了避免OOM杀手和其他问题 - 参见和了解更多信息)。在不增加RAM的情况下,准备使这种使用非常缓慢。在上一期中,您没有配置交换 - 如果您执行消耗所有可用内存(例如修复)的操作,则不会将操作系统置于任何位置。



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


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: couldn't connect to server ... The error in the configuration, you do not know why?
  2. /var/lib/mongodb/$tmp_repairDatabase_0 and /var/lib/mongodb/_tmp a temporary folder? Can I remove them?

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:

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

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?

解决方案

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.

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

http://www.mongodb.org/display/DOCS/Checking+Server+Memory+Usage

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.

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.

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中打开/创建失败的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

10-19 19:34