MongoDB suddenly won't start - mongodb

I have been running MongoDB on a RPI for several weeks, and suddenly it won't start. I know there's a lot of similar questions where correcting the permissions seemed to work. However, this has not worked for me.
I suspect a power off of the RPI has caused this problem, but I have no idea how to solve it.
I get the following terminal output:
$ sudo service mongodb start
[FAIL] Starting database: mongodb failed!
More details are shown with the 'mongod' command:
$ mongod
db level locking enabled: 1
mongod --help for help and startup options
Fri Aug 28 14:04:06
Fri Aug 28 14:04:06 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Fri Aug 28 14:04:06
Fri Aug 28 14:04:06 [initandlisten] MongoDB starting : pid=4036 port=27017 dbpath=/data/db/ 32-bit host=raspberrypi
Fri Aug 28 14:04:06 [initandlisten]
Fri Aug 28 14:04:06 [initandlisten] ** NOTE: This is a development version (2.1.1) of MongoDB.
Fri Aug 28 14:04:06 [initandlisten] ** Not recommended for production.
Fri Aug 28 14:04:06 [initandlisten]
Fri Aug 28 14:04:06 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Fri Aug 28 14:04:06 [initandlisten] ** see http://blog.mongodb.org/post/137788967/32-bit-limitations
Fri Aug 28 14:04:06 [initandlisten] ** with --journal, the limit is lower
Fri Aug 28 14:04:06 [initandlisten]
Fri Aug 28 14:04:06 [initandlisten] db version v2.1.1, pdfile version 4.5
Fri Aug 28 14:04:06 [initandlisten] git version: f457ff42ec37f2562d1a5ff06b4d96a861414c94
Fri Aug 28 14:04:06 [initandlisten] build info: Linux piplusraspbian 3.12.22+ #691 PREEMPT Wed Jun 18 18:29:58 BST 2014 armv6l BOOST_LIB_VERSION=1_49
Fri Aug 28 14:04:06 [initandlisten] options: {}
Fri Aug 28 14:04:06 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Fri Aug 28 14:04:06 dbexit:
Fri Aug 28 14:04:06 [initandlisten] shutdown: going to close listening sockets...
Fri Aug 28 14:04:06 [initandlisten] shutdown: going to flush diaglog...
Fri Aug 28 14:04:06 [initandlisten] shutdown: going to close sockets...
Fri Aug 28 14:04:06 [initandlisten] shutdown: waiting for fs preallocator...
Fri Aug 28 14:04:06 [initandlisten] shutdown: closing all files...
Fri Aug 28 14:04:06 [initandlisten] closeAllFiles() finished
Fri Aug 28 14:04:06 [initandlisten] shutdown: removing fs lock...
Fri Aug 28 14:04:06 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Fri Aug 28 14:04:06 dbexit: really exiting now
The /data/db does exist and seem to have the right permission:
$ ls -l /data
total 8
drwxr-xr-x 2 mongodb mongodb 4096 Aug 28 14:37 db
drwxr-xr-x 4 mongodb mongodb 4096 Aug 28 09:44 db_backup
The content of db has been copied to db_backup to check if that did any change, but it didn't. The db content permissions also seem fine:
$ ls -l /data/db_backup
total 131100
drwxr-xr-x 2 mongodb mongodb 4096 Aug 28 09:44 client-db
-rw------- 1 mongodb mongodb 16777216 Aug 28 09:44 client-db.0
-rw------- 1 mongodb mongodb 33554432 Aug 28 09:44 client-db.1
-rw------- 1 mongodb mongodb 16777216 Aug 28 09:44 client-db.ns
-rwxr-xr-x 1 mongodb mongodb 0 Aug 28 13:52 mongod.lock
drwxr-xr-x 2 mongodb mongodb 4096 Aug 28 09:44 myproject
-rw------- 1 mongodb mongodb 16777216 Aug 28 09:44 myproject.0
-rw------- 1 mongodb mongodb 33554432 Aug 28 09:44 myproject.1
-rw------- 1 mongodb mongodb 16777216 Aug 28 09:44 myproject.ns
I have also tried mongod --repair, but it does not help.
Does anyone have any ideas?
I don't care about the data, as it is all just temporary testing data.

