0

When i faced his error i deleted mongod.lock from /var/lib/mongodb then i did mongod -repair SO it listed all these things

Fri Mar 21 14:21:17.511 [initandlisten] MongoDB starting : pid=21182 port=27017 dbpath=/data/db/ 64-bit host=thara-Precision-T1600
Fri Mar 21 14:21:17.511 [initandlisten] db version v2.4.9
Fri Mar 21 14:21:17.511 [initandlisten] git version: 52fe0d21959e32a5bdbecdc62057db386e4e029c
Fri Mar 21 14:21:17.511 [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
Fri Mar 21 14:21:17.511 [initandlisten] allocator: tcmalloc
Fri Mar 21 14:21:17.511 [initandlisten] options: { repair: true }
Fri Mar 21 14:21:17.511 [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
Fri Mar 21 14:21:17.511 dbexit: 
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: going to close listening sockets...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: going to flush diaglog...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: going to close sockets...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: waiting for fs preallocator...
Fri Mar 21 14:21:17.511 [initandlisten] shutdown: closing all files...
Fri Mar 21 14:21:17.511 [initandlisten] closeAllFiles() finished
Fri Mar 21 14:21:17.511 dbexit: really exiting now

Still it says pymongo.errors.ConnectionFailure: could not connect to localhost:27017: [Errno 111] Connection refused

user3322943
  • 11
  • 1
  • 3

1 Answers1

4

Like it says in the error message, mongod is not able to find the db path. Either create the folder "/data/db" at the root or if you have created it else where, specify the path using the --dbpath option like:

mongod --dbpath /data/db
Anand Jayabalan
  • 12,294
  • 5
  • 41
  • 52
  • In the /etc/mongodb.conf file the dbpath= /var/lib/mongodb and logpath=/var/log/mongodb/mongodb.log which i changed to another directory datapath=/data/db and logpath=/data/log . – user3322943 Mar 21 '14 at 13:23
  • I hope you meant "dbpath" rather than "datapath". Also, does the folder "/data/db" exist? – Anand Jayabalan Mar 21 '14 at 14:33
  • 1
    and how are you starting mongod? are you passing the required params for the mongodb.conf to be used? i.e., `mongod --config /etc/mongodb.conf` or `mongod -f /etc/mongodb.conf` – Anand Jayabalan Mar 21 '14 at 14:53