After running mongo --repair database is empy - mongodb

On my developer machine I've reinstalled ubuntu and just copied files to /data/db from my old install.
After mongo --repair which seemingly went normal (no error messages or such) I see no databases I'm expecting to see.
How can I repair my database?
Here the first part of the log file:
Thu Dec 6 17:55:21 [initandlisten] MongoDB starting : pid=2123 port=27017 dbpath=/data/db/ 64-bit host=sog
Thu Dec 6 17:55:21 [initandlisten] db version v2.2.2, pdfile version 4.5
Thu Dec 6 17:55:21 [initandlisten] git version: d1b43b61a5308c4ad0679d34b262c5af9d664267
Thu Dec 6 17:55:21 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Thu Dec 6 17:55:21 [initandlisten] options: { repair: true }
Thu Dec 6 17:55:21 [initandlisten] Unable to check for journal files due to: boost::filesystem::basic_directory_iterator constructor: No such file or directory: "/data/db/journal"
Thu Dec 6 17:55:21 [initandlisten] ****
Thu Dec 6 17:55:21 [initandlisten] ****
Thu Dec 6 17:55:21 [initandlisten] need to upgrade database fan-fiction with pdfile version 4.5, new version: 4.5
Thu Dec 6 17:55:21 [initandlisten] starting upgrade
Thu Dec 6 17:55:21 [initandlisten] fan-fiction repairDatabase fan-fiction
Thu Dec 6 17:55:21 [FileAllocator] allocating new datafile /data/db/_tmp_repairDatabase_1/fan-fiction.ns, filling with zeroes...
Thu Dec 6 17:55:21 [FileAllocator] creating directory /data/db/_tmp_repairDatabase_1/_tmp
Thu Dec 6 17:55:21 [FileAllocator] done allocating datafile /data/db/_tmp_repairDatabase_1/fan-fiction.ns, size: 16MB, took 0.001 secs
Thu Dec 6 17:55:21 [FileAllocator] allocating new datafile /data/db/_tmp_repairDatabase_1/fan-fiction.0, filling with zeroes...

Ok, I've copied files under root and forgot to chown them. Now everything works like charm.

Related

Assertion: 13524:out of memory AlignedBuilder

