Mongod does not start using conf files

So i am attempting to start mongod using the configuration files. csrs_1.conf is created as per the lecture notes from chapter 3 Sharding, Setting up a Sharded cluster.

Contents of csrs_1.conf ,

sharding:
  clusterRole: configsvr
replication:
  replSetName: m103-csrs
security:
  keyFile: /var/mongodb/pki/m103-keyfile
net:
  bindIp: localhost,192.168.103.100
  port: 26001
systemLog:
  destination: file
  path: /var/mongodb/db/csrs1.log
  logAppend: true
processManagement:
  fork: true
storage:
  dbPath: /var/mongodb/db/csrs1

On executing mongod -f csrs_1.conf i get the following error,

about to fork child process, waiting until server is ready for connections.
forked process: 2278
ERROR: child process failed, exited with error number 1
To see additional information in this output, start without the "--fork" option.  

So i did a bit of googling and the problem seems to be something to do with file/folder permissions. So i went and changed file and folder permissions to the conf and log files but to no avail . Please do have a look at the attachment which shows the current state of permissions. Your input appreciated.

Thank you.

First up, it’s great that you showed this initiative! And your screenshot does in fact look alright, although there is one important detail missing: the permissions on the directory itself! Try running “ls -al /var/mongodb/db/*”. This will also show the permissions on “.”, the directory itself.

But let’s also go back to basics :slight_smile: What does the MongoD tell you when you in fact leave off the “–fork”? It should show you exactly which files and/or directories it can’t work with.

1 Like

Since the vagrant shell (aka the Linux shell and more specifically GNU bash shell running on the Ubuntu Linux VM :sunglasses: ) present ~/var/mongodb/db$ in the path part of the prompt, I suspect that the directory is in fact /home/vagrant/var/mongodb/db rather than /var/mongodb/db as specified in the configuration files.

4 Likes

Hi there,

So executing > ls -al /var/mongodb/db/* gave a list of permissions for the contents of the entire directory. I am not sure which directory/file you want me to check. As for leaving out —fork I did try that and nothing seems to happen. I did set the fork parameter to false as well but no output i.e no errors or messages when executing mongod -f csrs_1.conf.

I am executing mongod -f csrs_1.conf from the root directory. That’s where the configuration files are.

:face_with_raised_eyebrow: Huh?

Are you saying you’re storing your config in “/”? So you run: mongod -conf /csrs_1.conf?

I don’t think “root directory” means what you think it does :slight_smile:

When it comes to starting MongoD (and many other things) it is always best to specify the full path to files. What you are doing right now (mongod -f csrs_1.conf) is leaving off any and all path information, meaning that Mongo will search for the file in your current working directory. That’s not a good idea, both for security and for sanity.

I meant for you to verify that the vagrant user actually has access to that particular directory and whether it can write in there.

Thanks for clearing that up. Correct the conf are not in the root directory but in vagrant. So i edited the /var/ to var/ in the conf files. It is working now. Appreciate the help guys.

So @steevej-1495 was right.

Steeve, your attention to detail is awesome.

1 Like

Thanks @Tess_Sluijter, that’s one good thing for being old. I already seen all those errors made before. By the way, the smiley about the name of the shell was just for you. I wanted to be more pedantic than you. :wink:

2 Likes

Hi @steevej-1495 and friends, my case is that I put my csrs1.conf file inside the shared folder, then I (cheat-ly?) do readlink -f csrs1.conf and it says /home/vagrant/csrs1.conf so I guess when I put files into shared, they get to root of vagrant…

Mmm still can’t make my csrs files to work, although my previous replica set config files still work using the same shared folder, mongod -f /shared/mongod-repl-1.conf works, but mongod -f /shared/csrs1.conf doesn’t…

Wow, I think I got it, as first I did chmod -R 755 /var/mongodb/db/csrs1 and then I fired off my mongod -f /shared/csrs1.conf and now it did forked well, also pgrep shows it, yes! Well of course, I had to create that directory first…

1 Like

Thank you for posting your solution @maulberto3!!! You (along with everyone who has taken the time to post here) have saved me hours of confusion and troubleshooting!

@juliettet you are welcome, I just had such a hard time trying to figure out what was I doing wrong, that once I got it, I had to share it!

1 Like