MongoDB running without executing daemon - mongodb

I installed MondoDB on my Ubuntu 13.04 and tried to run its daemon by typing in either mongod or sudo mongod, but I encountered the following message:
mongod --help for help and startup options
Thu Jun 27 05:11:02 [initandlisten] MongoDB starting : pid=11685 port=27017 dbpath=/data/db/ 64-bit host=myhost
Thu Jun 27 05:11:02 [initandlisten] db version v2.2.4, pdfile version 4.5
Thu Jun 27 05:11:02 [initandlisten] git version: nogitversion
Thu Jun 27 05:11:02 [initandlisten] build info: Linux batsu 3.2.0-37-generic #58-Ubuntu SMP Thu Jan 24 15:28:10 UTC 2013 x86_64 BOOST_LIB_VERSION=1_49
Thu Jun 27 05:11:02 [initandlisten] options: {}
Thu Jun 27 05:11:02 [initandlisten] journal dir=/data/db/journal
Thu Jun 27 05:11:02 [initandlisten] recover : no journal files present, no recovery needed
Thu Jun 27 05:11:02 [initandlisten] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:27017
Thu Jun 27 05:11:02 [websvr] ERROR: listen(): bind() failed errno:98 Address already in use for socket: 0.0.0.0:28017
Thu Jun 27 05:11:02 [websvr] ERROR: addr already in use
Thu Jun 27 05:11:02 [initandlisten] ERROR: addr already in use
Thu Jun 27 05:11:02 [initandlisten] now exiting
Thu Jun 27 05:11:02 dbexit:
Thu Jun 27 05:11:02 [initandlisten] shutdown: going to close listening sockets...
Thu Jun 27 05:11:02 [initandlisten] shutdown: going to flush diaglog...
Thu Jun 27 05:11:02 [initandlisten] shutdown: going to close sockets...
Thu Jun 27 05:11:02 [initandlisten] shutdown: waiting for fs preallocator...
Thu Jun 27 05:11:02 [initandlisten] shutdown: lock for final commit...
Thu Jun 27 05:11:02 [initandlisten] shutdown: final commit...
Thu Jun 27 05:11:02 [initandlisten] shutdown: closing all files...
Thu Jun 27 05:11:02 [initandlisten] closeAllFiles() finished
Thu Jun 27 05:11:02 [initandlisten] journalCleanup...
Thu Jun 27 05:11:02 [initandlisten] removeJournalFiles
Thu Jun 27 05:11:02 [initandlisten] shutdown: removing fs lock...
Thu Jun 27 05:11:02 dbexit: really exiting now
However, when I tried to run MongoDB by typing mongo even without running its daemon, it seems that I can use MongoDB successfully. I don't start any daemon and also I have only one window in my terminal, so it would be impossible to run both daemon and main mongo program at the same time...
So the question is, why I can use MongoDB without starting any daemon process? When I use MongoDB on OS X, I always have to run daemon before using MongoDB. For your information I installed Ubuntu 13.04 via Parallels 8 on my OS X 10.8 and installed MongoDB by going with the same route as an official document explains.
Or since I use MongoDB on my OS X at port 27017, I don't have to run daemon on Virtual Ubuntu? (though I don't run daemon on OS X right now...)

When you installed mongo, it should already have run the server for you.
This is confirmed by both the fact that it says "addr already in use" (which means something is running on the mongod port) and the fact that you can use it successfully.
You can also test this by running ps wuax | grep mongo and looking for mongod in the resulting list - this list all the processes running on your computer, and then removes from this list anything that doesn't mention mongo. You may also see a line which has "grep" in it - this is the command you are currently running, which you can ignore.
When I run this on my computer, it shows:
mongodb 22394 9.1 1.0 109244 33592 ? Dsl 08:29 0:01 /usr/bin/mongod --config /etc/mongodb.conf
1001 22423 0.0 0.0 9436 904 pts/3 S+ 08:29 0:00 grep --color=auto mongo

Mongod service is running, try to stop it and init mongod with sudo command
sudo service mongodb stop
sudo mongod

