Issue
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
}
- Error: couldn't connect to server ... The error in the configuration, you do not know why?
- /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?
Solution
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?
Answered By - Adam Comerford