dbpath (/data/db/) does not exist - but you don't have to create it

2010 Nov 28 at 02:24 » Tagged as :nosql,

 

 

 

 

Sat Nov 27 20:57:48 exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating

 

Sat Nov 27 20:57:48 dbexit:

Sat Nov 27 20:57:48 shutdown: going to close listening sockets...

Sat Nov 27 20:57:48 shutdown: going to flush oplog...

Sat Nov 27 20:57:48 shutdown: going to close sockets...

Sat Nov 27 20:57:48 shutdown: waiting for fs preallocator...

Sat Nov 27 20:57:48 shutdown: closing all files...

Sat Nov 27 20:57:48 closeAllFiles() finished

Sat Nov 27 20:57:48 dbexit: really exiting now

 

 

 

This, ladies and gentle geeks is what happened when I tried to start up my mongodb after an involuntary power cycle. Looking around there are plenty of posts suggesting that I should create a folder named /data/db in my hard drive. Damned if I will. Mongo db data belongs in /var/lib/mongo and in fact that's where the previously created database was placed by the system.

So why is it looking for a /data/db folder now? probably because I typed in `mongodb` at the command line instead of doing `/etc/rc.d/init.d/mongodb start`. But then, I did try the init script but found that I couldn't connect to it so i tried the manual startup. Since that also failed I looked at the `/var/log/mongodb/mongodb.log` and found this:

 

 

 

**************

 

old lock file: /var/lib/mongodb/mongod.lock. probably means unclean shutdown

recommend removing file and running --repair

see: http://dochub.mongodb.org/core/repair for more information

*************

Sat Nov 27 19:47:17 exception in initAndListen std::exception: old lock file, terminating

Sat Nov 27 19:47:17 dbexit:

Sat Nov 27 19:47:17 shutdown: going to close listening sockets...

Sat Nov 27 19:47:17 shutdown: going to flush oplog...

Sat Nov 27 19:47:17 shutdown: going to close sockets...

Sat Nov 27 19:47:17 shutdown: waiting for fs preallocator...

Sat Nov 27 19:47:17 shutdown: closing all files...

Sat Nov 27 19:47:17 closeAllFiles() finished

Sat Nov 27 19:47:17 dbexit: really exiting now

 

 

 

Pity the poor sobs who wasted their time creating directories and messing up their directory hierarchy. All your need to do is to clean up the stale lock