How to resolve error :dbpath (/data/db/) does not exist permanently in MongoDB
Assuming you have followed the instructions to install a packaged version of MongoDB, you should be starting and stopping mongod
using service
.
To start mongod
:
sudo service mongodb start
To stop mongod
:
sudo service mongodb stop
If you use the service command to start and stop, it should be using the configuration file: /etc/mongodb.conf
.
Starting mongod
from the command line
If you run mongod
directly instead of using the service definition, you will also have to specify a configuration file as a command line parameter if you want one to be used:
mongod --config /etc/mongodb.conf
Here is how I got this resolved, simply by following their official Doc . HERE.
Step by step from teminal (running ubuntu) :
- cd into /srv folder =>>
cd /srv/
- make directory =>>
mkdir -p mongodb
- From within /srv/ give the newly created mongodb folder the right permissions and group ......
- Lastly, run this =>
mongod --dbpath /srv/mongodb/
"step by step" Copy of the terminal ...... :)
~$ mongod Tue Jun 3 20:27:39.564 [initandlisten] MongoDB starting : pid=5380 port=27017 dbpath=/srv/mongodb/ 64-bit host= -SVE1411EGXB Tue Jun 3 20:27:39.564 [initandlisten] db version v2.4.10 Tue Jun 3 20:27:39.564 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268a Tue Jun 3 20:27:39.564 [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 Tue Jun 3 20:27:39.564 [initandlisten] allocator: tcmalloc Tue Jun 3 20:27:39.564 [initandlisten] options: { dbpath: "/srv/mongodb/" } Tue Jun 3 20:27:39.565 [initandlisten] exception in initAndListen: 10296 ********************************************************************* ERROR: dbpath (/srv/mongodb/) does not exist. Create this directory or give existing directory in --dbpath. See http://dochub.mongodb.org/core/startingandstoppingmongo ********************************************************************* , terminating Tue Jun 3 20:27:39.565 dbexit: Tue Jun 3 20:27:39.565 [initandlisten] shutdown: going to close listening sockets... Tue Jun 3 20:27:39.565 [initandlisten] shutdown: going to flush diaglog... Tue Jun 3 20:27:39.565 [initandlisten] shutdown: going to close sockets... Tue Jun 3 20:27:39.565 [initandlisten] shutdown: waiting for fs preallocator... Tue Jun 3 20:27:39.565 [initandlisten] shutdown: lock for final commit... Tue Jun 3 20:27:39.565 [initandlisten] shutdown: final commit... Tue Jun 3 20:27:39.565 [initandlisten] shutdown: closing all files... Tue Jun 3 20:27:39.565 [initandlisten] closeAllFiles() finished Tue Jun 3 20:27:39.565 dbexit: really exiting now ~$ mongod --dbpath /srv/mongodb/ Tue Jun 3 20:27:55.616 [initandlisten] MongoDB starting : pid=5445 port=27017 dbpath=/srv/mongodb/ 64-bit host= -SVE1411EGXB Tue Jun 3 20:27:55.616 [initandlisten] db version v2.4.10 Tue Jun 3 20:27:55.616 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268a Tue Jun 3 20:27:55.616 [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 Tue Jun 3 20:27:55.616 [initandlisten] allocator: tcmalloc Tue Jun 3 20:27:55.616 [initandlisten] options: { dbpath: "/srv/mongodb/" } Tue Jun 3 20:27:55.617 [initandlisten] exception in initAndListen: 10296 ~$ sudo service mongodb startstart: Job is already running: mongodb ~$ sudo service mongodb stopmongodb stop/waiting ~$ cd /srv/ ~$~$/srv$ ls ~$ /srv$ mkdir mongodb ~$ sudo chgrp /srv ~$ sudo chmod 775 /srv ~$ cd /srv/ /srv$ ls /srv$ mkdir mongodb /srv$ ls mongodb /srv$ cd ~$ mongod --dbpath /srv/mongodb/Tue Jun 3 20:40:57.457 [initandlisten] MongoDB starting : pid=6018 port=27017 dbpath=/srv/mongodb/ 64-bit host= -SVE1411EGXBTue Jun 3 20:40:57.457 [initandlisten] db version v2.4.10Tue Jun 3 20:40:57.457 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268aTue Jun 3 20:40:57.457 [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_49Tue Jun 3 20:40:57.457 [initandlisten] allocator: tcmallocTue Jun 3 20:40:57.457 [initandlisten] options: { dbpath: "/srv/mongodb/" }Tue Jun 3 20:40:57.520 [initandlisten] journal dir=/srv/mongodb/journalTue Jun 3 20:40:57.521 [initandlisten] recover : no journal files present, no recovery neededTue Jun 3 20:41:00.545 [initandlisten] preallocateIsFaster=true 36.86Tue Jun 3 20:41:03.489 [initandlisten] preallocateIsFaster=true 35.06Tue Jun 3 20:41:07.456 [initandlisten] preallocateIsFaster=true 34.44Tue Jun 3 20:41:07.456 [initandlisten] preallocateIsFaster check took 9.935 secsTue Jun 3 20:41:07.456 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.0Tue Jun 3 20:41:10.009 [initandlisten] File Preallocator Progress: 985661440/1073741824 91%Tue Jun 3 20:41:22.273 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.1Tue Jun 3 20:41:25.009 [initandlisten] File Preallocator Progress: 933232640/1073741824 86%Tue Jun 3 20:41:37.119 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.2Tue Jun 3 20:41:40.093 [initandlisten] File Preallocator Progress: 1006632960/1073741824 93%Tue Jun 3 20:41:52.450 [FileAllocator] allocating new datafile /srv/mongodb/local.ns, filling with zeroes...Tue Jun 3 20:41:52.450 [FileAllocator] creating directory /srv/mongodb/_tmpTue Jun 3 20:41:52.503 [FileAllocator] done allocating datafile /srv/mongodb/local.ns, size: 16MB, took 0.022 secsTue Jun 3 20:41:52.517 [FileAllocator] allocating new datafile /srv/mongodb/local.0, filling with zeroes...Tue Jun 3 20:41:52.537 [FileAllocator] done allocating datafile /srv/mongodb/local.0, size: 64MB, took 0.02 secsTue Jun 3 20:41:52.538 [websvr] admin web console waiting for connections on port 28017Tue Jun 3 20:41:52.538 [initandlisten] waiting for connections on port 27017