There is a mongod.lock file inside the mongo's data directory, normally is /var/lib/mongodb. The content of this file is the pid of the mongod process.
If the mongod is stopped, the content of this file should be empty. Otherwise the mongod was stopped unexpectedly. To fix and start a new mongod process, assuming that mongo's data directory is /var/lib/mongodb. Just clear the file...
$ echo "" > /var/lib/mongodb/mongod.lock
and start a new mongod process.
$ mongod

Related

MongoDB Start several mongod with different ports

I can't change port in second mongod in my cmd
1 I'm starting mongod in c:\mongodb\bin
2 I'm starting cmd and writing
cd c:\mongodb\bin
mongod --port 10003
But second mongod not work.
Help me.Thank you!
This is error what show me
C:\Windows\system32> cd c:\mongodb\bin
c:\mongodb\bin>mongod --port 10003
Wed Apr 16 22:15:56.619
Wed Apr 16 22:15:56.620 warning: 32-bit servers don't have journaling enabled by
default. Please use --journal if you want durability.
Wed Apr 16 22:15:56.622
Wed Apr 16 22:15:56.635 [initandlisten] MongoDB starting : pid=8240 port=10003 d
bpath=\data\db\ 32-bit host=Danil
Wed Apr 16 22:15:56.637 [initandlisten]
Wed Apr 16 22:15:56.638 [initandlisten] ** NOTE: This is a 32 bit MongoDB binary
.
Wed Apr 16 22:15:56.640 [initandlisten] ** 32 bit builds are limited to le
ss than 2GB of data (or less with --journal).
Wed Apr 16 22:15:56.641 [initandlisten] ** Note that journaling defaults t
o off for 32 bit and is currently off.
Wed Apr 16 22:15:56.643 [initandlisten] ** See http://dochub.mongodb.org/c
ore/32bit
Wed Apr 16 22:15:56.645 [initandlisten]
Wed Apr 16 22:15:56.646 [initandlisten] db version v2.4.10
Wed Apr 16 22:15:56.648 [initandlisten] git version: e3d78955d181e475345ebd60053
a4738a4c5268a
Wed Apr 16 22:15:56.650 [initandlisten] build info: windows sys.getwindowsversio
n(major=6, minor=0, build=6002, platform=2, service_pack='Service Pack 2') BOOST
_LIB_VERSION=1_49
Wed Apr 16 22:15:56.651 [initandlisten] allocator: system
Wed Apr 16 22:15:56.653 [initandlisten] options: { port: 10003 }
Wed Apr 16 22:15:56.655 [initandlisten] exception in initAndListen: 13627 Unable
to create/open lock file: \data\db\mongod.lock ??????? ?? ????? ???????? ??????
? ?????, ??? ??? ???? ???? ????? ?????? ?????????.. Is a mongod instance alread
y running?, terminating
Wed Apr 16 22:15:56.657 dbexit:
Wed Apr 16 22:15:56.658 [initandlisten] shutdown: going to close listening socke
ts...
Wed Apr 16 22:15:56.660 [initandlisten] shutdown: going to flush diaglog...
Wed Apr 16 22:15:56.662 [initandlisten] shutdown: going to close sockets...
Wed Apr 16 22:15:56.663 [initandlisten] shutdown: waiting for fs preallocator...
Wed Apr 16 22:15:56.665 [initandlisten] shutdown: closing all files...
Wed Apr 16 22:15:56.666 [initandlisten] closeAllFiles() finished
Wed Apr 16 22:15:56.668 dbexit: really exiting now
c:\mongodb\bin>
try to start mongod with admin option as it is not able to open the file mongod.lock
You can't start multiple MongoDB processes on the same database.
What you need to do is:
mongod --dbpath c:\database1 --port 27017
mongod --dbpath c:\database2 --port 27018
Remember that you must manually create the database folders.
Usually if you read carefully the error log you will find the problem:
"13627 Unable to create/open lock file: \data\db\mongod.lock.
Is a mongod instance already running?"

