Lab - Configuration File - Command to Use Config File Does Nothing

Lab - Configuration File

I am not able to start my configuration file. I have saved the file in the shared directory and my vagrant shell can properly read from it. Here are the contents of my config file:

systemLog:
destination: file
path: “data/log/mongo.log”
logAppend: true
storage:
dbPath: “/data/db”
security:
authorization: “enabled”
replication:
replSetName: “M103”
net:
bindIp : 127.0.0.1,192.168.0.100
port: 27000

Whenever I use the command as described in the lab “mongod --config /shared/config.cfg”, I get no results on the command prompt, as shown below:

image

It is as if the command immediately exits, for one reason or another.

I see one issue with your config file. The value of path: should probably be /data/log/mongo.log. You are missing the leading slash. However it is possible that it works like this depending of where is the data directory and that mongod is simply awaiting connection. You could try to connection with mongo --port 270000. Could you please share the output the following commands?

cat data/log/mongo.log
ls -l /data
ls -l data
ss -tln
ps -aef | grep mongod | grep -v mongod

ls -l /data

ss -tln

ps -aef | grep mongod | grep -v mongod

image

Please verify you configuration file.

I do not think that 192.168.0.100 is the address that the instructions ask you to use. I don’t even think that it is a valid address.

I would also change path: to use /data/log/… rather than data/log/…. With data/log the exact location is dependent of your current directory. With /data/log it is always at the same place.

systemLog:
destination: file
path: “/data/log/mongo.log”
logAppend: true
storage:
dbPath: “/data/db”
security:
authorization: “enabled”
replication:
replSetName: “M103”
net:
bindIp : 127.0.0.1,192.168.103.100
port: 27000

Here is the output of the command:

Hello,

Could you try to run mongod with sudo ?

sudo mongod --config your-file

If you try this config file ? https://pastebin.com/6kcqBv65

Never run with sudo.

You fix the permissions.

With sudo you might render your system unstable if your config file has errors.

You just have to create the directory /data/log/. From you output of ls -l /data I can see that this directory is not present.

Do not use a config file given to you by somebody else unless you are really sure of what you are doing. And since we are here answering your questions you are definitively not really sure of what you are doing. That’s not bad and it is normal since we are here to learn.

Suggesting somebody to run a program with sudo with a config file that is not working is irresponsible.

Seriously guy, if something go wrong you can just break a vm not a production. Just take a breath and go fun yourself. That’s why I dislike forums there is always a pedant guy to bring back is science. :face_with_monocle:

Just curious, what is the issue with using sudo?


But @ Vincent_98639 is right that IN THIS CASE it is not a problem because it is a course VM. But it is good to acquire good habits even when it is not necessary.

1 Like

Thank you steeve !
I’m agree for the good habit. I’m just a student who want help an other mate.

I hear you. I am, too, just a student who want help an other mate.

Also, Here is some other useful information.

My mongod instance works when I use this mongod command:

mongod --dbpath /data/db --port 27000 --bind_ip “192.168.103.100,127.0.0.1”

Here is the output when I use the mongo --port 27000

So, it seems to be able to run, its just that the config file is broken, for whatever reason.

Yes, the last error you had was that the directory /data/log/ was not existent as I mentioned in an earlier post.

Give it a try.

Still same issue:

config file:

systemLog:
destination: file
path: /data/log/mongo.log
logAppend: true
storage:
dbPath: /data/db
security:
authorization: “enabled”
replication:
replSetName: “M103”
net:
bindIp : 127.0.0.1,192.168.103.100
port: 27000

starting mongod with config

1 Like

Output of ls -l /data/log please?