I start MongoDB, using commang: sudo service mongodb start.
OS: Ubuntu 11.04
My log is here:
***** SERVER RESTARTED *****
Mon Apr 29 21:55:23.697 [initandlisten] MongoDB starting : pid=3995 port=27017 dbpath=/srv/mongodb/ 64-bit host=myhost
Mon Apr 29 21:55:23.697 [initandlisten]
Mon Apr 29 21:55:23.697 [initandlisten] ** WARNING: You are running in OpenVZ. This is known to be broken!!!
Mon Apr 29 21:55:23.697 [initandlisten]
Mon Apr 29 21:55:23.697 [initandlisten] db version v2.4.3
Mon Apr 29 21:55:23.697 [initandlisten] git version: fe1743177a5ea03e91e0052fb5e2cb2945f6d95f
Mon Apr 29 21:55:23.697 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Mon Apr 29 21:55:23.697 [initandlisten] allocator: tcmalloc
Mon Apr 29 21:55:23.697 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/srv/mongodb/", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" }
Mon Apr 29 21:55:23.701 [initandlisten] journal dir=/srv/mongodb/journal
Mon Apr 29 21:55:23.706 [initandlisten] recover : no journal files present, no recovery needed
Mon Apr 29 21:55:24.465 [initandlisten] preallocateIsFaster=true 14.5
Mon Apr 29 21:55:26.100 [initandlisten] preallocateIsFaster=true 32.4
Mon Apr 29 21:55:27.419 [initandlisten] preallocateIsFaster=true 6.1
Mon Apr 29 21:55:27.419 [initandlisten] preallocateIsFaster check took 3.71 secs
Mon Apr 29 21:55:27.419 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.0
Mon Apr 29 21:55:30.011 [initandlisten] File Preallocator Progress: 377487360/1073741824 35%
Mon Apr 29 21:55:48.672 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.1
Mon Apr 29 21:55:51.008 [initandlisten] File Preallocator Progress: 283115520/1073741824 26%
Mon Apr 29 21:55:54.032 [initandlisten] File Preallocator Progress: 754974720/1073741824 70%
Mon Apr 29 21:56:12.230 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.2
Mon Apr 29 21:56:15.006 [initandlisten] File Preallocator Progress: 765460480/1073741824 71%
Mon Apr 29 21:56:37.587 [FileAllocator] allocating new datafile /srv/mongodb/local.ns, filling with zeroes...
Mon Apr 29 21:56:37.587 [FileAllocator] creating directory /srv/mongodb/_tmp
Mon Apr 29 21:56:39.362 [FileAllocator] done allocating datafile /srv/mongodb/local.ns, size: 16MB, took 1.19 secs
Mon Apr 29 21:56:39.362 [FileAllocator] allocating new datafile /srv/mongodb/local.0, filling with zeroes...
Mon Apr 29 21:56:43.413 [FileAllocator] done allocating datafile /srv/mongodb/local.0, size: 64MB, took 4.051 secs
Mon Apr 29 21:56:43.426 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 reslen:37 5839ms
Mon Apr 29 21:56:43.426 [initandlisten] waiting for connections on port 27017
Mon Apr 29 21:56:43.426 [journal] Assertion: 13524:out of memory AlignedBuilder
Mon Apr 29 21:56:43.426 [websvr] admin web console waiting for connections on port 28017
0xdcf361 0xd90a1b 0xd8e9ec 0xd8ec80 0x924cd1 0x924ec2 0x91a0b1 0x91bcf9 0x91c0bb 0xe17cb9 0x2ab868e0bd8c 0x2ab869ab6fdd
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xdcf361]
/usr/bin/mongod(_ZN5mongo11msgassertedEiPKc+0x9b) [0xd90a1b]
/usr/bin/mongod() [0xd8e9ec]
/usr/bin/mongod(_ZN5mongo14AlignedBuilderC1Ej+0x10) [0xd8ec80]
/usr/bin/mongod(_ZN5mongo3dur7Journal7journalERKNS0_11JSectHeaderERKNS_14AlignedBuilderE+0x221) [0x924cd1]
/usr/bin/mongod(_ZN5mongo3dur14WRITETOJOURNALENS0_11JSectHeaderERNS_14AlignedBuilderE+0x32) [0x924ec2]
/usr/bin/mongod(_ZN5mongo3dur27groupCommitWithLimitedLocksEv+0x141) [0x91a0b1]
/usr/bin/mongod() [0x91bcf9]
/usr/bin/mongod(_ZN5mongo3dur9durThreadEv+0x2eb) [0x91c0bb]
/usr/bin/mongod() [0xe17cb9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c) [0x2ab868e0bd8c]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x2ab869ab6fdd]
Mon Apr 29 21:56:43.880 [journal] dbexception in groupCommitLL causing immediate shutdown: 13524 out of memory AlignedBuilder
Mon Apr 29 21:56:43.880 dur1
Mon Apr 29 21:56:43.880 Got signal: 6 (Aborted).
Mon Apr 29 21:56:43.882 Backtrace:
0xdcf361 0x6cf729 0x2ab869a01d80 0x2ab869a01d05 0x2ab869a05ab6 0x9e8de7 0x91a4df 0x91bcf9 0x91c0bb 0xe17cb9 0x2ab868e0bd8c 0x2ab869ab6fdd
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xdcf361]
/usr/bin/mongod(_ZN5mongo10abruptQuitEi+0x399) [0x6cf729]
/lib/x86_64-linux-gnu/libc.so.6(+0x33d80) [0x2ab869a01d80]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x2ab869a01d05]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x186) [0x2ab869a05ab6]
/usr/bin/mongod(_ZN5mongo10mongoAbortEPKc+0x47) [0x9e8de7]
/usr/bin/mongod(_ZN5mongo3dur27groupCommitWithLimitedLocksEv+0x56f) [0x91a4df]
/usr/bin/mongod() [0x91bcf9]
/usr/bin/mongod(_ZN5mongo3dur9durThreadEv+0x2eb) [0x91c0bb]
/usr/bin/mongod() [0xe17cb9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c) [0x2ab868e0bd8c]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x2ab869ab6fdd]
How resolve this problem? I tryed reinstall MongoDB, but my problem is stayed.
PS: Why dbpath directory is so big??
root#myhost:~# du -hs /srv/mongodb/
3.1G /srv/mongodb/
You are using OpenVZ as your VM hypervisor. The way OpenVZ manages memory means that MongoDB's memory mapped file structure will NOT work.
You should try getting a VM that uses KVM as it's hypervisor, if possible.
I had this problem when filesystem went to 100% (due verbose logs that where not in /var).
it ended up in bad journal files.
impossible to repair the database (even with --repair)
The only way to recover seems to restart from a backup, and re-importing the proper tables.
to be able to re-start the DB in that situation (for mongodump or because it is prod) is as follow.
You have to start Mongo without journaling (very dangerous, you should leave this mode asap)
set nojournal = true in mongod.conf
then:
rm /mnt/pathto/mongodb/journal/*
rm /mnt/pathto/mongodb/mongod.lock
chown -R mongodb:mongodb /mnt/pathto/mongodb (in case you tried as root "mongod -f /etc/mongodb.conf --repair" as I did)
service mongodb start
DB is up & running, you can do your dumps a restart it WITH journaling (after restoring a backup then the mongodumps)

MongoDB Catch-22 won't let me drop huge collection

So I have a 2TB hard drive with 2 collections in 1 mongoDB.
Collection 1 is about 500gb and completely essential
Collection 2 is about 1500gb and needs to be deleted.
I was running a process that accidentally filled up the entire HDD, leaving 0% space. There is literally nothing on the machine apart from a Linux Distro and this mongoDB.
I would like to delete Collection 2.
In order to do this, I would normally just go into mongo and type db.collection.drop()
However, mongoDB is not currently running. In order to start it, I'm using:
[bobby#myPC bin]# ./mongod --dbpath /home/mongo &
However, since there is no space on the HDD, it returns:
[bobby#myPC bin]# Thu Feb 14 17:47:10 [initandlisten] MongoDB starting : pid=1264 port=27017 dbpath=/home/mongo 64-bit host=localhost.localdomain
Thu Feb 14 17:47:10 [initandlisten] db version v2.2.3, pdfile version 4.5
Thu Feb 14 17:47:10 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2f4a96bf08
Thu Feb 14 17:47:10 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Thu Feb 14 17:47:10 [initandlisten] options: { dbpath: "/home/mongo" }
Thu Feb 14 17:47:10 [initandlisten] journal dir=/home/mongo/journal
Thu Feb 14 17:47:10 [initandlisten] recover : no journal files present, no recovery needed
Thu Feb 14 17:47:10 [initandlisten]
Thu Feb 14 17:47:10 [initandlisten] ERROR: Insufficient free space for journal files
Thu Feb 14 17:47:10 [initandlisten] Please make at least 3379MB available in /home/mongo/journal or use --smallfiles
Thu Feb 14 17:47:10 [initandlisten]
Thu Feb 14 17:47:10 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
Thu Feb 14 17:47:10 dbexit:
Thu Feb 14 17:47:10 [initandlisten] shutdown: going to close listening sockets...
Thu Feb 14 17:47:10 [initandlisten] shutdown: going to flush diaglog...
Thu Feb 14 17:47:10 [initandlisten] shutdown: going to close sockets...
Thu Feb 14 17:47:10 [initandlisten] shutdown: waiting for fs preallocator...
Thu Feb 14 17:47:10 [initandlisten] shutdown: lock for final commit...
Thu Feb 14 17:47:10 [initandlisten] shutdown: final commit...
Thu Feb 14 17:47:10 [initandlisten] shutdown: closing all files...
Thu Feb 14 17:47:10 [initandlisten] closeAllFiles() finished
Thu Feb 14 17:47:10 [initandlisten] journalCleanup...
Thu Feb 14 17:47:10 [initandlisten] removeJournalFiles
Thu Feb 14 17:47:10 [initandlisten] shutdown: removing fs lock...
Thu Feb 14 17:47:10 dbexit: really exiting now
I can't remove this collection cause there's no space. And there's no space because I can't remove this collection.
How can I fix this? Is there some way of identifying which mongoDB files in /home/mongo I can take out?
Based on the error message, its complaining about not having enough space for the journal. Its not ideal in a production environment to run with out journaling, but you could try starting with out it while you fix the issue.
./mongod --nojournal --dbpath /home/mongo &
edit: to answer your question though, mongo creates and allocates files per database, not collection. So you wouldn't be able to target a specific file to remove a collection.

mongodb crashes after unexpected shutdown

after our vps got down and we boot it, mongod service didnt start automatically and we cannot start it by service mongod start,
file /var/log/mongo/mongod.log contains following log:
***** SERVER RESTARTED *****
Thu Oct 11 13:51:18
Thu Oct 11 13:51:18 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Oct 11 13:51:18
Thu Oct 11 13:51:18 [initandlisten] MongoDB starting : pid=3821 port=27017 dbpath=/var/lib/mongo 32-bit host=server2.paransa.org
Thu Oct 11 13:51:18 [initandlisten]
Thu Oct 11 13:51:18 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 11 13:51:18 [initandlisten] ** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 11 13:51:18 [initandlisten] ** with --journal, the limit is lower
Thu Oct 11 13:51:18 [initandlisten]
Thu Oct 11 13:51:18 [initandlisten] ** WARNING: You are running in OpenVZ. This is known to be broken!!!
Thu Oct 11 13:51:18 [initandlisten]
Thu Oct 11 13:51:18 [initandlisten] db version v2.2.0, pdfile version 4.5
Thu Oct 11 13:51:18 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
Thu Oct 11 13:51:18 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
Thu Oct 11 13:51:18 [initandlisten] options: { config: "/etc/mongod.conf", dbpath: "/var/lib/mongo", fork: "true", logappend: "true", logpath: "/var/log/mongo/mongod.log", pidfilepath: "/var/run/mongodb/mongod.pid" }
Thu Oct 11 13:51:18 [initandlisten] couldn't open /var/lib/mongo/mydb_main.ns errno:13 Permission denied
Thu Oct 11 13:51:18 [initandlisten] error couldn't open file /var/lib/mongo/mydb_main.ns terminating
Thu Oct 11 13:51:18 dbexit:
Thu Oct 11 13:51:18 [initandlisten] shutdown: going to close listening sockets...
Thu Oct 11 13:51:18 [initandlisten] shutdown: going to flush diaglog...
Thu Oct 11 13:51:18 [initandlisten] shutdown: going to close sockets...
Thu Oct 11 13:51:18 [initandlisten] shutdown: waiting for fs preallocator...
Thu Oct 11 13:51:18 [initandlisten] shutdown: closing all files...
Thu Oct 11 13:51:18 [initandlisten] closeAllFiles() finished
Thu Oct 11 13:51:18 [initandlisten] shutdown: removing fs lock...
Thu Oct 11 13:51:18 dbexit: really exiting now
as you may see, log says mongo server cant open *.ns file cause lake of permission
but if i run the server manually by following command:
mongod --dbpath=/var/lib/mongo -f /etc/mongod.conf
it seems everything is fine and about the log file:
***** SERVER RESTARTED *****
Thu Oct 11 14:02:06
Thu Oct 11 14:02:06 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Thu Oct 11 14:02:06
Thu Oct 11 14:02:06 [initandlisten] MongoDB starting : pid=4090 port=27017 dbpath=/var/lib/mongo 32-bit host=server2.paransa.org
Thu Oct 11 14:02:06 [initandlisten]
Thu Oct 11 14:02:06 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Thu Oct 11 14:02:06 [initandlisten] ** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Thu Oct 11 14:02:06 [initandlisten] ** with --journal, the limit is lower
Thu Oct 11 14:02:06 [initandlisten]
Thu Oct 11 14:02:06 [initandlisten] ** WARNING: You are running in OpenVZ. This is known to be broken!!!
Thu Oct 11 14:02:06 [initandlisten]
Thu Oct 11 14:02:06 [initandlisten] db version v2.2.0, pdfile version 4.5
Thu Oct 11 14:02:06 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
Thu Oct 11 14:02:06 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
Thu Oct 11 14:02:06 [initandlisten] options: { config: "/etc/mongod.conf", dbpath: "/var/lib/mongo", fork: "true", logappend: "true", logpath: "/var/log/mongo/mongod.log", pidfilepath: "/var/run/mongodb/mongod.pid" }
Thu Oct 11 14:02:07 [websvr] admin web console waiting for connections on port 28017
Thu Oct 11 14:02:07 [initandlisten] waiting for connections on port 27017
and using --repair arg didnt help
(maybe because it could start manually with mongod --dbpath=/var/lib/mongo -f /etc/mongod.conf and adding --repair arg to the command, logs everything is fine!...)
any suggestion?
This is a permissions issue, you are running as mongod (or mongodb etc.) user when you start via service, and you are likely running as root (you confirm this in the comments above) when you are using sudo or invoking as root. You need to fix the permissions for all the files in that folder and not start the service as root, ever.
To fix the files based on what you have posted, assuming your relevant user is mongodb and the group is mongodb, you would do the following with sudo (or as root) - substitute for the appropriate user for your system:
chown -R mongodb:mongodb /var/lib/mongo
chown -R mongodb:mongodb /var/run/mongodb
chown mongodb:mongodb /var/log/mongo/mongod.log
Once you fix the permissions on these folders you should be able to start via service again. Note: if you post the output of ls -al /var/lib/mongo then I can give you the exact commands you need to run
sudo rm /data/db/mongod.lock
sudo mongod --dbpath /data/db --repair
sudo mongod --dbpath /data/db
Try deleting the *.lock file in "\data\db" folder before starting mongod.exe in CMD.
Stop the MongoDB service
sudo service mongodb stop
Remove the MongoDB lock file
sudo rm /var/lib/mongodb/mongod.lock
Change ownership from root to the MongoDB path
sudo chown -R mongodb:mongodb /var/lib/mongodb/
Access the mongodb Shell
sudo mongod --dbpath=/var/lib/mongodb
Start the MongoDB service
sudo service mongodb start
Test the mongo application
mongo
You can run automatically your mongodb forever from the rc.local, using this command:
su pi -c 'sudo mongod --repairpath your_path'
and don't worry about the unexpected shutdown.

How to resolve error :dbpath (/data/db/) does not exist permanently in MongoDB

I have installed mongodb in my Ubuntu 10.04.
I know that when it comes to start the mongodb server with the command "mongod",then it expects /data/db folder and it can be easily resolved by creating "/data/db/". One more way is to provide your own path using mongod --dbpath "path",when we intend to give our own custom path for db.
But while going through http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ link i found that there is a configuration file.
I made the following changes to it.
# mongodb.conf
dbpath=/EBS/Work/mongodb/data/db/
logpath=/EBS/Work/mongodb/mongodb.log
logappend=true
But still when I try to start the server with "mongod" it throws the same error
i.e error :dbpath (/data/db/) does not exist .
I wanted to know that how can I permanently redirect my dbpath to my own custom folder cause everytime you don't want to type the path using "mongod --dbpath path".Rather we look to make some changes in configuration file.
Assuming you have followed the instructions to install a packaged version of MongoDB, you should be starting and stopping mongod using service.
To start mongod:
sudo service mongodb start
To stop mongod:
sudo service mongodb stop
If you use the service command to start and stop, it should be using the configuration file: /etc/mongodb.conf.
Starting mongod from the command line
If you run mongod directly instead of using the service definition, you will also have to specify a configuration file as a command line parameter if you want one to be used:
mongod --config /etc/mongodb.conf
Here is how I got this resolved, simply by following their official Doc . HERE.
Step by step from teminal (running ubuntu) :
cd into /srv folder =>> cd /srv/
make directory =>> mkdir -p mongodb
From within /srv/ give the newly created mongodb folder the right permissions and group ......
Lastly, run this => mongod --dbpath /srv/mongodb/
"step by step" Copy of the terminal ...... :)
~$ mongod
Tue Jun 3 20:27:39.564 [initandlisten] MongoDB starting : pid=5380 port=27017 dbpath=/srv/mongodb/ 64-bit host= -SVE1411EGXB
Tue Jun 3 20:27:39.564 [initandlisten] db version v2.4.10
Tue Jun 3 20:27:39.564 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268a
Tue Jun 3 20:27:39.564 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Tue Jun 3 20:27:39.564 [initandlisten] allocator: tcmalloc
Tue Jun 3 20:27:39.564 [initandlisten] options: { dbpath: "/srv/mongodb/" }
Tue Jun 3 20:27:39.565 [initandlisten] exception in initAndListen: 10296
*********************************************************************
ERROR: dbpath (/srv/mongodb/) does not exist.
Create this directory or give existing directory in --dbpath.
See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Tue Jun 3 20:27:39.565 dbexit:
Tue Jun 3 20:27:39.565 [initandlisten] shutdown: going to close listening sockets...
Tue Jun 3 20:27:39.565 [initandlisten] shutdown: going to flush diaglog...
Tue Jun 3 20:27:39.565 [initandlisten] shutdown: going to close sockets...
Tue Jun 3 20:27:39.565 [initandlisten] shutdown: waiting for fs preallocator...
Tue Jun 3 20:27:39.565 [initandlisten] shutdown: lock for final commit...
Tue Jun 3 20:27:39.565 [initandlisten] shutdown: final commit...
Tue Jun 3 20:27:39.565 [initandlisten] shutdown: closing all files...
Tue Jun 3 20:27:39.565 [initandlisten] closeAllFiles() finished
Tue Jun 3 20:27:39.565 dbexit: really exiting now
~$ mongod --dbpath /srv/mongodb/
Tue Jun 3 20:27:55.616 [initandlisten] MongoDB starting : pid=5445 port=27017 dbpath=/srv/mongodb/ 64-bit host= -SVE1411EGXB
Tue Jun 3 20:27:55.616 [initandlisten] db version v2.4.10
Tue Jun 3 20:27:55.616 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268a
Tue Jun 3 20:27:55.616 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Tue Jun 3 20:27:55.616 [initandlisten] allocator: tcmalloc
Tue Jun 3 20:27:55.616 [initandlisten] options: { dbpath: "/srv/mongodb/" }
Tue Jun 3 20:27:55.617 [initandlisten] exception in initAndListen: 10296
~$ sudo service mongodb start
start: Job is already running: mongodb
~$ sudo service mongodb stop
mongodb stop/waiting
~$ cd /srv/
~$~$/srv$ ls
~$ /srv$ mkdir mongodb
~$ sudo chgrp /srv
~$ sudo chmod 775 /srv
~$ cd /srv/
/srv$ ls
/srv$ mkdir mongodb
/srv$ ls mongodb
/srv$ cd
~$ mongod --dbpath /srv/mongodb/
Tue Jun 3 20:40:57.457 [initandlisten] MongoDB starting : pid=6018 port=27017 dbpath=/srv/mongodb/ 64-bit host= -SVE1411EGXB
Tue Jun 3 20:40:57.457 [initandlisten] db version v2.4.10
Tue Jun 3 20:40:57.457 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268a
Tue Jun 3 20:40:57.457 [initandlisten] build info: Linux ip-10-2-29-40 2.6.21.7-2.ec2.v1.2.fc8xen #1 SMP Fri Nov 20 17:48:28 EST 2009 x86_64 BOOST_LIB_VERSION=1_49
Tue Jun 3 20:40:57.457 [initandlisten] allocator: tcmalloc
Tue Jun 3 20:40:57.457 [initandlisten] options: { dbpath: "/srv/mongodb/" }
Tue Jun 3 20:40:57.520 [initandlisten] journal dir=/srv/mongodb/journal
Tue Jun 3 20:40:57.521 [initandlisten] recover : no journal files present, no recovery needed
Tue Jun 3 20:41:00.545 [initandlisten] preallocateIsFaster=true 36.86
Tue Jun 3 20:41:03.489 [initandlisten] preallocateIsFaster=true 35.06
Tue Jun 3 20:41:07.456 [initandlisten] preallocateIsFaster=true 34.44
Tue Jun 3 20:41:07.456 [initandlisten] preallocateIsFaster check took 9.935 secs
Tue Jun 3 20:41:07.456 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.0
Tue Jun 3 20:41:10.009 [initandlisten] File Preallocator Progress: 985661440/1073741824 91%
Tue Jun 3 20:41:22.273 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.1
Tue Jun 3 20:41:25.009 [initandlisten] File Preallocator Progress: 933232640/1073741824 86%
Tue Jun 3 20:41:37.119 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.2
Tue Jun 3 20:41:40.093 [initandlisten] File Preallocator Progress: 1006632960/1073741824 93%
Tue Jun 3 20:41:52.450 [FileAllocator] allocating new datafile /srv/mongodb/local.ns, filling with zeroes...
Tue Jun 3 20:41:52.450 [FileAllocator] creating directory /srv/mongodb/_tmp
Tue Jun 3 20:41:52.503 [FileAllocator] done allocating datafile /srv/mongodb/local.ns, size: 16MB, took 0.022 secs
Tue Jun 3 20:41:52.517 [FileAllocator] allocating new datafile /srv/mongodb/local.0, filling with zeroes...
Tue Jun 3 20:41:52.537 [FileAllocator] done allocating datafile /srv/mongodb/local.0, size: 64MB, took 0.02 secs
Tue Jun 3 20:41:52.538 [websvr] admin web console waiting for connections on port 28017
Tue Jun 3 20:41:52.538 [initandlisten] waiting for connections on port 27017
Change the user of the new data directory:
chown mongodb [rute_directory]
And try another time to start the mongo service
service mongodb start
I solve the same problem with this.
Find mongo log file from root system folder
sudo find / -name "mongodb.log" -type f
result:
/var/log/mongodb/mongodb.log
open /var/log/mongodb/mongodb.log
search for last "exception" word
try to correct exception
In my case exception was the next:
2015-07-30T15:09:15.806+0300 [initandlisten] exception in initAndListen: 13597 can't start without --journal enabled when journal/ files are present, terminating
I made the next:
cd /var/lib/mongodb
rm -r journal/
If you are using mac catalina:
mongod --dbpath=/Users/user/data/db
leave this window
then you can type in another window.
mongo
show dbs

MongoDB Unclean Shutdown - Fail to repair

I was running MongoDB on Amazon AWS, until one day it ran out of space. Then, the database is completely inaccessible,and I tried to shutdown the database. Having restarted the server and installed larger disk, the MongoDB can't be started.
I tried to repair the database, and the error is shown like below:
Wed Aug 15 10:08:04 [initandlisten] MongoDB starting : pid=1447 port=27017 dbpath=/var/lib/mongodb/ 32-bit
** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
** see http://blog.mongodb.org/post/137788967/32-bit-limitations
** with --dur, the limit is lower
Wed Aug 15 10:08:04 [initandlisten] db version v1.8.3, pdfile version 4.5
Wed Aug 15 10:08:04 [initandlisten] git version: c206d77e94bc3b65c76681df5a6b605f68a2de05
Wed Aug 15 10:08:04 [initandlisten] build sys info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Wed Aug 15 10:08:04 [initandlisten] **
Wed Aug 15 10:08:04 [initandlisten] **
Wed Aug 15 10:08:04 [initandlisten] need to upgrade database md with pdfile version 559903.1345021735, new version: 4.5
Wed Aug 15 10:08:04 [initandlisten] starting upgrade
Wed Aug 15 10:08:04 [initandlisten] md repairDatabase md
Wed Aug 15 10:08:04 [initandlisten] md.system.namespaces Assertion failure isOk() db/pdfile.h 259
0x817c27b 0x819121e 0x83cf525 0x83d6bec 0x83f5420 0x82a4fb7 0x83f8680 0x83fcece 0x8401358 0x8401e29 0x8402abd 0x828f755 0x83b3d67 0x83b931c 0x83bb3df 0x81ce25f 0x81ae714 0x8380f31 0x83831ba 0x83d4faf
mongod(_ZN5mongo12sayDbContextEPKc+0xcb) [0x817c27b]
mongod(_ZN5mongo8assertedEPKcS1_j+0x12e) [0x819121e]
mongod(_ZN5mongo11DataFileMgr7findAllEPKcRKNS_7DiskLocE+0x7a5) [0x83cf525]
mongod(_ZN5mongo13findTableScanEPKcRKNS_7BSONObjERKNS_7DiskLocE+0x13c) [0x83d6bec]
mongod(_ZNK5mongo9QueryPlan9newCursorERKNS_7DiskLocEi+0x830) [0x83f5420]
mongod(_ZN5mongo11UserQueryOp5_initEv+0x437) [0x82a4fb7]
mongod(_ZN5mongo12QueryPlanSet6Runner6initOpERNS_7QueryOpE+0x110) [0x83f8680]
mongod(_ZN5mongo12QueryPlanSet6Runner3runEv+0x2ee) [0x83fcece]
mongod(_ZN5mongo12QueryPlanSet5runOpERNS_7QueryOpE+0x2e8) [0x8401358]
mongod(_ZN5mongo16MultiPlanScanner9runOpOnceERNS_7QueryOpE+0x59) [0x8401e29]
mongod(_ZN5mongo16MultiPlanScanner5runOpERNS_7QueryOpE+0x2d) [0x8402abd]
mongod(_ZN5mongo8runQueryERNS_7MessageERNS_12QueryMessageERNS_5CurOpES1_+0x1575) [0x828f755]
mongod() [0x83b3d67]
mongod(_ZN5mongo16assembleResponseERNS_7MessageERNS_10DbResponseERKNS_8SockAddrE+0x70c) [0x83b931c]
mongod(_ZN5mongo14DBDirectClient4callERNS_7MessageES2_bPSs+0x7f) [0x83bb3df]
mongod(_ZN5mongo14DBClientCursor4initEv+0x15f) [0x81ce25f]
mongod(_ZN5mongo12DBClientBase5queryERKSsNS_5QueryEiiPKNS_7BSONObjEii+0x2a4) [0x81ae714]
mongod(_ZN5mongo6Cloner2goEPKcRSsRKSsbbbb+0x451) [0x8380f31]
mongod(_ZN5mongo9cloneFromEPKcRSsRKSsbbbb+0x5a) [0x83831ba]
mongod(_ZN5mongo14repairDatabaseESsRSsbb+0x38f) [0x83d4faf]
Wed Aug 15 10:08:04 [initandlisten] assertion 0 assertion db/pdfile.h:259 ns:md.system.namespaces query:{}
Wed Aug 15 10:08:04 [initandlisten] Assertion: 10290:bad system.namespaces object { $err: "assertion db/pdfile.h:259" }
0x819045e 0x8381181 0x83831ba 0x83d4faf 0x852a30c 0x852b217 0x852e733 0x852f59c 0x85366bb 0xb74a4ce7 0x810b551
mongod(_ZN5mongo11msgassertedEiPKc+0x15e) [0x819045e]
mongod(_ZN5mongo6Cloner2goEPKcRSsRKSsbbbb+0x6a1) [0x8381181]
mongod(_ZN5mongo9cloneFromEPKcRSsRKSsbbbb+0x5a) [0x83831ba]
mongod(_ZN5mongo14repairDatabaseESsRSsbb+0x38f) [0x83d4faf]
mongod(_ZN5mongo11doDBUpgradeERKSsSsPNS_14DataFileHeaderE+0x6c) [0x852a30c]
mongod() [0x852b217]
mongod(_ZN5mongo14_initAndListenEiPKc+0x4b3) [0x852e733]
mongod(ZN5mongo13initAndListenEiPKc+0x2c) [0x852f59c]
mongod(main+0x6bdb) [0x85366bb]
/lib/libc.so.6(_libc_start_main+0xe7) [0xb74a4ce7]
mongod() [0x810b551]
Wed Aug 15 10:08:04 [initandlisten] exception in initAndListen std::exception: bad system.namespaces object { $err: "assertion db/pdfile.h:259" }, terminating
Wed Aug 15 10:08:04 dbexit:
Wed Aug 15 10:08:04 [initandlisten] shutdown: going to close listening sockets...
Wed Aug 15 10:08:04 [initandlisten] shutdown: going to flush diaglog...
Wed Aug 15 10:08:04 [initandlisten] shutdown: going to close sockets...
Wed Aug 15 10:08:04 [initandlisten] shutdown: waiting for fs preallocator...
Wed Aug 15 10:08:04 [initandlisten] shutdown: closing all files...
Wed Aug 15 10:08:04 closeAllFiles() finished
Wed Aug 15 10:08:04 [initandlisten] shutdown: removing fs lock...
Wed Aug 15 10:08:04 dbexit: really exiting now
I have all *.number and *.ns file completely. But it seems the ns file is corrupted. Any way I could repair the database?
Thanks
If repair doesn't work then you are unfortunately out of luck.
I'm presuming that you didn't have journaling enabled or any back-ups. I would strongly encourage you to run with journaling enabled and follow one of the back-up strategies outlined here. The LVM snapshot is easy to implement, fairly quick and reliable.
You are better to run MongoDB on a 64-bit system also. 32-bit limits you to 2gb of data. You say that you "ran out of space"?