Configuration File Error

storage:
  dbPath: "/data/db"
systemLog:
  path: "/data/log/mongod.log"
  destination: "file"
replication:
  replSetName: M103
net:
  bindIp : "127.0.0.1,192.168.103.100"
tls:
  mode: "requireTLS"
  certificateKeyFile: "/etc/tls/tls.pem"
  CAFile: "/etc/tls/TLSCA.pem"
security:
  keyFile: "/data/keyfile"
processManagement:
  fork: true

This is the code from the example.

If you use as is, you will receive error: Unrecognized option: tls.Mode

Referencing this page, you will see that we need to indent tls: such that it is ‘under’ net.

Hi @Manav_Misra,

The code mentioned in the Lecture Notes are for Vargrant environment that we used to have earlier in our courses.

This code will not run on your local setup / IDE as it is. You will have to modify it based on the environment you are using.

We are currently in the process of updating the codes to make it compatible for the IDE environment.

~ Shubham

Try this:

systemLog:
destination: file
path: “/var/log/mongodb/mongod.log”
logAppend: true
net:
bindIp: 127.0.0.1
port: 27000
security:
authorization: “enabled”

Using these settings I get the following Error reading config file: No such file or directory try 'mongod --help' for more information

It is because you should create mongodb directory in var/log at first.

mkdir -p /var/log/mongodb

I don’t think error is due to missing directory
It would have failed to start mongod if dir is missing
It is issue with config file itself

Phillip_Gore
Where is your config file located?
What command you ran and from which dir?
Please show the screenshot

OK - I’m finally trying this again. Please see attached. Any help is appreciated.

  1. Mongod was started with a configuration file. Most likely you did not start mongod with a configuration file. Post screenshot of the terminal where you started mongod.
  2. The server requires authentication. Most likely you did not start mongod with authrorization enabled. The configuration file we see does specify it but most likely you did not start mongod with this configuration file. See 1.
1 Like

I started it with the config file

UGG - totally missed that step 3 had to be completed for the tests to pass.

Hi @Phillip_Gore,

I’m glad your issue got resolved. Please feel free to get back to us if you have any other issues.

~ Shubham

This just worked for me:

CONFIG FILE:

net:
bindIp: “127.0.0.1”
port: 27000

BACK IN THE TERMINAL:

mongod -f mongod.conf --auth

IN A DIFFERENT TERMINAL:

mongo admin --host localhost:27000 --eval ’
db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

2 Likes

Hi. I this error “Unrecognized option”: net
what might be the problem coz my configuration file is correct
below is a screenshot

i found solution to the problem. there should be space between port: and 27000

Funcionou para mim, especifiquei a porta 27000 junto ao comando mongod -f mongod.conf --auth e deu certo. Muito obrigado!

Worked for me, thanks.

In their video they talk about replica and keyFile implies asking for authentication, they didn’t mention anything about the --auth command.

They would have to mention something idk; there are a lot of resources in the documentation but also, too many things to read when you search for “authentication”

Closing this thread as all the issue has been resolved.