Configuration File : Error message when validating lab_configuration_file

Hello everyone,

Can anyone help me please ?!

I can start mongod process successfully by reading mongod file configuration :

vagrant@m103:~$ mongod --config “/shared/mongod.conf”
about to fork child process, waiting until server is ready for connections.
forked process: 2054
child process started successfully, parent exiting

But, when I want to validate the lab with : vagrant@m103:~$ validate_lab_configuration_file
I have this error message :

“Client experienced a timeout when connecting to the database - check that mongod is running on the correct port, and that your user was created with the correct settings”

Note that I can connect to the port 27000 without problem : mongo --port 27000

Thank you
Kindly
Otmane

What about the following

Hello steevej-1495,

Thanks for your replay,

I don’t know how to verify that user was created with the correct setting
I have created user with given information in lunching mongod lab :

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

Are you able to login with the new user you created?

show users;
db.getUsers(); will give user details

Hi @Otmane_77759,

Do the following :

  1. Start the mongod instance using the configuration file

  2. Connect to this instance using this command :

    mongo --port 27000 -u m001-admin -p m001-pass

  3. Once you are connected please run this command and share a screenshot of the output :

    db.adminCommand( { getCmdLineOpts: 1 } )

  4. Try to run the validator as well

Thanks,
Shubham Ranjan
Curriculum Services Engineer

Thanks for your replay,
I connot show users, I have a message telling me that there is no user authenticated

Hello @Shubham_Ranjan

Thanks for your answer,

  1. Start the mongod instance using the configuration file
    Done successfully
  2. Connect to this instance using this command :
    mongo --port 27000 -u m001-admin -p m001-pass
    I have this Message error :
    vagrant@m103:~$ mongo --port 27000 -u m001-admin -p m001-pass
    MongoDB shell version v3.6.17
    connecting to: mongodb://127.0.0.1:27000/?gssapiServiceName=mongodb
    2020-02-04T18:02:27.731+0000 E QUERY [thread1] Error: Authentication failed. :
    connect@src/mongo/shell/mongo.js:263:13
    @(connect):1:6
    exception: connect failed
  3. Once you are connected please run this command and share a screenshot of the output :

db.adminCommand( { getCmdLineOpts: 1 } )
Step 2 doesn’t work so I connected mongod without user and password : mongod --port 27000
I got this message :
MongoDB Enterprise > db.adminCommand( { getCmdLineOpts: 1 } )
{
“ok” : 0,
“errmsg” : “there are no users authenticated”,
“code” : 13,
“codeName” : “Unauthorized”
}

  1. Try to run the validator as well --> doesn’t work, same error message as before

I think that I have a user authentification problem, here is my configuration file :

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

Thanks again

Best regards
Otmane

You got

so you failed to authenticate. You will not be able to do anything as mongod does not recognize you. Since, the user name and password you used give you this error then the user you created is not the correct one.

  1. The user name might be wrong
  2. The password might be wrong
  3. The authentication database might be wrong

To find out you

  1. stop the current mongod.
  2. comment out the authorization configuration item
  3. restart mongod
  4. run getUsers()
1 Like

Hi @steevej-1495

When I run the commads line (first lab) to lunch mongod I can show users :

MongoDB Enterprise > show users;
{
“_id” : “test.m103-admin”,
“userId” : UUID(“7dd1dc10-ef30-47cf-8ceb-d624f908cbbb”),
“user” : “m103-admin”,
“db” : “test”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
}

But when I run configuration file (second lab), and try to show user, I got an error message
“There are no users authenticated”

I tried your request from 1 to 4 but steal doesn’t succeed to show users

But your error is there.

You have create the user in the test database rather than the admin database.

Using the same mongod, the one that allows you to run getUsers(), do

use test
db.dropUser( "m103-admin" )
use admin
db.createUser( { user : "m103-admin" , ....  } )

The run db.getUsers() and make sure _id is admin.m103-admin.

Once the above is done, terminate this mongod and start mongod with the real configuration file. And I think you should be good to validate.

@steevej-1495
Yes I have created user with the wrong db (test)

With cammands you show me, and by running commands line , I have the correct _id now : admin.m103-admin :

MongoDB Enterprise > db.getUsers();
[
{
“_id” : “admin.m103-admin”,
“userId” : UUID(“32b1b4a0-7206-4b32-9a89-ec5f5488316b”),
“user” : “m103-admin”,
“db” : “admin”,
“roles” : [
{
“role” : “root”,
“db” : “admin”
}
]
}
]

I start mongod with real configuration file, i cannot show dbs and users, I cannot also getUsers(), I have this error message :

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.getUsers();
2020-02-04T20:43:01.110+0000 E QUERY [thread1] Error: not master and slaveOk=false
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.getUsers@src/mongo/shell/db.js:1686:1
@(shell):1:1

Thank you again !

@steevej-1495

I got it,
I commented out the replication in the configuration file

I validate the lab now successfully,
happy and sad in the same time, cause today is the end of first chapter

Than you again !

1 Like

Closing this thread as the issue has been resolved.