Friday, February 4, 2011

MongoDB Error

If you happen to pass by this error

[02:33:05] mongodb$ mongo
MongoDB shell version: 1.6.3
connecting to: test
Sat Nov 13 02:33:10 Error: couldn't connect to server 127.0.0.1 (anon):1137
exception: connect failed


Check if your mongo is running by issuing "mongod" command. If you get something like this,

Sat Nov 13 02:30:41 MongoDB starting : pid=294 port=27017 dbpath=/data/db/ 64-bit
Sat Nov 13 02:30:41 db version v1.6.3, pdfile version 4.5
Sat Nov 13 02:30:41 git version: 278bd2ac2f2efbee556f32c13c1b6803224d1c01
Sat Nov 13 02:30:41 sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Sat Nov 13 02:30:41 exception in initAndListen std::exception: dbpath (/data/db/) does not exist, terminating
Sat Nov 13 02:30:41 dbexit:

Sat Nov 13 02:30:41 shutdown: going to close listening sockets...
Sat Nov 13 02:30:41 shutdown: going to flush oplog...
Sat Nov 13 02:30:41 shutdown: going to close sockets...
Sat Nov 13 02:30:41 shutdown: waiting for fs preallocator...
Sat Nov 13 02:30:41 shutdown: closing all files...
Sat Nov 13 02:30:41 closeAllFiles() finished

Sat Nov 13 02:30:41 dbexit: really exiting now


You can see a lot of things to do here but you should probably check on your log file to see some errors while your mongo wouldn't start. When I tailed my logs, I saw a different error stated like so

**************
old lock file: /usr/local/mongodb/data/mongod.lock. probably means unclean shutdown
recommend removing file and running --repair
see: http://dochub.mongodb.org/core/repair for more information
**************


And yes I did came from a crash. So I checked and removed the file and it automatically ran again based on my existing tail on the logs and it was back again.

Hope this helps somebody else as well.

No comments:

Post a Comment