Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

mongodb data directory permissions

Tags:

mongodb

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?

like image 415
Mark Gill Avatar asked May 12 '11 05:05

Mark Gill


People also ask

Where is mongodb data directory?

Install MongoDB On Windows The default location for the MongoDB data directory is c:\data\db. So you need to create this folder using the Command Prompt.

How do I change directory in mongodb?

Copy the data folder of your mongodb to the new location - cp -R /var/lib/mongodb/ /mnt/database/ Remove the old database folder - rm -rf /var/lib/mongodb/ Create symbolic link to the new database folder - ln -s /mnt/database/mongodb /var/lib/mongodb.

In which directory does mongodb writes data by default?

The default dbpath for mongodb is /data/db .


2 Answers

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.

sudo chown -R mongodb:mongodb /vol/db/ 

If you get the error chown: invalid user: 'mongodb:mongodb', check /etc/passwd to see if there is a similar user that exists (ex. mongod).

like image 120
kaezarrex Avatar answered Sep 18 '22 16:09

kaezarrex


The easiest would be

sudo chmod 777 /data/db 
like image 40
Federico Giust Avatar answered Sep 20 '22 16:09

Federico Giust