Home:ALL Converter>mongodb data directory permissions

mongodb data directory permissions

Ask Time:2011-05-12T13:49:59         Author:Mark Gill

Json Formatter

Earlier i was storing all the mongodb data files in /var/lib/mongodb directory..and the dbpath entry in /etc/mongodb.conf was /var/lib/mongodb..

Now i want to change the data directory to /vol/db..so I created the directory /vol/db and changed the permissions using sudo chown -R id -u /vol/db and changed the db path entry to /vol/db in /etc/mongodb.conf

now when i start the mongodb using sudo service mongodb start..i am getting this error in /var/log/mongodb/mongodb.log

http://pastebin.com/C0tv8HQN

i need help..where I am wrong?

Author:Mark Gill,eproduced under the CC 4.0 BY-SA copyright license with a link to the original source and this disclaimer.
Link to original article:https://stackoverflow.com/questions/5973811/mongodb-data-directory-permissions
kaezarrex :

I was having the same problem, but was able to solve it thanks to a similar question. You need to make sure that /vol/db/ is owned by mongodb.\n\nsudo chown -R mongodb:mongodb /vol/db/\n\n\nIf you get the error chown: invalid user: 'mongodb:mongodb', check /etc/passwd to see if there is a similar user that exists (ex. mongod).",
2012-03-14T15:07:27
Federico Giust :

The easiest would be\n\nsudo chmod 777 /data/db\n",
2014-04-17T20:31:55
calmrat :

If after changing permissions and ownership of the new db path, you're still seeing this issue, run getenforce to see if you are using a system with SELinux running in enforce mode.\nIf getenforce returns 'enforcing', it's likely selinux is the cause of the permissions error, since mongodb is now running outside it's original context scope since the db location changed out of /var/lib/... \n\nI don't know the details, but a brute force way then to resolve the issue without writing your own selinux policy for the new context is to simply turn off selinux :-/\n\nsudo setenforce 0\n\n\nIdeally, you'd figure out how to update the selinux policy if you're planning to run in production.",
2013-06-11T12:57:32
Mohsen Shamohamadi :

I suggest to check what is the error by reading mongo log\n\ntail -50 /var/log/mongodb/mongodb.log\n\n\nyou can immediately find the problem(including permission ones)",
2016-09-06T05:55:52
yy