Unrecognised option '--auth'

Stuck on Chapter 1: The Mongod, Lab - Launching Mongod. There are many variables involved, so being new to setting up a VM, node, etc… this has been more daunting than expected. But I am determined to learn.

Anyhow, I am running through this exercise and reading about configuration settings, bind ip, authentication settings and such in the MongoDB Manual. I think I successfully created the username and password in the lab exercise, but I was unable to get the validation script to run. I did kill the process using PID, and have reset and retried various combinations in mongod and mongo.

This is my latest, in just trying to restart at the top line:

vagrant@m103:~ mongo --auth --port 27000 --host localhost,192.168.103.0 Error parsing command line: unrecognised option '--auth' try 'mongo --help' for more information vagrant@m103:~ mongo --port 27000 --host localhost,192.168.103.0 --auth
Error parsing command line: unrecognised option ‘–auth’
try ‘mongo --help’ for more information

This is just in response to this:

Applying what you’ve learned so far about the mongod process, launch a mongod instance, from the command line, with the following requirements:

  • run on port 27000
  • data files are stored in /data/db/
  • listens to connections from the IP address 192.168.103.100 and localhost
  • authentication is enabled

Any help is greatly appreciated. Also, I realize that this is late, but can I still continue the class and try to catch up or do I have to retake it?

Tried this:

vagrant@m103:~$ mongo --port 27000 --host localhost,192.168.103.0 -u m103-admin -p m103-pass
MongoDB shell version v3.6.14
connecting to: mongodb://localhost:27000,192.168.103.0:27000/?gssapiServiceName=mongodb
2019-08-30T17:26:54.005+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused
2019-08-30T17:26:54.005+0000 W NETWORK [thread1] Failed to connect to 192.168.103.0:27000, in(connect), reason: Network is unreachable
2019-08-30T17:26:54.006+0000 E QUERY [thread1] Error: couldn’t connect to server 192.168.103.0:27000, connection attempt failed :
connect@src/mongo/shell/mongo.js:263:13
@(connect):1:6
exception: connect failed

And another, adding dbpath:

Vagrant@m103:~ mongo --port 27000 --host localhost -u m103-admin -p m103-pass MongoDB shell version v3.6.14 connecting to: mongodb://localhost:27000/?gssapiServiceName=mongodb 2019-08-30T17:27:30.547+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused 2019-08-30T17:27:30.547+0000 E QUERY [thread1] Error: couldn't connect to server localhost:27000, connection attempt failed : connect@src/mongo/shell/mongo.js:263:13 @(connect):1:6 exception: connect failed vagrant@m103:~ mongo --port 27000 --host localhost,192.168.103.0 --dbpath /data/db -u m103-admin -p m103-pass
Error parsing command line: unrecognised option ‘–dbpath’

Hey @Sean_64404

mongod is the process that you need to start
https://docs.mongodb.com/manual/reference/program/mongod/index.html#mongod

mongo is the shell
https://docs.mongodb.com/manual/mongo/index.html#the-mongo-shell

I was finally able to get the mongod up and running with the following command:

vagrant@m103:~$ mongod --port 27000 --bind_ip localhost,192.168.103.0 --dbpath /data/db --auth

2019-08-30T18:36:12.462+0000 I CONTROL [initandlisten] MongoDB starting : pid=8659 port=27000 dbpath=/data/db 64-bit host=m103

But, now trying to see if the user was in fact created, and if it is saved or not.

I think it was, because I am not having difficulty logging into the mongo shell.

I have yet to successfully run: validate_lab_launch_mongod.

vagrant@m103:~$ validate_lab_launch_mongod
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.

It seems that I am using the right port, but I have no idea how to check if the user was created with the correct settings.

2019-08-30T18:36:12.462+0000 I CONTROL [initandlisten] MongoDB starting : pid=8659 port=27000 dbpath=/data/db 64-bit host=m103

Maybe they are not created. Finally got some insight:

MongoDB Enterprise > db.getUsers()
2019-08-30T18:58:18.213+0000 E QUERY [thread1] Error: there are no users authenticated :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.getUsers@src/mongo/shell/db.js:1686:1
@(shell):1:1
MongoDB Enterprise >

