Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

MongoDB service not working after upgrade to Ubuntu 15.04

I have recently upgraded my ubuntu from 14.10 to 15.04. All features seems to be working fine except MongoDB. I am using mongoDB with ruby on rails application using Mongoid gem. MongoDB is not controllable from service as we do normally in ubuntu.

sudo service mongodb start

or

sudo service mongod start

I get this error message

Failed to restart mongod.service: Unit mongod.service failed to load: No such file or directory.

But i have to start it manually each time i have to connect my application to MongoDB server using

sudo mongod -f /etc/mongod.conf

So mongodb is connected as long as that terminal is opened. I am using MongoDB in Ruby on Rails application using Mongoid adapater/ORM.

When i run

sudo service mongodb status

i get following output

mongodb.service - An object/document-oriented database
Loaded: loaded (/lib/systemd/system/mongodb.service; enabled; vendor preset: enabled)
Active: failed (Result: exit-code) since بدھ 2015-05-06 14:47:53 PKT; 5s ago
Docs: man:mongod(1)
Process: 28602 ExecStart=/usr/bin/mongod --config /etc/mongodb.conf (code=exited, status=4)
Main PID: 28602 (code=exited, status=4)

مٓی 06 14:47:53 NX00443 systemd[1]: Started An object/document-oriented database.
مٓی 06 14:47:53 NX00443 systemd[1]: Starting An object/document-oriented database...
مٓی 06 14:47:53 NX00443 systemd[1]: mongodb.service: main process exited, code=exited, status=4/NOPERMISSION
مٓی 06 14:47:53 NX00443 systemd[1]: Unit mongodb.service entered failed state.
مٓی 06 14:47:53 NX00443 systemd[1]: mongodb.service failed.

Any help in this regard will be appreciated.

like image 760
Shahzad Tariq Avatar asked May 04 '15 07:05

Shahzad Tariq


3 Answers

It turns out that Mongo>2.6.3 has a known issue with start:

Support Systemd (cannot start mongodb with init scripts with Fedora 15 or above)

As noted here: in this link and it seems that this possibly won't be fully fixed for >2.6.3 until Ubuntu 16.04, unless there is a strong outcry.

So the solution is to issue:

sudo apt-get install --reinstall mongodb

This reverted back to mongo 2.6.3 and NOW ALL WORKS! For those that run across this...

like image 55
Abdul Baig Avatar answered Oct 17 '22 22:10

Abdul Baig


You need to change the path configuration of the db:

for example in the file "/etc/mongod.conf" set "dbPath: /data/db"

You need to give the right to mongodb user to access this path:

sudo chown -R mongodb /data/db
like image 31
Fabien Thetis Avatar answered Oct 18 '22 00:10

Fabien Thetis


The above solution works for me too:

> sudo apt-get install --reinstall mongodb

I've tried several methods that I found in this site and other sites, but only this one works for me! So, for now, back to Mongodb 2.6.3!

Update: problem fixed (2015/8/2 14:39): I just found out that MongoDB 3.0.5 is released, so I purged version 2.6.3 and tried to install 3.0.5 on my Ubuntu 15.04. But the problem remains! However, after I reintalled it with the Debian wheezy package instead, finally the sudo service mongod start command works (it didn't work when I install 3.0.4 debian wheezy version). Now the new MongoDB 3.0.5 is running fine on my Ubuntu 15.04!

To install Debian wheezy version, please refer to the official installation guide on MongoDB: http://docs.mongodb.org/manual/tutorial/install-mongodb-on-debian/

like image 3
Tom Liao Avatar answered Oct 17 '22 22:10

Tom Liao