InterviewSolution
| 1. |
What are the projection operators $, $elemMatch and $slice used for in MongoDB? |
|
Answer» MongoDB sharded CLUSTER has 3 components namely shards, mongos and config servers. We will deploy all components using the below process.
We need to start all the members of replica sets with the –shardsvr option. mongod --replSet "RS0" --shardsvr mongod --replSet "rs1" --shardsvrSuppose we have 2 shards with 3-member replica set each, all 6 shards should be started with the above option. These shard members are deployed as replica sets on the host (h1, h2, h3…. h6) at port 27017. sh1(M1, M2, M3 as replica set “rs0”) and sh2(M4, M5, M6 as replica set “rs1”)
We need to start all members of config servers as a replica set with --configsvr mongod --configsvr --replSet “cf1”Config Sever (Member c1, c2 and c3 as a replica set cf1) on host H7, h8 at port 27017.
Start the mongos specifying the config server replica set name followed by a SLASH / and at least one of the config server HOSTNAMES and ports. Mongos is deployed on server h9 at port 27017. mongos --configdb cf1/h7:27017, h8:27017, h9:27017
|
|