Setting Up a Sharded Cluster node1.conf does not work

Chapter 3: Sharding, Lecture: Setting Up a Sharded Cluster

Running csrs and mongos was successful, but Error running node1.conf

On video lesson

sharding:
  clusterRole: shardsvr
storage:
  dbPath: /var/mongodb/db/node1
  wiredTiger:
    engineConfig:
      cacheSizeGB: .1
net:
  bindIp: 192.168.103.100,localhost
  port: 27011
security:
  keyFile: /var/mongodb/pki/m103-keyfile
systemLog:
  destination: file
  path: /var/mongodb/db/node1/mongod.log
  logAppend: true
processManagement:
  fork: true
replication:
  replSetName: m103-repl

So, I just COPY & PASTE entire node1.conf on lecture note.

Since I already kill my mongod, I think I don’t need to live upgraded. So I just start mongod again(mongod -f node1.conf), node2, node3.conf respectively.

But as you can see, my replica set name doesn’t change (still it is m103-example). And also, there’s error message(replica set conifg is invalid)

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

MongoDB Enterprise m103-example:OTHER> rs.status()
{
	"state" : 10,
	"stateStr" : "REMOVED",
	"uptime" : 756,
	"optime" : {
		"ts" : Timestamp(1576203621, 1),
		"t" : NumberLong(1)
	},
	"optimeDate" : ISODate("2019-12-13T02:20:21Z"),
	"lastHeartbeatMessage" : "",
	"syncingTo" : "",
	"syncSourceHost" : "",
	"syncSourceId" : -1,
	"infoMessage" : "",
	"ok" : 0,
	"errmsg" : "Our replica set config is invalid or we are not a member of it",
	"code" : 93,
	"codeName" : "InvalidReplicaSetConfig",
	"operationTime" : Timestamp(1576203621, 1),
	"$clusterTime" : {
		"clusterTime" : Timestamp(1576203621, 1),
		"signature" : {
			"hash" : BinData(0,"0bYsqW5ypMblYDB2QYvABp/0Tow="),
			"keyId" : NumberLong("6769724917924495361")
		}
	}
}

So, Should I remove entire directory?(dbPath: /var/mongodb/db/node1, node2, node3)?

Or should I do rolling upgrade?

If I should do rolling upgrade, what’s original contents of node1.conf?

In lecture video, he just add two lines as belows.
sharding:
clusterRole: shardsvr

but my original node1.conf is very different. My original node1.conf as follows(it is created on Chapter 2, replication set lecture)

storage:
  dbPath: /var/mongodb/db/node1
net:
  bindIp: 192.168.103.100,localhost
  port: 27011
security:
  authorization: enabled
  keyFile: /var/mongodb/pki/m103-keyfile
systemLog:
  destination: file
  path: /var/mongodb/db/node1/mongod.log
  logAppend: true
processManagement:
  fork: true
replication:
  replSetName: m103-example

I have tried several ways. Changing the node1.conf file doesn’t seem to work without deleting dbPath (/ var / mongdb / db / node1,2,3), which was created during chapter 2 replication lecture.

I wish there was an instruction to delete the directory.

Hi @ys_70859,

We can’t just change the name of the replica set by modifying the name in the configuration file. The name of the replica set is stored locally on each node in the local database.

You will have to drop/delete the local database on each node which stores the replication related information. OR, deleting the entire directory pointed by the dbPath would also resolve the issue.

For deleting the directories and its content you can use this command :

rm -rf < dir name >

Thanks for surfacing this, I will forward the feedback to the team and we will take the necessary action.

Thanks,
Shubham Ranjan
Curriculum Support Engineer