Lab: Configuration File - Start mongod with config file

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > db.getUsers()
[
	{
		"_id" : "admin.m103-admin",
		"user" : "m103-admin",
		"db" : "admin",
		"roles" : [
			{
				"role" : "root",
				"db" : "admin"
			}
		]
	}
]
   ]

================================================
When i leave fork in i get below error:

ERROR: child process failed, exited with error number 100

To see additional information in this output, start without the “–fork” option.

vagrant@m103:/data/db$

==================================================
when i remove fork i get no output:
vagrant@m103:/data/db$ mongod --config /data/db/mongod.conf

vagrant@m103:/data/db$

===========================================
Validation:

vagrant@m103:/data/db$ 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.

Much better :slight_smile:

Your fork element now looks like it’s a child of the processManagement element, which is where it should be.

If you’re not getting …

Unrecognized option: security.fork

… anywhere then I guess you’ve fixed that issue.

I notice you’re running the validation script from the /data/db folder. Have you tried running it from the home folder that you’re in when you first launch and connect to the vagrant VM?

Just did it. same error:

Last login: Mon Jun 24 19:56:06 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:~$ pwd

/home/vagrant

vagrant@m103:~$``

OK, I admit defeat. I don’t know what you’re doing wrong. But you’ve learned how to use the image button, which will help you no end when asking for help in the future… :slight_smile:

1 Like

hi, could you tell me where do you store the config file? I copied it into C:\Users\user\university\m103\m103-vagrant-env\shared as I understood this is what you meant by shared directory on vagrant but still doesn’t work.
Thanks

1 Like

There is something going on the the validate_lab_configuration_file that I do not understand. I have created the config file:

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

I am able to start the mongod with the config file. I can start a mongo shell and manipulate the databases using the requireed user account:

mongo --port 27000 -u "m103-admin" -p "m103-pass" --authenticationDatabase "admin"

But I continue to get this error when i run the validation script:

“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.”

Hi James_68753

From your various snapshots i see some mistakes

First of all you should not connect to mongodb as mongo
It connects you to default port 27017
Please connect as below
mongo admin --port 27000
Thats why your validation is failing
Validation is expecting your mongod to run on port 27000 but it is running on 27017

Are you doing replication in this lab?
Please remove replication parmeter
You have put user name m103-admin for replicasetname.Nothing wrong but what was your intention?
Also you are running mongo when you are already connected to mongodb
You should run mongo at your os prompt(outside mongo prompt)
That’s why your commands failed with syntax error
Please check all above and repeat the exercise

@Pawel_72578 yes, that’s the shared folder. You can put the config file there as long as you pass its path as the -f or --config command line argument when you start mongod. From within the VM you can refer to the shared folder as /shared.

1 Like

@SloughHand there’s no requirement in this lab to run mongod as a background process with a log file. The error message doesn’t seem to say that this is the problem, but I think it’s worth changing the config file to run it in the foreground with the output written to the console, just in case that is what’s wrong.

Yep, that’s where I put it and it worked for me…

figured it out yesterday and worked for me. thanks! :slightly_smiling_face:

1 Like

Hi @James_68753,

First you need to launch mongod process on port 27000. After it gets successfully launched you need to get into mongo shell using the following command:

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

Here, you have already into mongo shell. By just typing “mongo”, you get connected to mongo shell on port 27017. So, your user is created on port 27017, and not on expected 27000.

Please let me know, if you still face any issues.

Thanks,
Sonali

@Sonali_Mamgain i keep running into that issue on the different labs because i am thinking that i am in port27000 as user already. I’m working on the logging one now.

Hi @SloughHand,

I can see that you have successfully completed the lab. :clap:
Can you please share what did you do to run validation script successfully?

Thanks,
Sonali

/var/mongodb$ mongo admin --port 27000

MongoDB shell version v3.6.12

connecting to: mongodb://127.0.0.1:27000/admin?gssapiServiceName=mongodb

2019-06-25T13:03:03.834+0000 W NETWORK [thread1] Failed to connect to 127.0.0.1:27000, in(checking socket for error after poll), reason: Connection refused

2019-06-25T13:03:03.834+0000 E QUERY [thread1] Error: couldn't connect to server 127.0.0.1:27000, connection attempt failed :

connect@src/mongo/shell/mongo.js:263:13

@(connect):1:6

exception: connect failed`

Hi @James_68753,

Please make sure you follow all the lab requirements exactly as mentioned.

In this case, check if your mongod process is started on port 27000.
Please share the output of the following command:

ps -ef | grep mongod

Also, share the configuration file along with the name of the lab that you are attempting.

Thanks,
Sonali

Okay i'm on the right port. how do i get the validation script to work now 

validate_lab_change_dbpath

connect to this server.
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** Start the server with --bind_ip to specify which IP
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** addresses it should serve responses from, or with --bind_ip_all to
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** bind to all interfaces. If this behavior is desired, start the
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** server with --bind_ip 127.0.0.1 to disable this warning.
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten]
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten]
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten]
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-06-25T13:23:15.522+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-06-25T13:23:15.523+0000 I CONTROL [initandlisten]

Hi @James_68753,

Please share the screenshot of the configuration file that ypu are using to launch mongod. It seems, there is some issue with the bind Ip parameter.

Also, what command did you run to get this above error? Please share the command with the complete error message.

Thanks,
Sonali

Okay so config file in /data/db/mongod.conf

storage:
  dbPath: "/var/mongodb/db"
journal:
enabled: true
net:
  bindIp: "192.168.103.100,127.0.0.1"
  port: 27000
systemLog:
  destination: file
  path: "/data/mongod.log"
security:
  authorization: enabled

=============================
running mongod --port 27000 gave me that message.

Hi @James_68753,

Please check for all the steps below:

  1. You can remove the following lines from the config file:
  1. Follow the steps to create /var/mongodb/db/ folder as mentioned in the lab.

  2. Kill existing mongod processes running on port 27000. Refer to the following screenshot:
    54%20PM

  3. Add the fork option in your configuration file. Then try launching mongod using the following command:

mongod -f /data/db/mongod.conf

I would recommend to save your config files in /shared folder as for future labs you can access your config files from the same place.

  1. If launching mongod exits with an error, remove the fork options and share the screenshot of the error.

  2. After completing all steps above, if your mongod is successfully started, then create user m103-admin like you did for previous lab. Make sure you use correct username, password and database.

Please let me know, where you are facing issues.

Thanks,
Sonali