mongod shell doesn't start, data/db doesn't exsist

debian, mongodb

Solution

The default db path for mongodb is `/data/db/`.

So when you run:

mongod

MongoDB checks if /data/db/ is present and if the user has access to it. In your case, there is no such directory and hence the error.

However you can override the default db path using the --dbpath argument of mongod( or use a config file).

mongod --dbpath /var/lib/mongodb/data/db

In this case instead of checking for /data/db/ mongoDB check for /var/lib/mongodb/data/db. In your case, you have the specified directory and you have access to it and hence it runs.

And doing this doesn't start the mongo shell. To start the shell, start mongod first as mentioned above and leave it running. Then in another terminal execute

mongo

This will start the mongo shell.

Problem

When I start mongod trowed error. What is the problem? ``` root@cs12867:~# mongod mongod --help for help and startup options Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867 Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6 Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673 Sun Dec 22 15:37:44.081 [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 Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc Sun Dec 22 15:37:44.081 [initandlisten] options: {} Sun Dec 22 15:37:44.081 [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 Sun Dec 22 15:37:44.081 dbexit: Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files... Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished Sun Dec 22 15:37:44.081 dbexit: really exiting now ``` I set `--dbpath`: ``` root@cs12867:~# mongod --dbpath /var/lib/mongodb/data/db Sun Dec 22 15:29:25.121 [initandlisten] MongoDB starting : pid=17739 port=27017 dbpath=/var/lib/mongodb/data/db 64-bit host=cs12867 Sun Dec 22 15:29:25.121 [initandlisten] db version v2.4.6 Sun Dec 22 15:29:25.121 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673 Sun Dec 22 15:29:25.121 [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 Sun Dec 22 15:29:25.121 [initandlisten] allocator: tcmalloc Sun Dec 22 15:29:25.121 [initandlisten] options: { dbpath: "/var/lib/mongodb/data/db" } Sun Dec 22 15:29:25.121 [initandlisten] Sun Dec 22 15:29:25.121 [initandlisten] ** WARNING: Readahead for /var/lib/mongodb/data/db is set to 2048KB Sun Dec 22 15:29:25.121 [initandlisten] ** We suggest setting it to 256KB (512 sectors) or less Sun Dec 22 15:29:25.121 [initandlisten] ** http://dochub.mongodb.org/core/readahead Sun Dec 22 15:29:25.123 [initandlisten] journal dir=/var/lib/mongodb/data/db/journal Sun Dec 22 15:29:25.123 [initandlisten] recover : no journal files present, no recovery needed Sun Dec 22 15:29:25.134 [initandlisten] waiting for connections on port 27017 Sun Dec 22 15:29:25.134 [websvr] admin web console waiting for connections on port 28017 Sun Dec 22 15:29:26.179 [initandlisten] connection accepted from 127.0.0.1:37164 #1 (1 connection now open) Sun Dec 22 15:29:26.179 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.ns, filling with zeroes... Sun Dec 22 15:29:26.179 [FileAllocator] creating directory /var/lib/mongodb/data/db/_tmp Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.ns, size: 16MB, took 0 secs Sun Dec 22 15:29:26.181 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.0, filling with zeroes... Sun Dec 22 15:29:26.181 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.0, size: 64MB, took 0 secs Sun Dec 22 15:29:26.182 [FileAllocator] allocating new datafile /var/lib/mongodb/data/db/Tester.1, filling with zeroes... Sun Dec 22 15:29:26.182 [FileAllocator] done allocating datafile /var/lib/mongodb/data/db/Tester.1, size: 128MB, took 0 secs Sun Dec 22 15:29:26.184 [conn1] build index Tester.user { _id: 1 } Sun Dec 22 15:29:26.184 [conn1] build index done. scanned 0 total records. 0 secs Sun Dec 22 15:29:26.184 [conn1] end connection 127.0.0.1:37164 (0 connections now open) Sun Dec 22 15:29:26.192 [initandlisten] connection accepted from 127.0.0.1:37165 #2 (1 connection now open) Sun Dec 22 15:29:26.732 [initandlisten] connection accepted from 127.0.0.1:37166 #3 (2 connections now open) Sun Dec 22 15:29:26.733 [conn3] end connection 127.0.0.1:37166 (1 connection now open) Sun Dec 22 15:29:26.740 [initandlisten] connection accepted from 127.0.0.1:37167 #4 (2 connections now open) Sun Dec 22 15:29:26.740 [conn4] end connection 127.0.0.1:37167 (1 connection now open) Sun Dec 22 15:29:26.834 [initandlisten] connection accepted from 127.0.0.1:37168 #5 (2 connections now open) Sun Dec 22 15:29:26.835 [conn5] end connection 127.0.0.1:37168 (1 connection now open) Sun Dec 22 15:29:26.843 [initandlisten] connection accepted from 127.0.0.1:37169 #6 (2 connections now open) Sun Dec 22 15:29:27.252 [initandlisten] connection accepted from 127.0.0.1:37170 #7 (3 connections now open) Sun Dec 22 15:29:27.253 [conn7] end connection 127.0.0.1:37170 (2 connections now open) Sun Dec 22 15:29:27.304 [initandlisten] connection accepted from 127.0.0.1:37171 #8 (3 connections now open) Sun Dec 22 15:29:27.304 [conn8] end connection 127.0.0.1:37171 (2 connections now open) Sun Dec 22 15:29:28.332 [initandlisten] connection accepted from 127.0.0.1:37173 #9 (3 connections now open) Sun Dec 22 15:29:28.333 [conn9] end connection 127.0.0.1:37173 (2 connections now open) Sun Dec 22 15:29:28.352 [initandlisten] connection accepted from 127.0.0.1:37174 #10 (3 connections now open) Sun Dec 22 15:29:28.842 [conn10] end connection 127.0.0.1:37174 (2 connections now open) Sun Dec 22 15:29:28.862 [initandlisten] connection accepted from 127.0.0.1:37176 #11 (3 connections now open) Sun Dec 22 15:29:28.863 [conn11] end connection 127.0.0.1:37176 (2 connections now open) Sun Dec 22 15:29:30.362 [initandlisten] connection accepted from 127.0.0.1:37178 #12 (3 connections now open) Sun Dec 22 15:29:30.363 [initandlisten] connection accepted from 127.0.0.1:37179 #13 (4 connections now open) Sun Dec 22 15:29:30.364 [conn13] end connection 127.0.0.1:37179 (3 connections now open) Sun Dec 22 15:37:36.523 [signalProcessingThread] shutdown: closing all files... Sun Dec 22 15:37:36.523 [signalProcessingThread] closeAllFiles() finished Sun Dec 22 15:37:36.523 [signalProcessingThread] journalCleanup... Sun Dec 22 15:37:36.523 [signalProcessingThread] removeJournalFiles Sun Dec 22 15:37:36.525 [signalProcessingThread] shutdown: removing fs lock... Sun Dec 22 15:37:36.525 dbexit: really exiting now ``` Then again: ``` root@cs12867:~# mongod mongod --help for help and startup options Sun Dec 22 15:37:44.081 [initandlisten] MongoDB starting : pid=18415 port=27017 dbpath=/data/db/ 64-bit host=cs12867 Sun Dec 22 15:37:44.081 [initandlisten] db version v2.4.6 Sun Dec 22 15:37:44.081 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673 Sun Dec 22 15:37:44.081 [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 Sun Dec 22 15:37:44.081 [initandlisten] allocator: tcmalloc Sun Dec 22 15:37:44.081 [initandlisten] options: {} Sun Dec 22 15:37:44.081 [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 Sun Dec 22 15:37:44.081 dbexit: Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close listening sockets... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to flush diaglog... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: going to close sockets... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: waiting for fs preallocator... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: lock for final commit... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: final commit... Sun Dec 22 15:37:44.081 [initandlisten] shutdown: closing all files... Sun Dec 22 15:37:44.081 [initandlisten] closeAllFiles() finished Sun Dec 22 15:37:44.081 dbexit: really exiting now ```

Original source

Related problems