Mongod runs, but Mongo returns an error - mongodb

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

Related

Unable to start MongoDB. ERROR: addr already in use

I tried running MongoDB in local server with mongod command and it failed to run. The error:
mongod --help for help and startup options
Sat Jan 31 13:07:16.392 [initandlisten] MongoDB starting : pid=5127 port=27017 dbpath=/data/db/ 64-bit host=leandrotk
Sat Jan 31 13:07:16.392 [initandlisten] db version v2.4.9
Sat Jan 31 13:07:16.392 [initandlisten] git version: nogitversion
Sat Jan 31 13:07:16.392 [initandlisten] build info: Linux orlo 3.2.0-58-generic #88-Ubuntu SMP Tue Dec 3 17:37:58 UTC 2013 x86_64 BOOST_LIB_VERSION=1_54
Sat Jan 31 13:07:16.392 [initandlisten] allocator: tcmalloc
Sat Jan 31 13:07:16.392 [initandlisten] options: {}
Sat Jan 31 13:07:16.435 [initandlisten] journal dir=/data/db/journal
Sat Jan 31 13:07:16.435 [initandlisten] recover : no journal files present, no recovery needed
Sat Jan 31 13:07:16.513 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Sat Jan 31 13:07:16.514 [initandlisten] ERROR: addr already in use
Sat Jan 31 13:07:16.514 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
Sat Jan 31 13:07:16.514 [initandlisten] now exiting
Sat Jan 31 13:07:16.514 [websvr] ERROR: addr already in use
Sat Jan 31 13:07:16.514 dbexit:
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to close listening sockets...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to flush diaglog...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: going to close sockets...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: waiting for fs preallocator...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: lock for final commit...
Sat Jan 31 13:07:16.514 [initandlisten] shutdown: final commit...
Sat Jan 31 13:07:16.599 [initandlisten] shutdown: closing all files...
Sat Jan 31 13:07:16.599 [initandlisten] closeAllFiles() finished
Sat Jan 31 13:07:16.599 [initandlisten] journalCleanup...
Sat Jan 31 13:07:16.599 [initandlisten] removeJournalFiles
Sat Jan 31 13:07:16.668 [initandlisten] shutdown: removing fs lock...
Sat Jan 31 13:07:16.668 dbexit: really exiting now
you already have a process running
killall mongod
should kill the other process, if you have another kind of process bound to that port you could find it with netstat | grep 27017
Try this:
sudo service mongodb stop
sudo mongod
some version is:
sudo service mongod stop
mongod: mongo damon

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

MongoDB Catch-22 won't let me drop huge collection

