Lab: Configure a Sharded Cluster

Firstly is there a typo in the lab notes? It says to add the first shard:

sh.addShard(“m103-repl/192.168.103.100:27001”)

But the m103-repl replica set nodes are running on 192.168.103.100:27011/27012/27013

Secondly the validation scripts fails with an error:

vagrant@m103:~$ validate_lab_first_sharded_cluster

Client experienced a timeout when connecting to ‘m103-repl’ - check that mongod/mongos

processes are running on the correct ports, and that the ‘m103-admin’ user

authenticates against the admin database.

But I can connect to the replica set:

mongo --host “m103-repl/192.168.103.100:27012” -u “m103-admin” -p “m103-pass” --authenticationDatabase “admin”
MongoDB shell version v3.6.14
connecting to: mongodb://192.168.103.100:27012/?authSource=admin&gssapiServiceName=mongodb&replicaSet=m103-repl
2019-09-04T15:39:16.734+0000 I NETWORK [thread1] Starting new replica set monitor for m103-repl/192.168.103.100:27012
2019-09-04T15:39:16.735+0000 I NETWORK [thread1] Successfully connected to 192.168.103.100:27012 (1 connections now open to 192.168.103.100:27012 with a 5 second timeout)
2019-09-04T15:39:16.736+0000 I NETWORK [thread1] changing hosts to m103-repl/192.168.103.100:27011,192.168.103.100:27012,192.168.103.100:27013 from m103-repl/192.168.103.100:27012
2019-09-04T15:39:16.736+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to 192.168.103.100:27013 (1 connections now open to 192.168.103.100:27013 with a 5 second timeout)
2019-09-04T15:39:16.738+0000 I NETWORK [ReplicaSetMonitor-TaskExecutor-0] Successfully connected to 192.168.103.100:27011 (1 connections now open to 192.168.103.100:27011 with a 5 second timeout)
Implicit session: session { “id” : UUID(“f63509ef-6f23-4512-b894-0488821ee32e”) }
MongoDB server version: 3.6.14
Server has startup warnings:
2019-09-04T15:31:17.087+0000 I STORAGE [initandlisten]
2019-09-04T15:31:17.087+0000 I STORAGE [initandlisten] ** WARNING: Using the XFS filesystem is strongly recommended with the WiredTiger storage engine
2019-09-04T15:31:17.087+0000 I STORAGE [initandlisten] ** See http://dochub.mongodb.org/core/prodnotes-filesystem
2019-09-04T15:31:17.934+0000 I CONTROL [initandlisten]
2019-09-04T15:31:17.934+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/enabled is ‘always’.
2019-09-04T15:31:17.934+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-09-04T15:31:17.934+0000 I CONTROL [initandlisten]
2019-09-04T15:31:17.934+0000 I CONTROL [initandlisten] ** WARNING: /sys/kernel/mm/transparent_hugepage/defrag is ‘always’.
2019-09-04T15:31:17.934+0000 I CONTROL [initandlisten] ** We suggest setting it to ‘never’
2019-09-04T15:31:17.934+0000 I CONTROL [initandlisten]
MongoDB Enterprise m103-repl:PRIMARY>

Confused and a bit downhearted to be honest :frowning:

So, I removed everything, rebuilt the m103-repl replica set to run on port 27001|2|3, rebuilt the cars replica set, restarted mongos, added in the m103-repl replica set as the first shard and completed the lab successfully.

So - if I had wanted just to move the m103-repl to run on a new port could I have just restarted the 3 modes to run. a new port by changing the config files or was deleting everything and starting again from scratch the correct approach - seems a bit “nuclear”.

Hi @dgiffin,

There is no typo in the Lab notes. Please read the instructions carefully.

Congratulations that you completed the lab :slight_smile:

By just changing the port number in the config files and re-launching the mongod daemons would not work because the replica set configuration is shared with all the nodes in the replica set and you must update the configuration as well if you are making any changes.

Additionally, for validating the labs correctly, you need to follow the instructions carefully and use the exact same configurations (including the port numbers and replica set names) as mentioned in the labs.

Hope it helps!

Thanks,
Muskan
Curriculum Support Engineer

I have the config files in place for all config servers and started the mongod using the 3 new files
I just started mongo on 1st on port 26001 to create a root user
but i keep getting the below error

MongoDB Enterprise > use admin
switched to db admin
MongoDB Enterprise > mongo admin --host localhost:26001 --eval
2019-10-29T15:43:22.145+0000 E QUERY [thread1] SyntaxError: missing ; before statement @(shell):1:6
MongoDB Enterprise > db.createUser({
… user: “m103-admin”,
… pwd: “m103-pass”,
… roles: [
… {role: “root”, db: “admin”}
… ]
… })
2019-10-29T15:43:37.767+0000 E QUERY [thread1] Error: couldn’t add user: not master :
_getErrorWithCode@src/mongo/shell/utils.js:25:13
DB.prototype.createUser@src/mongo/shell/db.js:1437:15
@(shell):1:1

You are running the command at mongo prompt
Please run at your os prompt.It will work

Hi @Parsurama_Reddy_84828,

In addition to @Ramachandra_37567,

I believe you are trying to create a user for the config server replica set (CSRS). There are couple of things that you are doing wrong here.

The command that you have used here to create the user was discussed in chapter 1 for the standalone (single) mongod instance. However, in this case you are working with a replica set so please make sure you have run the rs.initiate() command before creating a user.

We have already discussed the steps for initiating the replica set and then creating the user in the Lab - Initiate a Replica Set Locally.

Hope it helps!

If you have any other issue, then please feel free to get back to us.

Happy Learning :slight_smile:

Thanks,
Shubham Ranjan
Curriculum Support Engineer