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

Please check the directory: /data/log is present and vagrant user can access it.

sudo mkdir -p /data/log
sudo chown vagrant:vagrant -R /data/log

Kanika

Thank you for the advice @Kanika. I ran the two scripts the two commands to make the directory and grant access to vagrant. However, I have a new problem were mongo daemon hangs and doesn’t start.

Have you checked for --fork option in config file.

If it is just hanging, good news could be it is working!!!

:slight_smile:

Kanika

Yes, it is working now! Thanks for the help. I just thought it was hung because the window did not show any output.

Though I have an issue connecting to Mongo in another window, as shown below:

Pass the --port along with mongo command.

The port will be in your config file.

Kanika

Looks like it is working.

image

However, the validate_lab_configuration_file is not:

Even though I have the correct port (27000) in my config file, it is still not working for some reason.

The port is correct! :slight_smile:

So you can check few things here:

  • dbPath directory should be /data/db and not data/db. Its a small mistake which most of us seems to be getting into.
  • Check for m103-user if it is not there, create one on admin database.
  • Authentication should be enabled.

Kanika

Here is 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.103.100
port: 27000

It seems I have all of the credentials necessary. Also, I have created that user, as shown below:

image

Another thing that is odd, is now that I connect to mongo using this configuration, my user no longer exists. I think I may have created two instances of mongo, where one has the admin account, and the other doesn’t.

Yes! You got the issue. :slight_smile:

Hint: Check on which database the user has to be created.

Kanika

I am running the same script on the new instance of mongo, yet I am encountering this error:

Follow these steps:

  • Run mongod without authentication.
  • run query “show users” If user is not there or on wrong database, delete that one and create user on admin database.
  • re-run mongod with authentication enabled.

Kanika

I have updated my configuration file as shown:
systemLog:
destination: file
path: /data/log/mongo.log
logAppend: true
storage:
dbPath: /data/db
security:
authorization: “disabled”
replication:
replSetName: “M103”
net:
bindIp : 127.0.0.1,192.168.103.100
port: 27000

I run the query “show users” and I get the following:

Do I just need to uninstall the databases and reinstall? How can I make progress at this point?

You also might not need replication set details for this Lab.

Kanika

1 Like

So do you agree I need to start from scratch?

How did you authenticate? What command do you use?
Looks like you first created the user on a wrong db (test) then you enabled authentication and then when you tried to create it again on the correct db (admin) it failed because it was wrongly created in the frist place. Just disable authentication in the config file and then you can create the user (on the correct db this time hopefully).