Doubt Lab - Configure a Sharded Cluster

Hi to everyone.
I just start the lab, but I have some doubts.
The code of the mongos.conf is:

sharding:
configDB:
m103-csrs/192.168.103.100:26001,192.168.103.100:26002,192.168.103.100:26003
security:
keyFile: /var/mongodb/pki/m103-keyfile
net:
bindIp: localhost,192.168.103.100
port: 26000
systemLog:
destination: file
path: /var/mongodb/db/mongos.log
logAppend: true
processManagement:
fork: true

The response on running the mongos -f mongos.conf are:

Error parsing YAML config file: yaml-cpp: error at line 4, column 9: illegal map value
try ‘mongos --help’ for more information

Hi Maria,

I am going off of what you have pasted here but it looks like you may have a formatting issue. I would start with making sure your file matches the suggested file format and specifically looking at your configDB line.
Your options look correct to me which further supports the potential for a formatting issue.

Hope that helps!

1 Like

Hi Christopher, thanks on your response.
Now I have another doubt on this lab.
As I run the sh.addShard(“m103-repl/192.168.103.100:27002”) command to include then secondary node to the sharded cluster the response are:

MongoDB Enterprise m103-csrs:PRIMARY> sh.addShard(“m103-repl/192.168.103.100:27002”)
{
“operationTime” : Timestamp(1544639711, 1),
“ok” : 0,
“errmsg” : “no such command: ‘addShard’, bad cmd: ‘{ addShard: “m103-repl/192.168.103.100:27002”, lsid: { id: UUID(“76a5969b-2118-4f9f-8017-fd74003b17a6”) }, $clusterTime: { clusterTime: Timestamp(1544639681, 1), signature: { hash: BinData(0, E582649E635A357C989F5F0F740AFB1F51AD37AB), keyId: 6634145534967808026 } }, $db: “admin” }’”,
“code” : 59,
“codeName” : “CommandNotFound”,
“$clusterTime” : {
“clusterTime” : Timestamp(1544639711, 1),
“signature” : {
“hash” : BinData(0,“DdC9PmpKGXbAtLBeBOykwzG8FrI=”),
“keyId” : NumberLong(“6634145534967808026”)
}
}
}

Are you running this when connected to a MongoD, or to a MongoS? :wink:

https://docs.mongodb.com/manual/reference/method/sh.addShard/

sh. addShard ( <url> )
Adds a shard replica set to a sharded cluster. This method must be run on a mongos instance.

1 Like

Thanks for both of them for your responses.
Luckily I could finish the lab correctly.

So? What was the actual problem? It may help future students if you share your findings :slight_smile: