Lab - Deploy a Sharded Cluster - not able to deploy shard

I have started mongos and it is running on port 26000 but I do not know next steps to deploy shard. In lecture it was asked to add

sharding:
  clusterRole: shardsvr
storage:
  dbPath: /var/mongodb/db/node1
  wiredTiger:
    engineConfig:
      cacheSizeGB: .1

Do we have to add these or it has been already added?

My config file is below:

security:
  keyFile: /var/mongodb/pki/m103-keyfile
net:
  bindIp: localhost
  port: 26000
systemLog:
  destination: file
  path: /var/mongodb/logs/mongos.log
  logAppend: true
processManagement:
  fork: true
sharding:
  configDB: csrs/localhost:27004,localhost:27005,localhost:27006

I dont think your have to edit or add anything

Since your mongos is already up just connect to mongos prompt and run addshard.
You have to review your lecture/lab instructions or mongo doc for the exact command

my steps are:

  1. mongos -f mongos.conf
  2. mongo --port 26000 -u m103-admin -p m103-pass --authenticationDatabase admin
  3. sh.status()
    *— Sharding Status — *
  • sharding version: {*
  •    "_id" : 1,*
    
  •    "minCompatibleVersion" : 5,*
    
  •    "currentVersion" : 6,*
    
  •    "clusterId" : ObjectId("60f0f422e646280f5fd88d3c")*
    
  • }*
  • shards:*
  • active mongoses:*
  • autosplit:*
  •    Currently enabled: yes*
    
  • balancer:*
  •    Currently enabled:  yes*
    
  •    Currently running:  no*
    
  •    Failed balancer rounds in last 5 attempts:  0*
    
  •    Migration Results for the last 24 hours: *
    
  •            No recent migrations*
    
  • databases:*
  •    {  "_id" : "config",  "primary" : "config",  "partitioned" : true }*
    

here active mongoses is blank

Did you addshard?

After adding first shard you should be able to see count of mongooses

In older version it used to show but in latest versions only after adding first shard you will see the count

mongos> sh.addShard(“localhost:27002”)
{
“ok” : 0,
"errmsg" : “localhost:27002 does not have a master. If this is a replica set, ensure that it has a healthy primary and that the set has been properly initiated.”,
“code” : 10107,
“codeName” : “NotMaster”,
“operationTime” : Timestamp(1626925997, 1),

steps should be:

  1. mongos -f mongos.conf
  2. mongo --port 26000 -u m103-admin -p m103-pass --authenticationDatabase admin
  3. sh.addShard(“shard1/localhost:27002”)

Hey @Dharmendra_Kumar,

We are super glad that you were able to resolve your issue.:clap:

We wish you good luck with the rest of the course. :sparkles:
For now, we’re closing this thread. In case of any questions, please feel free to reach out to us.!!

Thank you,
Kushagra