Start mongod Processes
By default, MongoDB stores data in the /data/db directory. On Windows, MongoDB stores data in C:\data\db. On all platforms, MongoDB listens for connections from clients on port 27017.
To start MongoDB using all defaults, issue the following command at the system shell:
mongod
Stop mongod Processes
In a clean shutdown a mongod completes all pending operations, flushes all data to data files, and closes all data files. Other shutdowns are unclean and can compromise the validity of the data files.
To ensure a clean shutdown, always shutdown mongod instances using one of the following methods:
Use shutdownServer()
Shut down the mongod from the mongo shell using the db.shutdownServer() method as follows:
use admin
db.shutdownServer()
Calling the same method from a init script accomplishes the same result.
For systems with authorization enabled, users may only issue db.shutdownServer() when authenticated to the admin database or via the localhost interface on systems without authentication enabled.
Use --shutdown
From the Linux command line, shut down the mongod using the --shutdown option in the following command:
mongod --shutdown

Related

I can start the MongoDB shell, but not Mongo Daemon

I'm new to MongoDB, and I'm trying to run mongod. If I type in mongo, I can run the shell (and then I exit nicely with ^C), but when I try typing mongod, I get this:
mongod --help for help and startup options
Sat Nov 24 13:42:34 [initandlisten] MongoDB starting : pid=99910 port=27017 dbpath=/data/db/ 64-bit host=Macbook-err.local
Sat Nov 24 13:42:34 [initandlisten]
Sat Nov 24 13:42:34 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
Sat Nov 24 13:42:34 [initandlisten] db version v2.2.1, pdfile version 4.5
Sat Nov 24 13:42:34 [initandlisten] git version: nogitversion
Sat Nov 24 13:42:34 [initandlisten] build info: Darwin 172-26-13-128.dynapool.nyu.edu 12.2.0 Darwin Kernel Version 12.2.0: Sat Aug 25 00:48:52 PDT 2012; root:xnu-2050.18.24~1/RELEASE_X86_64 x86_64 BOOST_LIB_VERSION=1_49
Sat Nov 24 13:42:34 [initandlisten] options: {}
Sat Nov 24 13:42:34 [initandlisten] journal dir=/data/db/journal
Sat Nov 24 13:42:34 [initandlisten] recover : no journal files present, no recovery needed
Sat Nov 24 13:42:34 [websvr] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:28017
Sat Nov 24 13:42:34 [websvr] ERROR: addr already in use
Sat Nov 24 13:42:34 [initandlisten] ERROR: listen(): bind() failed errno:48 Address already in use for socket: 0.0.0.0:27017
Sat Nov 24 13:42:34 [initandlisten] ERROR: addr already in use
Sat Nov 24 13:42:34 [initandlisten] now exiting
Sat Nov 24 13:42:34 dbexit:
Sat Nov 24 13:42:34 [initandlisten] shutdown: going to close listening sockets...
Sat Nov 24 13:42:34 [initandlisten] shutdown: going to flush diaglog...
Sat Nov 24 13:42:34 [initandlisten] shutdown: going to close sockets...
Sat Nov 24 13:42:34 [initandlisten] shutdown: waiting for fs preallocator...
Sat Nov 24 13:42:34 [initandlisten] shutdown: lock for final commit...
Sat Nov 24 13:42:34 [initandlisten] shutdown: final commit...
Sat Nov 24 13:42:34 [initandlisten] shutdown: closing all files...
Sat Nov 24 13:42:34 [initandlisten] closeAllFiles() finished
Sat Nov 24 13:42:34 [initandlisten] journalCleanup...
Sat Nov 24 13:42:34 [initandlisten] removeJournalFiles
Sat Nov 24 13:42:34 [initandlisten] shutdown: removing fs lock...
Sat Nov 24 13:42:34 dbexit: really exiting now
This seems to be a common problem around here, and I've tried:
deleting the mongod.lock file rm /data/db/mongod.lock
repair: mongod --repair
killing processes: killall -15 mongod and killall -9 mongod
I tried changing permissions: sudo chmod 0755 /data/db and sudo chown $USER /data/db
My permissions seem correct:
drwxr-xr-x 4 slaffont wheel 136 Nov 24 13:28 /data/db/
I've run out of ideas. Has anyone else had this problem? What should I do? :(
From your main comments, it seems you installed MongoDB via macports (given the /opt install location). What I believe might be happening is that the recipe for macports installed MongoDB as a launchd service.
Check this location for a mongodb related plist file: /Library/LaunchDaemons
If you find it, that means your system will automatically keep this service running. If you only want to run the mongod manually, then remove this plist and reboot. Or you can try this command:
launchctl unload /Library/LaunchDaemons/path.to.mongo.plist
Otherwise, run another instance of mongod on a different port.
sudo rm /var/lib/mongodb/mongod.lock
sudo chown -R mongodb:mongodb /var/lib/mongodb/
sudo -u mongodb mongod -f /etc/mongodb.conf --repair
sudo service mongodb start
or instead of the last one try : sudo mongod
"Address already in use for socket: 0.0.0.0:28017"
It looks like mongo is already running or another process is using port 27017
In this case, type the following command
ps wuax | grep mongo
You should see something that looks like this
User 31936 0.5 0.4 2719784 35624 ?? S 7:34pm 0:09.98 mongod
User 31945 0.0 0.0 2423368 184 s000 R+ 8:24pm 0:00.00 grep mongo
Now enter the kill command for the mongod instance (31936 in this case):
kill 31936
It looks like something is already bound to port 27017, making it seem like another mongod is running (that was not killed on the killall). Does the output of ps aux or lsof -i :27017 show any mongod processes running?
If this proves completely fruitless, you can always pass the --port <portnum> option to the mongod process via the command line, telling it to listen on a different port (use the same option for the mongo shell to tell it to connect on a different port than 27017.
As #shelman said, you already have something using that port, however your command to understand if something is running is wrong, try:
sudo netstat -lpn |grep :27017
I have noticed as well:
Sat Nov 24 13:42:34 [initandlisten] ** WARNING: soft rlimits too low. Number of files is 256, should be at least 1000
This is more of an warning but still one you should heed. I answered a question with some one who had this problem recently: Mongod runs, but Mongo returns an error that should help.
Since this seems to be a common question:
As someone who just had/solved this problem, what you're probably running into is this. When you first install Mongo (say, via apt-get), the Mongod process automatically starts running. For example:
terekhov / $ sudo apt-get install mongodb-10gen
--Snip Install Process--
Done. mongodb
start/running, process 4467 Processing triggers for ureadahead ...
terekhov / $ service mongodb start start: Job is already running: mongodb
So, if you don't need a forked daemon etc, then just type mongo to start the command shell; it will automatically search for a MongoDB daemon on port 27017. Happily, that's where ours is.
You can start/stop/restart the mongod process with this command: sudo service mongodb stop

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

Getting an error, "Error: couldn't connect to server 127.0.0.1 shell/mongo.js" & when trying to run mongodb on mac osx lion

I am using Mac OS X Lion and i just did a fresh install of MongoDB using macports and when i try to run mongodb for the first time i get the following error
MongoDB shell version: 2.0.5
connecting to: test
Fri Jun 1 11:20:33 Error: couldn't connect to server 127.0.0.1 shell/mongo.js:84
exception: connect failed
can anybody please help with this? thanks
when i run mongod i get:
hisham-agil:~ hisham$ mongod
mongod --help for help and startup options
Fri Jun 1 11:24:47 [initandlisten] MongoDB starting : pid=53452 port=27017 dbpath=/data/db/ 64-bit host=hisham-agil.local
Fri Jun 1 11:24:47 [initandlisten] db version v2.0.5, pdfile version 4.5
Fri Jun 1 11:24:47 [initandlisten] git version: nogitversion
Fri Jun 1 11:24:47 [initandlisten] build info: Darwin gamma.local 11.3.0 Darwin Kernel Version 11.3.0: Thu Jan 12 18:48:32 PST 2012; root:xnu-1699.24.23~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_49
Fri Jun 1 11:24:47 [initandlisten] options: {}
Fri Jun 1 11:24:47 [initandlisten] exception in initAndListen: 10296 dbpath (/data/db/) does not exist, terminating
Fri Jun 1 11:24:47 dbexit:
Fri Jun 1 11:24:47 [initandlisten] shutdown: going to close listening sockets...
Fri Jun 1 11:24:47 [initandlisten] shutdown: going to flush diaglog...
Fri Jun 1 11:24:47 [initandlisten] shutdown: going to close sockets...
Fri Jun 1 11:24:47 [initandlisten] shutdown: waiting for fs preallocator...
Fri Jun 1 11:24:47 [initandlisten] shutdown: lock for final commit...
Fri Jun 1 11:24:47 [initandlisten] shutdown: final commit...
Fri Jun 1 11:24:47 [initandlisten] shutdown: closing all files...
Fri Jun 1 11:24:47 [initandlisten] closeAllFiles() finished
Fri Jun 1 11:24:47 dbexit: really exiting now
You're running the mongo client without starting the server first. Try running mongod first.
You'll have to specify where the mongo "workspace" is using the --dbpath switch, such as mongod --dbpath /mongo/db. The specified folder should exist.
By default mongod will try to use the directory /data/db for the database files.
In your case that directory does not exist.
Before starting mongod you should create those directories and make sure they are writable by the same user that is running mongod process.
I deleted /data/db/mongod.lock to solve the problem.
I had the same issue on my mac. Try,
sudo chown -R id -u /data/db
Then start the daemon specifying your dbpath /data/db, as in bdares post above. This worked for me.

MongoDB Data disappeared

I just had to do an emergency reboot of my linux server. I did it gracefully, not a hard reboot. I have been gathering data through a node.js app for a month, but when the server started up again, all the data was gone!
I have a long log file: http://clintberry.com/mongod.log
I also ran a repair to see if it would help but to no avail.
New Development
It looks like I was running mongo with the command 'service mongod start' and when I try to run that command again, I get this:
**************
old lock file: /var/lib/mongo/mongod.lock. probably means unclean shutdown recommend
removing file and running --repair see: http://dochub.mongodb.org/core/repair
for more information
*************
So that means the repair I was trying was not working since I wasn't using the correct config file.
When I run repair with the correct config file it doesn't seem to run repair, just spits out this:
root#es2 [/var/log/mongo]# mongod --dbpath /var/lib/mongo/ --repair
Wed Nov 30 12:09:40 [initandlisten] MongoDB starting : pid=26916 port=27017 dbpath=/var/lib/mongo/ 64-bit
Wed Nov 30 12:09:40 [initandlisten] db version v1.8.4, pdfile version 4.5
Wed Nov 30 12:09:40 [initandlisten] git version: 81f12749a15e3d158b1b16bab6bc3faea538e166
Wed Nov 30 12:09:40 [initandlisten] build sys info: Linux bs-linux64.10gen.cc 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_41
**************
old lock file: /var/lib/mongo/mongod.lock. probably means unclean shutdown
recommend removing file and running --repair
see: http://dochub.mongodb.org/core/repair for more information
*************
Wed Nov 30 12:09:40 [initandlisten] exception in initAndListen std::exception: old lock file, terminating
Wed Nov 30 12:09:40 dbexit:
Wed Nov 30 12:09:40 [initandlisten] shutdown: going to close listening sockets...
Wed Nov 30 12:09:40 [initandlisten] shutdown: going to flush diaglog...
Wed Nov 30 12:09:40 [initandlisten] shutdown: going to close sockets...
Wed Nov 30 12:09:40 [initandlisten] shutdown: waiting for fs preallocator...
Wed Nov 30 12:09:40 [initandlisten] shutdown: closing all files...
Wed Nov 30 12:09:40 closeAllFiles() finished
Wed Nov 30 12:09:40 dbexit: really exiting now
As mpobrien's comment suggested, the issue was that when starting mongo it was using a different dbpath (location for the data). For those that have mongo installed on CentOS, if you use the service command to start mongo,
service mongod start
then mongo will use the configuration file /etc/mongo.conf when starting, which puts your dbpath as /var/lib/mongo
but if you start mongo with the regular mongod command, it will not use that folder and will use the mongo default.
Thanks for the help.

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