Take the 2-minute tour ×
Unix & Linux Stack Exchange is a question and answer site for users of Linux, FreeBSD and other Un*x-like operating systems.. It's 100% free, no registration required.

I used these instructions to install mongodb on my OS X machine. I did not make the files owned by root though, I used my local user (markdsievers), and installed to /usr/local/mongodb and usr/local/mongodb_data. I've chmod'ed and chown'ed all files and subdirectories of those to rwxrwxr-x markdsievers staff.

As user markdsievers I can start up the database without error using:

$ sudo mongod --dbpath=/usr/local/mongodb_data

However, if I start it with:

$ mongod --dbpath=/usr/local/mongodb_data/

I get:

Unable to create / open lock file for lockfilepath: /usr/local/mongodb_data/mongod.lock errno:13 Permission denied

What am I missing here?

share|improve this question
    
The directory /usr/local/mongodb_data itself must be writable by the user running mongod. Is it? –  Gilles Jul 10 '11 at 21:53
    
Hi, it is; drwxrwxr-x 8 markdsievers staff 272 11 Jul 06:30 mongodb drwxrwxrwx 6 markdsievers staff 204 11 Jul 06:55 mongodb_data –  markdsievers Jul 10 '11 at 22:30

2 Answers 2

up vote 3 down vote accepted

First, an aside: storing your mongo data in /usr/local/mongodb_data seems a little strange; most behind-the-scenes storage is in /var/, or, for self-installed applications, /var/local/. See hier(7) or the Filesystem Hierarchy Standard for more details. (The FHS is mis-named: because it is descriptive, not prescriptive, it is not a standard. But it is worth reading.)

Your mongodb.lock file is owned by root because you executed:

sudo mongod --dbpath=/usr/local/mongodb_data

sudo(8) executes programs with a different effective user id (see seteuid(2), setreuid(2) for details). Because you didn't specify any other user with a -u option, sudo(8) defaulted to the root account. Thus, your lock file was created with root owner and group. (Compare sudo id with id to see what changes.)

What is strange though, is that the lock file should have been removed when you stop the mongod database. Be sure you're stopping it properly -- not only so the lock files are removed -- but also so you know data has been properly saved to disk.

share|improve this answer

Do an ls -l /usr/local/mongodb_data/mongod.lock

I bet that since you ran first as user "root", that file already exists, and owned by root. Delete it and I bet it works as user "markdsievers".

share|improve this answer
    
Doh - right you are, the mongodb.lock was owned by root. One question though - I don't understand your use of "mongodb user". I thought executing a binary it would handle files as the user who spawned it, ie markdsievers? –  markdsievers Jul 10 '11 at 22:50
    
@BruceEdiger To delete a comment, hover your mouse over it and click on the × that appears on the right. –  Gilles Jul 15 '11 at 18:26

Your Answer

 
discard

By posting your answer, you agree to the privacy policy and terms of service.

Not the answer you're looking for? Browse other questions tagged or ask your own question.