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):
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
Tagged: error, Fedora, Fedora 19, Mongo no start, MongoDB, SELinux