When I run "/usr/bin/mongod –config /var/data/rs1/rs1db0v3.conf". It failes. The error is:
warning: bind_ip of 0.0.0.0 is unnecessary; listens on all ips by default
about to fork child process, waiting until server is ready for connections.
forked process: 16970
ERROR: child process failed, exited with error number 1
The permission of the relative files and folds are following:
drwxr-xr-x 6 root root 115 Mar 16 14:47 .
drwxr-xr-x 5 root root 43 Jan 20 12:12 ..
drwxr-xr-x 6 mongodb mongodb 4096 Mar 16 15:05 db
drwxr-xr-x 2 root root 28 Jan 20 10:04 keys
drwxr-xr-x 2 mongodb mongodb 23 Jan 20 10:32 log
-rwxr-xr-x 1 mongodb mongodb 593 Mar 16 14:47 rs1db0v3.conf
-rwxr-xr-x 1 mongodb mongodb 21303832 Mar 3 08:03 /usr/bin/mongod
I found similar questions in this website, but no answers can help me…
—–SOLVED—–
I have no idea how to run mongod as mongodb, so I changed the ownership to user1, and then run mongod as user1. It works.
drwxr-xr-x 6 root root 115 Mar 16 14:47 .
drwxr-xr-x 5 root root 43 Jan 20 12:12 ..
drwxr-xr-x 6 user1 mongodb 4096 Mar 16 15:05 db
drwxr-xr-x 2 root root 28 Jan 20 10:04 keys
drwxr-xr-x 2 user1 mongodb 23 Jan 20 10:32 log
-rwxr-xr-x 1 user1 mongodb 593 Mar 16 14:47 rs1db0v3.conf
-rwxr-xr-x 1 user1 mongodb 21303832 Mar 3 08:03 /usr/bin/mongod
Best Answer
First of all when you run mongod as a normal user you need to make sure that the particular user has the following permissions:
All of the above are automatically set and granted for the user mongodb (mongod in earlier versions). If you take a look at /etc/init.d/mongodb you will see that the service will be stared under the user mongodb DAEMONUSER=${DAEMONUSER:-mongodb} and not as root.