Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Cannot restart mongodb on Ubuntu 11.04

Tags:

mongodb

I have installed mongodb and when i typing the following command i am getting these messages

root@amila:~# service mongodb status    
mongodb stop/waiting
root@amila:~# service mongodb restart    
restart: Unknown instance:     
root@amila:~# service mongodb stop    
stop: Unknown instance: 

I want to restart mongodb.but unable to restart.

EDIT: here is the /etc/mongodb.conf

dbpath=/var/lib/mongodb logpath=/var/log/mongodb/mongodb.log

logappend=true

bind_ip = 127.0.0.1
auth = true

like image 763
Amila Avatar asked Apr 09 '12 11:04

Amila


2 Answers

Given the output of the start command, this is starting correctly. When you are running status, it seems to have been stopped. You need to look into the log file:

/var/log/mongodb/mongodb.log

That will tell you why the mongod is stopping. There are a couple of likely causes, but without seeing that output it will be hard to answer definitively. My general recommendations:

  1. Do not use bind_ip - it is a bad idea in general Update (2016): Removing this because the issues with bind_ip that caused me to write this back in 2012 have been fixed, and it is even on by default in official packages now. Worth trying without the setting as a troubleshooting step, but not a bad idea to use it in general.
  2. Check for something else running on port 27017
  3. Specify the port explicitly in the mongodb.conf file, even if you want to use the default

Finally, take a look at this answer for how to fix file permissions, just in case that is a problem (usually caused by running as root at some point):

mongodb crashes after unexpected shutdown

like image 124
Adam Comerford Avatar answered Oct 06 '22 04:10

Adam Comerford


Sorry if you consider this "SO archeology".

I don't know if this is the same issue, but I'm facing something similiar right now. End of my log:

Mon Nov 19 10:25:37 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
Mon Nov 19 10:25:37 dbexit: 
Mon Nov 19 10:25:37 [initandlisten] shutdown: going to close listening sockets...
Mon Nov 19 10:25:37 [initandlisten] shutdown: going to flush diaglog...
Mon Nov 19 10:25:37 [initandlisten] shutdown: going to close sockets...
Mon Nov 19 10:25:37 [initandlisten] shutdown: waiting for fs preallocator...
Mon Nov 19 10:25:37 [initandlisten] shutdown: lock for final commit...
Mon Nov 19 10:25:37 [initandlisten] shutdown: final commit...
Mon Nov 19 10:25:37 [initandlisten] shutdown: closing all files...
Mon Nov 19 10:25:37 [initandlisten] closeAllFiles() finished
Mon Nov 19 10:25:37 dbexit: really exiting now

So I think the lock file is not closed properly (for example when shutting down). You should use

mongod --repair

But it didn't work for me, so I just removed /var/lib/mongodb/mongod.lock and then started the server. This is not the secure way, and there is possibility, that data in your database is corrupt if you do so.

like image 23
warran Avatar answered Oct 06 '22 03:10

warran