Why MongoDB does not start in Fedora ? [SOLVED]


Hello guys,

Today I want to share with you how to easily make MongoDB work in Fedora. Recently, while moving to F19 I have faced the issue when my Mongo does not start. What I mean by does not start ?

[aspektor@localhost routes]$ mongo
MongoDB shell version: 2.4.3
connecting to: test
Tue Jun 11 16:07:26.273 JavaScript execution failed: Error: couldn't connect to server 127.0.0.1:27017 at src/mongo/shell/mongo.js:L112
exception: connect failed

Also when I try to start service:

[aspektor@localhost routes]$ service mongod start
Starting mongod (via systemctl):  Failed to issue method call: Access denied
[FAILED]

The main thing here is:

DO NOT PANIC 🙂

I even put it in green, because green  suppose to be the  most relaxing colour :))))

The problem lies in SELinux , disallowing access to MongoDB. I have tried setting SELinux to permissive, and one time it worked, but it didn’t the other time. And frankly saying, you don’t want your SELinux to be in Permissive mode.

So what you need to do is to create a policy allowing Mongo to access your system.

SELinux provides you with these 2 commands:


[root@localhost routes]$ grep mongod /var/log/audit/audit.log | audit2allow -M mypol
******************** IMPORTANT ***********************
To make this policy package active, execute:

semodule -i mypol.pp

[root@localhost routes]$ semodule -i mypol.pp1

If you are still curious where did I get this commands from – I got them right from SELinux  (image clickable):

Mongo SELinux

After setting the new policy that allow mongo, just try to start it again:

[root@localhost routes] exit
[aspektor@localhost routes]$ mongo
MongoDB shell version: 2.4.3
connecting to: test

Let me know if it worked for you!

Cheers,

Anatoly

Advertisements

About Anatoly Spektor

My name is Anatoly Spektor (originally Anatolijs Spektors) I am Software and Web Developer. I have worked in Seneca Center for Development of Open Technology on Big Blue Button Add-on - Polling Module, Red Hat and some other places :) I am an author of the book 'Eclipse Debugging How To', Muay Thai fighter and amateur photographer ;)
This entry was posted in Fedora, MongoDB, OS and tagged , , , , , . Bookmark the permalink.

2 Responses to Why MongoDB does not start in Fedora ? [SOLVED]

  1. shailesh says:

    thanks Anatoly,

  2. aseds says:

    hi, i ran the command “grep mongod ……. mypol” , it said: permission denied.
    so i used sudo with the command, now it says: Nothing to do.
    and the problem persists.. 😦

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s