Error in textSearchEnable=true in MongoDB

I am getting the below error when enabling text search in mongodb. Any Suggestion.
I have mongo.config filw which contains :
##store data here
dbpath=C:\mongodb\data
##all output go here
logpath=C:\mongodb\log\mongo.log
##log read and write operations
diaglog=3
Error is :
C:\mongodb-win32-x86_64-2.4.6\bin>mongod --setParameter textSearchEnabled=true
Tue Jan 14 16:52:51.336 [initandlisten] MongoDB starting : pid=976 port=27017 dbpath=\data\db\ 64-bit host=dellvostro3
Tue Jan 14 16:52:51.337 [initandlisten] db version v2.4.6
Tue Jan 14 16:52:51.337 [initandlisten] git version: b9925db5eac369d77a3a5f5d98a145eaaacd9673
Tue Jan 14 16:52:51.337 [initandlisten] build info: windows sys.getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Service Pack
1') BOOST_LIB_VERSION=1_49
Tue Jan 14 16:52:51.337 [initandlisten] allocator: system
Tue Jan 14 16:52:51.337 [initandlisten] options: { setParameter: [ "textSearchEnabled=true" ] }
Tue Jan 14 16:52:51.337 [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
Tue Jan 14 16:52:51.338 dbexit:
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: going to close listening sockets...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: going to flush diaglog...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: going to close sockets...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: waiting for fs preallocator...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: lock for final commit...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: final commit...
Tue Jan 14 16:52:51.338 [initandlisten] shutdown: closing all files...
Tue Jan 14 16:52:51.338 [initandlisten] closeAllFiles() finished
Tue Jan 14 16:52:51.338 dbexit: really exiting now
You provide wrong path to your data
ERROR: dbpath (\data\db\) does not exist.
\data\db\ is default mongo data path, you need to create this directory or get provide another path when running mongod
When you run
mongod --setParameter textSearchEnabled=true
MongoDB will take \data\db\ as the dbpath. Which is not there in your machine and hence you get the error.
I see you have a config file containing the dbpath etc, but you haven't specified the config file while starting mongod.
mongod --config mongo.config --setParameter textSearchEnabled=true
See using config file here.
Also you could move the textSearchEnabled=true to your config file.
##store data here
dbpath=C:\mongodb\data
##all output go here
logpath=C:\mongodb\log\mongo.log
##log read and write operations
diaglog=3
setParameter=textSearchEnabled=true
Now you can start mongod by just using
mongod --config mongo.config

Assertion: 13524:out of memory AlignedBuilder

I start MongoDB, using commang: sudo service mongodb start.
OS: Ubuntu 11.04
My log is here:
***** SERVER RESTARTED *****
Mon Apr 29 21:55:23.697 [initandlisten] MongoDB starting : pid=3995 port=27017 dbpath=/srv/mongodb/ 64-bit host=myhost
Mon Apr 29 21:55:23.697 [initandlisten]
Mon Apr 29 21:55:23.697 [initandlisten] ** WARNING: You are running in OpenVZ. This is known to be broken!!!
Mon Apr 29 21:55:23.697 [initandlisten]
Mon Apr 29 21:55:23.697 [initandlisten] db version v2.4.3
Mon Apr 29 21:55:23.697 [initandlisten] git version: fe1743177a5ea03e91e0052fb5e2cb2945f6d95f
Mon Apr 29 21:55:23.697 [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
Mon Apr 29 21:55:23.697 [initandlisten] allocator: tcmalloc
Mon Apr 29 21:55:23.697 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/srv/mongodb/", logappend: "true", logpath: "/var/log/mongodb/mongodb.log" }
Mon Apr 29 21:55:23.701 [initandlisten] journal dir=/srv/mongodb/journal
Mon Apr 29 21:55:23.706 [initandlisten] recover : no journal files present, no recovery needed
Mon Apr 29 21:55:24.465 [initandlisten] preallocateIsFaster=true 14.5
Mon Apr 29 21:55:26.100 [initandlisten] preallocateIsFaster=true 32.4
Mon Apr 29 21:55:27.419 [initandlisten] preallocateIsFaster=true 6.1
Mon Apr 29 21:55:27.419 [initandlisten] preallocateIsFaster check took 3.71 secs
Mon Apr 29 21:55:27.419 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.0
Mon Apr 29 21:55:30.011 [initandlisten] File Preallocator Progress: 377487360/1073741824 35%
Mon Apr 29 21:55:48.672 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.1
Mon Apr 29 21:55:51.008 [initandlisten] File Preallocator Progress: 283115520/1073741824 26%
Mon Apr 29 21:55:54.032 [initandlisten] File Preallocator Progress: 754974720/1073741824 70%
Mon Apr 29 21:56:12.230 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.2
Mon Apr 29 21:56:15.006 [initandlisten] File Preallocator Progress: 765460480/1073741824 71%
Mon Apr 29 21:56:37.587 [FileAllocator] allocating new datafile /srv/mongodb/local.ns, filling with zeroes...
Mon Apr 29 21:56:37.587 [FileAllocator] creating directory /srv/mongodb/_tmp
Mon Apr 29 21:56:39.362 [FileAllocator] done allocating datafile /srv/mongodb/local.ns, size: 16MB, took 1.19 secs
Mon Apr 29 21:56:39.362 [FileAllocator] allocating new datafile /srv/mongodb/local.0, filling with zeroes...
Mon Apr 29 21:56:43.413 [FileAllocator] done allocating datafile /srv/mongodb/local.0, size: 64MB, took 4.051 secs
Mon Apr 29 21:56:43.426 [initandlisten] command local.$cmd command: { create: "startup_log", size: 10485760, capped: true } ntoreturn:1 keyUpdates:0 reslen:37 5839ms
Mon Apr 29 21:56:43.426 [initandlisten] waiting for connections on port 27017
Mon Apr 29 21:56:43.426 [journal] Assertion: 13524:out of memory AlignedBuilder
Mon Apr 29 21:56:43.426 [websvr] admin web console waiting for connections on port 28017
0xdcf361 0xd90a1b 0xd8e9ec 0xd8ec80 0x924cd1 0x924ec2 0x91a0b1 0x91bcf9 0x91c0bb 0xe17cb9 0x2ab868e0bd8c 0x2ab869ab6fdd
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xdcf361]
/usr/bin/mongod(_ZN5mongo11msgassertedEiPKc+0x9b) [0xd90a1b]
/usr/bin/mongod() [0xd8e9ec]
/usr/bin/mongod(_ZN5mongo14AlignedBuilderC1Ej+0x10) [0xd8ec80]
/usr/bin/mongod(_ZN5mongo3dur7Journal7journalERKNS0_11JSectHeaderERKNS_14AlignedBuilderE+0x221) [0x924cd1]
/usr/bin/mongod(_ZN5mongo3dur14WRITETOJOURNALENS0_11JSectHeaderERNS_14AlignedBuilderE+0x32) [0x924ec2]
/usr/bin/mongod(_ZN5mongo3dur27groupCommitWithLimitedLocksEv+0x141) [0x91a0b1]
/usr/bin/mongod() [0x91bcf9]
/usr/bin/mongod(_ZN5mongo3dur9durThreadEv+0x2eb) [0x91c0bb]
/usr/bin/mongod() [0xe17cb9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c) [0x2ab868e0bd8c]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x2ab869ab6fdd]
Mon Apr 29 21:56:43.880 [journal] dbexception in groupCommitLL causing immediate shutdown: 13524 out of memory AlignedBuilder
Mon Apr 29 21:56:43.880 dur1
Mon Apr 29 21:56:43.880 Got signal: 6 (Aborted).
Mon Apr 29 21:56:43.882 Backtrace:
0xdcf361 0x6cf729 0x2ab869a01d80 0x2ab869a01d05 0x2ab869a05ab6 0x9e8de7 0x91a4df 0x91bcf9 0x91c0bb 0xe17cb9 0x2ab868e0bd8c 0x2ab869ab6fdd
/usr/bin/mongod(_ZN5mongo15printStackTraceERSo+0x21) [0xdcf361]
/usr/bin/mongod(_ZN5mongo10abruptQuitEi+0x399) [0x6cf729]
/lib/x86_64-linux-gnu/libc.so.6(+0x33d80) [0x2ab869a01d80]
/lib/x86_64-linux-gnu/libc.so.6(gsignal+0x35) [0x2ab869a01d05]
/lib/x86_64-linux-gnu/libc.so.6(abort+0x186) [0x2ab869a05ab6]
/usr/bin/mongod(_ZN5mongo10mongoAbortEPKc+0x47) [0x9e8de7]
/usr/bin/mongod(_ZN5mongo3dur27groupCommitWithLimitedLocksEv+0x56f) [0x91a4df]
/usr/bin/mongod() [0x91bcf9]
/usr/bin/mongod(_ZN5mongo3dur9durThreadEv+0x2eb) [0x91c0bb]
/usr/bin/mongod() [0xe17cb9]
/lib/x86_64-linux-gnu/libpthread.so.0(+0x6d8c) [0x2ab868e0bd8c]
/lib/x86_64-linux-gnu/libc.so.6(clone+0x6d) [0x2ab869ab6fdd]
How resolve this problem? I tryed reinstall MongoDB, but my problem is stayed.
PS: Why dbpath directory is so big??
root#myhost:~# du -hs /srv/mongodb/
3.1G /srv/mongodb/
You are using OpenVZ as your VM hypervisor. The way OpenVZ manages memory means that MongoDB's memory mapped file structure will NOT work.
You should try getting a VM that uses KVM as it's hypervisor, if possible.
I had this problem when filesystem went to 100% (due verbose logs that where not in /var).
it ended up in bad journal files.
impossible to repair the database (even with --repair)
The only way to recover seems to restart from a backup, and re-importing the proper tables.
to be able to re-start the DB in that situation (for mongodump or because it is prod) is as follow.
You have to start Mongo without journaling (very dangerous, you should leave this mode asap)
set nojournal = true in mongod.conf
then:
rm /mnt/pathto/mongodb/journal/*
rm /mnt/pathto/mongodb/mongod.lock
chown -R mongodb:mongodb /mnt/pathto/mongodb (in case you tried as root "mongod -f /etc/mongodb.conf --repair" as I did)
service mongodb start
DB is up & running, you can do your dumps a restart it WITH journaling (after restoring a backup then the mongodumps)

Mongod runs, but Mongo returns an error

This question has been asked before but was never answered. Furthermore, my error logs are slightly different:
When I run 'mongo' I get this error:
MongoDB shell version: 2.2.0
connecting to: test
Fri Nov 16 10:52:05 Error: couldn't connect to server 127.0.0.1:27017 src/mongo/shell/mongo.js:91
exception: connect failed
Here are my error logs:
Fri Nov 16 10:47:44 [initandlisten] MongoDB starting : pid=46508 port=27017 dbpath=/usr/local/var/mongodb 64-bit host=Brians-MacBook-Pro-2.local
Fri Nov 16 10:47:44 [initandlisten]
Fri Nov 16 10:47:44 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Fri Nov 16 10:47:44 [initandlisten] db version v2.2.0, pdfile version 4.5
Fri Nov 16 10:47:44 [initandlisten] git version: f5e83eae9cfbec7fb7a071321928f00d1b0c5207
Fri Nov 16 10:47:44 [initandlisten] build info: Darwin bs-osx-106-x86-64-1.local 10.8.0 Darwin Kernel Version 10.8.0: Tue Jun 7 16:33:36 PDT 2011; root:xnu-1504.15.3~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49
Fri Nov 16 10:47:44 [initandlisten] options: { bind_ip: "127.0.0.1", config: "/usr/local/etc/mongod.conf", dbpath: "/usr/local/var/mongodb", logappend: "true", logpath: "/usr/local/var/log/mongodb/mongo.log" }
Fri Nov 16 10:47:44 [initandlisten] journal dir=/usr/local/var/mongodb/journal
Fri Nov 16 10:47:44 [initandlisten] recover begin
Fri Nov 16 10:47:44 [initandlisten] couldn't open /usr/local/var/mongodb/journal/lsn errno:13 Permission denied
Fri Nov 16 10:47:44 [initandlisten] Assertion failure f.is_open() src/mongo/db/dur_journal.cpp 552
0x10037637b 0x1000b0196 0x100105ec2 0x10049de46 0x10049e445 0x10049e628 0x1002401ac 0x1000057ec 0x10000608d 0x10000d534 0x10000f309 0x100000ea4 0x3
0 mongod 0x000000010037637b _ZN5mongo15printStackTraceERSo + 43
1 mongod 0x00000001000b0196 _ZN5mongo12verifyFailedEPKcS1_j + 310
2 mongod 0x0000000100105ec2 _ZN5mongo3dur14journalReadLSNEv + 898
3 mongod 0x000000010049de46 _ZN5mongo3dur11RecoveryJob2goERSt6vectorIN5boost11filesystem210basic_pathISsNS4_11path_traitsEEESaIS7_EE + 86
4 mongod 0x000000010049e445 _ZN5mongo3dur8_recoverEv + 405
5 mongod 0x000000010049e628 _ZN5mongo3dur7recoverEv + 40
6 mongod 0x00000001002401ac _ZN5mongo3dur7startupEv + 124
7 mongod 0x00000001000057ec _ZN5mongo14_initAndListenEi + 1052
8 mongod 0x000000010000608d _ZN5mongo13initAndListenEi + 29
9 mongod 0x000000010000d534 _ZL11mongoDbMainiPPc + 29348
10 mongod 0x000000010000f309 main + 9
11 mongod 0x0000000100000ea4 start + 52
12 ??? 0x0000000000000003 0x0 + 3
Fri Nov 16 10:47:44 [initandlisten] dbexception during recovery: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:552
Fri Nov 16 10:47:44 [initandlisten] exception in initAndListen: 13611 can't read lsn file in journal directory : assertion src/mongo/db/dur_journal.cpp:552, terminating
Fri Nov 16 10:47:44 dbexit:
Fri Nov 16 10:47:44 [initandlisten] shutdown: going to close listening sockets...
Fri Nov 16 10:47:44 [initandlisten] shutdown: going to flush diaglog...
Fri Nov 16 10:47:44 [initandlisten] shutdown: going to close sockets...
Fri Nov 16 10:47:44 [initandlisten] shutdown: waiting for fs preallocator...
Fri Nov 16 10:47:44 [initandlisten] shutdown: lock for final commit...
Fri Nov 16 10:47:44 [initandlisten] shutdown: final commit...
Fri Nov 16 10:47:44 [initandlisten] shutdown: closing all files...
Fri Nov 16 10:47:44 [initandlisten] closeAllFiles() finished
Fri Nov 16 10:47:44 [initandlisten] shutdown: removing fs lock...
Fri Nov 16 10:47:44 dbexit: really exiting now
There is no output when I run:
netstat -f inet -a -n | grep 27101
Thanks for your help!
As #Nilam said one of your problems is the journal, however, you actually have two problems here, the one I am talking about being more of a warning:
Fri Nov 16 10:47:44 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
This specifically relates to: https://jira.mongodb.org/browse/SERVER-4407
You should look into increasing your openfile count in Linux otherwise you could get this: http://www.mongodb.org/display/DOCS/Too+Many+Open+Files of course this page also tells you how to solve the problem.
NB: as a side note to the journal point, it looks like your MongoDB node could be trying to recover from something. I would check why.
Similar to #Hartator's answer, this solved the issue for me:
chmod -R 777 /data/db
You have
journal dir=/usr/local/var/mongodb/journal
The error shows is
[initandlisten] couldn't open /usr/local/var/mongodb/journal/lsn errno:13 Permission denied
So check if journal directory exist and proper write permissions are given to this folder.
Try to run :
chmod 777 -R /usr/local/var/mongodb

How to resolve error :dbpath (/data/db/) does not exist permanently in MongoDB

I have installed mongodb in my Ubuntu 10.04.
I know that when it comes to start the mongodb server with the command "mongod",then it expects /data/db folder and it can be easily resolved by creating "/data/db/". One more way is to provide your own path using mongod --dbpath "path",when we intend to give our own custom path for db.
But while going through http://docs.mongodb.org/manual/tutorial/install-mongodb-on-ubuntu/ link i found that there is a configuration file.
I made the following changes to it.
# mongodb.conf
dbpath=/EBS/Work/mongodb/data/db/
logpath=/EBS/Work/mongodb/mongodb.log
logappend=true
But still when I try to start the server with "mongod" it throws the same error
i.e error :dbpath (/data/db/) does not exist .
I wanted to know that how can I permanently redirect my dbpath to my own custom folder cause everytime you don't want to type the path using "mongod --dbpath path".Rather we look to make some changes in configuration file.
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 start
start: Job is already running: mongodb
~$ sudo service mongodb stop
mongodb 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= -SVE1411EGXB
Tue Jun 3 20:40:57.457 [initandlisten] db version v2.4.10
Tue Jun 3 20:40:57.457 [initandlisten] git version: e3d78955d181e475345ebd60053a4738a4c5268a
Tue 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_49
Tue Jun 3 20:40:57.457 [initandlisten] allocator: tcmalloc
Tue Jun 3 20:40:57.457 [initandlisten] options: { dbpath: "/srv/mongodb/" }
Tue Jun 3 20:40:57.520 [initandlisten] journal dir=/srv/mongodb/journal
Tue Jun 3 20:40:57.521 [initandlisten] recover : no journal files present, no recovery needed
Tue Jun 3 20:41:00.545 [initandlisten] preallocateIsFaster=true 36.86
Tue Jun 3 20:41:03.489 [initandlisten] preallocateIsFaster=true 35.06
Tue Jun 3 20:41:07.456 [initandlisten] preallocateIsFaster=true 34.44
Tue Jun 3 20:41:07.456 [initandlisten] preallocateIsFaster check took 9.935 secs
Tue Jun 3 20:41:07.456 [initandlisten] preallocating a journal file /srv/mongodb/journal/prealloc.0
Tue 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.1
Tue 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.2
Tue 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/_tmp
Tue Jun 3 20:41:52.503 [FileAllocator] done allocating datafile /srv/mongodb/local.ns, size: 16MB, took 0.022 secs
Tue 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 secs
Tue Jun 3 20:41:52.538 [websvr] admin web console waiting for connections on port 28017
Tue Jun 3 20:41:52.538 [initandlisten] waiting for connections on port 27017
Change the user of the new data directory:
chown mongodb [rute_directory]
And try another time to start the mongo service
service mongodb start
I solve the same problem with this.
Find mongo log file from root system folder
sudo find / -name "mongodb.log" -type f
result:
/var/log/mongodb/mongodb.log
open /var/log/mongodb/mongodb.log
search for last "exception" word
try to correct exception
In my case exception was the next:
2015-07-30T15:09:15.806+0300 [initandlisten] exception in initAndListen: 13597 can't start without --journal enabled when journal/ files are present, terminating
I made the next:
cd /var/lib/mongodb
rm -r journal/
If you are using mac catalina:
mongod --dbpath=/Users/user/data/db
leave this window
then you can type in another window.
mongo
show dbs