So I have a 2TB hard drive with 2 collections in 1 mongoDB.
Collection 1 is about 500gb and completely essential
Collection 2 is about 1500gb and needs to be deleted.
I was running a process that accidentally filled up the entire HDD, leaving 0% space. There is literally nothing on the machine apart from a Linux Distro and this mongoDB.
I would like to delete Collection 2.
In order to do this, I would normally just go into mongo and type db.collection.drop()
However, mongoDB is not currently running. In order to start it, I'm using:
[bobby#myPC bin]# ./mongod --dbpath /home/mongo &
However, since there is no space on the HDD, it returns:
[bobby#myPC bin]# Thu Feb 14 17:47:10 [initandlisten] MongoDB starting : pid=1264 port=27017 dbpath=/home/mongo 64-bit host=localhost.localdomain
Thu Feb 14 17:47:10 [initandlisten] db version v2.2.3, pdfile version 4.5
Thu Feb 14 17:47:10 [initandlisten] git version: f570771a5d8a3846eb7586eaffcf4c2f4a96bf08
Thu Feb 14 17:47:10 [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
Thu Feb 14 17:47:10 [initandlisten] options: { dbpath: "/home/mongo" }
Thu Feb 14 17:47:10 [initandlisten] journal dir=/home/mongo/journal
Thu Feb 14 17:47:10 [initandlisten] recover : no journal files present, no recovery needed
Thu Feb 14 17:47:10 [initandlisten]
Thu Feb 14 17:47:10 [initandlisten] ERROR: Insufficient free space for journal files
Thu Feb 14 17:47:10 [initandlisten] Please make at least 3379MB available in /home/mongo/journal or use --smallfiles
Thu Feb 14 17:47:10 [initandlisten]
Thu Feb 14 17:47:10 [initandlisten] exception in initAndListen: 15926 Insufficient free space for journals, terminating
Thu Feb 14 17:47:10 dbexit:
Thu Feb 14 17:47:10 [initandlisten] shutdown: going to close listening sockets...
Thu Feb 14 17:47:10 [initandlisten] shutdown: going to flush diaglog...
Thu Feb 14 17:47:10 [initandlisten] shutdown: going to close sockets...
Thu Feb 14 17:47:10 [initandlisten] shutdown: waiting for fs preallocator...
Thu Feb 14 17:47:10 [initandlisten] shutdown: lock for final commit...
Thu Feb 14 17:47:10 [initandlisten] shutdown: final commit...
Thu Feb 14 17:47:10 [initandlisten] shutdown: closing all files...
Thu Feb 14 17:47:10 [initandlisten] closeAllFiles() finished
Thu Feb 14 17:47:10 [initandlisten] journalCleanup...
Thu Feb 14 17:47:10 [initandlisten] removeJournalFiles
Thu Feb 14 17:47:10 [initandlisten] shutdown: removing fs lock...
Thu Feb 14 17:47:10 dbexit: really exiting now
I can't remove this collection cause there's no space. And there's no space because I can't remove this collection.
How can I fix this? Is there some way of identifying which mongoDB files in /home/mongo I can take out?
Based on the error message, its complaining about not having enough space for the journal. Its not ideal in a production environment to run with out journaling, but you could try starting with out it while you fix the issue.
./mongod --nojournal --dbpath /home/mongo &
edit: to answer your question though, mongo creates and allocates files per database, not collection. So you wouldn't be able to target a specific file to remove a collection.

can't start mongo db

I'm trying to start mongo db but I'm getting an error
Here is the output:
k-ps-macbook:~ kp$ mongod
mongod --help for help and startup options
Tue Aug 16 15:57:11 [initandlisten] MongoDB starting : pid=4143 port=27017 dbpath=/data/db/ 64-bit
Tue Aug 16 15:57:11 [initandlisten] db version v1.8.2, pdfile version 4.5
Tue Aug 16 15:57:11 [initandlisten] git version: 433bbaa14aaba6860da15bd4de8edf600f56501b
Tue Aug 16 15:57:11 [initandlisten] build sys info: Darwin erh2.10gen.cc 9.6.0 Darwin Kernel Version 9.6.0: Mon Nov 24 17:37:00 PST 2008; root:xnu-1228.9.59~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40
Tue Aug 16 15:57:11 [initandlisten] couldn't open /data/db/awesome_blog.ns errno:13 Permission denied
Tue Aug 16 15:57:11 [initandlisten] error couldn't open file /data/db/awesome_blog.ns terminating
Tue Aug 16 15:57:11 dbexit:
Tue Aug 16 15:57:11 [initandlisten] shutdown: going to close listening sockets...
Tue Aug 16 15:57:11 [initandlisten] shutdown: going to flush diaglog...
Tue Aug 16 15:57:11 [initandlisten] shutdown: going to close sockets...
Tue Aug 16 15:57:11 [initandlisten] shutdown: waiting for fs preallocator...
Tue Aug 16 15:57:11 [initandlisten] shutdown: closing all files...
Tue Aug 16 15:57:11 closeAllFiles() finished
Tue Aug 16 15:57:11 [initandlisten] shutdown: removing fs lock...
Tue Aug 16 15:57:11 dbexit: really exiting now
any help will be appreciated,
thanks!
You will need read/write permissions to /data/db/
The error shows up, because you are not logged in as root user. To do that (if you use Debian), run:
sudo mongod
Or simply:
su root
Then type the password and type
mongod
Then you will get access to the
/data/db directory.
I deleted /data/db/mongod.lock to solve the problem.
From the command line, run:
cd ~
./mongod --repair
If you're still having trouble getting it to run then find the /data directory (it should be inside of ~ or ~/workspace) and cd into it. Once inside, run rm mongod.lock then cd back into ~ and run ./mongod again (see below).
cd ~/data
rm mongod.lock
cd
./mongod