Now, we'll repeat a very similar process for each member of the sharded cluster. In our illustration, we'll initiate three single-node replica sets, each representing a shard. The mongod.conf file for each shard is similar to the following:
systemLog:
destination: file
path: "/var/log/mongodb/mongodb.log"
logAppend: true
storage:
dbPath: "/data/db"
journal:
enabled: true
net:
bindIp: 0.0.0.0
port: 27018
replication:
replSetName: repl_shard_1
sharding:
clusterRole: shardsvr
To initialize the shard replica set, as described in the previous sub-section, we open a mongo shell to each of the member servers in turn. It's important to add the --port 27018 option when opening the shell. We can then initialize the replica set using the following shell commands:
doc = {
_id : "repl_shard_1",
members: [
{ _id: 1, host: "shard1.biglittle.local:27018" }
]
}
rs.initiate(doc);
The resulting...