MongoD cannot open mongod.log

4,819 views
Skip to first unread message

Sheldon

unread,
Mar 19, 2012, 6:20:44 PM3/19/12
to mongod...@googlegroups.com
I set-up an AWS instance following the instructions here:

http://www.mongodb.org/display/DOCS/Amazon+EC2+Quickstart#AmazonEC2Quickstart-ConnectToMongoDB

When I attempt to run MongoD I get the following error:

[ec2-user@<the instance ip> ~]$ sudo /etc/init.d/mongod start
Starting mongod: can't open [/var/log/mongo/mongod.log] for log file: errno:13 Permission denied [FAILED]

"ls -la /var/log/mongo/" gives the following:

drwxr-xr-x 2 mongod mongod 4096 Mar 19 17:41 .
drwxr-x--- 10 root   root   4096 Mar 19 17:41 ..
-rw-r-----  1 mongod mongod    0 Feb 28 18:34 mongod.log

The permissions look correct.  Any idea why MongoD cannot access the log file?

Scott Hernandez

unread,
Mar 19, 2012, 11:14:27 PM3/19/12
to mongod...@googlegroups.com
Always best to su to the user and try manually to verify permissions.

Are you sure your init script is running as mongod?

Looks like that user can't read from /var/log/ (if I'm reading it
right on my tiny phone screen).

> --
> You received this message because you are subscribed to the Google Groups
> "mongodb-user" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/mongodb-user/-/4zWBx9s31R8J.
> To post to this group, send email to mongod...@googlegroups.com.
> To unsubscribe from this group, send email to
> mongodb-user...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/mongodb-user?hl=en.

Wes Freeman

unread,
Mar 19, 2012, 11:24:20 PM3/19/12
to mongod...@googlegroups.com
Yeah, you need execute permissions on the folder that the file is in,
in order to write to files there. mongod looks like it doesn't have
that for /var/log/

Wes

Timothy Hawkins

unread,
Mar 20, 2012, 12:13:35 AM3/20/12
to mongod...@googlegroups.com, mongod...@googlegroups.com
Why do you need execute? , wont write do?

Sent from my iPad

Wes Freeman

unread,
Mar 20, 2012, 12:27:44 AM3/20/12
to mongod...@googlegroups.com
Execute permissions on a directory allow you to list the files there,
which is needed to be able to open the file for writing, among other
things. And you need that permission on directories all the way up the
path.

Wes

Sheldon

unread,
Mar 20, 2012, 12:31:09 PM3/20/12
to mongod...@googlegroups.com
Thank-you for the feedback.  Permissions on the parent folder was my issue.  I had assumed that the user 'mongod' had rights to access /var/log/mongo/, even though the parent directory (/var/log/) was owned by root.  I executed "chmod 755 ." in /var/log/ and mongod now runs without error.


>>>> For more options, visit this group at
>>>> http://groups.google.com/group/mongodb-user?hl=en.
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
>>> To post to this group, send email to mongod...@googlegroups.com.

>>> To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.


>>> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
>> To post to this group, send email to mongod...@googlegroups.com.

>> To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.


>> For more options, visit this group at http://groups.google.com/group/mongodb-user?hl=en.
>>
>
> --
> You received this message because you are subscribed to the Google Groups "mongodb-user" group.
> To post to this group, send email to mongod...@googlegroups.com.

> To unsubscribe from this group, send email to mongodb-user+unsubscribe@googlegroups.com.

Reply all
Reply to author
Forward
0 new messages