Thursday, May 8, 2014

Solution for connect failure - MongoDB startup error on Debian/BOSS OS

Solution for connect failure at src/mongo/shell/mongo.js - MongoDB startup error on Debian/BOSS OS I've installed MongoDB 2.4, last year, It was working fine with replication and sharding. Today I tried to start MongoDB, It wont as I was expected as usual. Surprisingly thrown error "Connection Failed "



ERROR
root@solai[~]#mongo
MongoDB shell version: 2.4.4
connecting to: test
Mon May  5 13:25:39.094 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed



SOLUTION

1) Remove mongodb.lock file under dbpath (its configured /etc/mongodb.conf)
2) Start/restart mongodb server

1) To get the dbpath directory details
root@solai[bin]#vi /etc/mongodb.conf
...........
...........
dbpath=/data/db
...........
 

2) Remove the mongodb.lock under /data/db (as per in my configuration)
root@solai[bin]#rm -rf  /data/db/mongod.lock

3) Start the MongoDB server
root@solai[bin]#/etc/init.d/mongodb start


-------------------------------------------------***-------------------------------------------------------

To know more.


I was searching "mongod.lock" file in /var/lib/mongodb/mongod.lock
in order to remove, but I failed to find it.

Then I was searching  "mongod.lock" file,

root@solai[bin]#find / -name mongodb.lock

I had many "mongod.lock" files, Just confused which one to delete. Then I opened mongodb.conf file under "/etc/mongodb.conf"

root@solai[bin]#vi /etc/mongodb.conf
...........
...........
dbpath=/data/db
...........
 


the default dbpath is /var/lib/mongodb/ ,  but i have changed it to /data/db.  lock file for the running server always reside into dbpath directory. in my case lock file reside into /data/db/mongodb.lock


No comments: