2 min read

Recover mongodb after unexpected shutdown

Today I’m relaunching my Uptime Monitoring using NodeJS for uptime.web.id which is powered by Fiberoute. But due to bad configuration for the networking I did, the server had to shutdown from the SolusVM manualy.
My Mongodb crashed after the server boot, and never work again. From the log files, we need to repair it,  but we have to remove the mongod.lock first.

# rm /var/lib/mongodb/mongod.lock
# mongod --repair
Sat Apr 12 12:04:29.130
Sat Apr 12 12:04:29.130 warning: 32-bit servers don't have journaling enabled by
 default. Please use --journal if you want durability.
Sat Apr 12 12:04:29.130
Sat Apr 12 12:04:29.138 [initandlisten] MongoDB starting : pid=3699 port=27017 d
bpath=/data/db/ 32-bit host=uptime
Sat Apr 12 12:04:29.138 [initandlisten]
Sat Apr 12 12:04:29.138 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary
.
Sat Apr 12 12:04:29.138 [initandlisten] **       32 bit builds are limited to le
ss than 2GB of data (or less with --journal).
Sat Apr 12 12:04:29.138 [initandlisten] **       Note that journaling defaults t
o off for 32 bit and is currently off.
Sat Apr 12 12:04:29.138 [initandlisten] **       See http://dochub.mongodb.org/c
ore/32bit
Sat Apr 12 12:04:29.138 [initandlisten]
Sat Apr 12 12:04:29.138 [initandlisten] db version v2.4.10
Sat Apr 12 12:04:29.138 [initandlisten] git version: e3d78955d181e475345ebd60053
a4738a4c5268a
Sat Apr 12 12:04:29.138 [initandlisten] build info: Linux bs-linux32.10gen.cc 2.
6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_49
Sat Apr 12 12:04:29.138 [initandlisten] allocator: system
Sat Apr 12 12:04:29.138 [initandlisten] options: { repair: true }
Sat Apr 12 12:04:29.138 [initandlisten] exception in initAndListen: 10296
*********************************************************************
 ERROR: dbpath (/data/db/) does not exist.
 Create this directory or give existing directory in --dbpath.
 See http://dochub.mongodb.org/core/startingandstoppingmongo
*********************************************************************
, terminating
Sat Apr 12 12:04:29.138 dbexit:
Sat Apr 12 12:04:29.138 [initandlisten] shutdown: going to close listening socke
ts...
Sat Apr 12 12:04:29.138 [initandlisten] shutdown: going to flush diaglog...
Sat Apr 12 12:04:29.138 [initandlisten] shutdown: going to close sockets...
Sat Apr 12 12:04:29.138 [initandlisten] shutdown: waiting for fs preallocator...
Sat Apr 12 12:04:29.138 [initandlisten] shutdown: closing all files...
Sat Apr 12 12:04:29.138 [initandlisten] closeAllFiles() finished
Sat Apr 12 12:04:29.138 dbexit: really exiting now

Wait until it finished, and then try to restart the mongodb again.