Maybe they are?

vagrant@m103:~$ mongo admin --host localhost:27000 --eval ’

db.createUser({
user: “m103-admin”,
pwd: “m103-pass”,
roles: [
{role: “root”, db: “admin”}
]
})

MongoDB shell version v3.6.14
connecting to: mongodb://localhost:27000/admin?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“df84c633-6788-4a05-943d-f82b6c7a9a67”) }
MongoDB server version: 3.6.14
2019-08-30T19:07:59.662+0000 E QUERY [thread1] Error: couldn’t add user: there are no users authenticated :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell eval):2:1
vagrant@m103:~$

Got the mongod to work with this:

Last login: Fri Aug 30 18:49:31 2019 from 10.0.2.2
vagrant@m103:~$ mongod --port 27000 --bind_ip localhost,192.168.103.0 --dbpath /data/db --auth

Still unable to get a successful validation:

Last login: Fri Aug 30 19:50:11 2019 from 10.0.2.2
vagrant@m103:~ validate_lab_launch_mongod 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. vagrant@m103:~

Try to connect to the mongo shell with the user you may have created.

Or if all else fails just delete the db path and recreate it and try again with creating the user with the local host exception.

I have been able to connect to the mongo shell with the user created. I also just created another user after the

$ use Admin

command.

Now I am getting the following error:

You need to bind the IP address to 192.168.103.100

But I did include that in my mongod command launch:

vagrant@m103:~$ mongod --port 27000 --bind_ip localhost,192.168.103.0 --dbpath /data/db --auth

And the mogo command line launch:

vagrant@m103:~$ mongo localhost:27000 --username m103-admin --password m103-pass
MongoDB shell version v3.6.14
connecting to: mongodb://localhost:27000/test?gssapiServiceName=mongodb
Implicit session: session { “id” : UUID(“25dbae6b-ec84-46a3-ae6e-8a2f3cb8a896”) }
MongoDB server version: 3.6.14
Server has startup warnings:
2019-08-30T21:17:36.218+0000 I STORAGE [initandlisten]
2019-08-30T21:17:36.218+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-08-30T21:17:36.218+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise >

SHould I delete the db path at the Vagrant SSH level or in the Ubuntu GUI?

Here are the users:

MongoDB Enterprise > db.system.users.find( {} )
{ “_id” : “test.m103-admin”, “userId” : UUID(“7d5765a1-bff3-4fff-8e9c-40bb7173a035”), “user” : “m103-admin”, “db” : “test”, “credentials” : { “SCRAM-SHA-1” : { “iterationCount” : 10000, “salt” : “qQh3gCZP4T8YZrSL5+E1LQ==”, “storedKey” : “VHX/7B4F5hVcHx4CYqaTiJD6Z5I=”, “serverKey” : “727AxarM45YCajzhtV37zeeCtA0=” } }, “roles” : [ { “role” : “root”, “db” : “admin” } ] }
{ “_id” : “admin.m103-admin”, “userId” : UUID(“d019ec7d-9187-4c55-be32-0efb0513be6d”), “user” : “m103-admin”, “db” : “admin”, “credentials” : { “SCRAM-SHA-1” : { “iterationCount” : 10000, “salt” : “wMjSK3UHOfa3Vq8IX3D8Vw==”, “storedKey” : “EINKceocXJFiq0Y3jlJMDYvNzh4=”, “serverKey” : “DPz0N9Gi3+144ML1S0gE+86ky58=” } }, “roles” : [ { “role” : “root”, “db” : “admin” } ] }
MongoDB Enterprise >

The ips are not equal.

I realize that the local host ip is different. I thought we could bind both, no? I did try removing localhost in both the mongod and mongo command lines.

Does not equal 192.168.103.0

1 Like

That was the final issue. Thank you very much @natac13. I received 5a21c6dd403b6546001e79c0 as the key, but I am not able to paste into the quiz to verify accuracy. Is this because I am late? Am I able to complete this course even though I am late or is it going to prevent me from finishing properly?