Based on previous studies, we have learned several major server roles in MongoDB:
- Mongos, the entry server of the MongoDB cluster, mainly undertakes data routing tasks. It distributes data to its own MongoDB Cluster Based on the configured "partition key;
- Configserver: the server role is responsible for managing mongos data shards, the relationship between data and shards, and the corresponding configuration information (note that the number of configservers must be 1 or 3)
- Shardserver, an independent shard D server, is integrated into mongos for unified management and storage of sharded data;
- Shardserver (repset) is the shard server in the replica set. Each replica set requires at least two shardservers;
- Arbiterserver: The arbitration server in the replica set. Each replica set requires at least one arbiterserver;
For details, we need to deploy two mongos portals, three configservers, one independent shardserver and one repset (including two shardservers and one arbiterserver). A total of nine mongod instances are required.
I decided to deploy these eight instances on three computers respectively (one physical host and two virtual machines)
Physical server (192.168.111.11)
- Configserver-I (disk D)
Mongod -- configsvr -- dbpath = D: \ MongoDB \ dB -- port 2000
- Shardserver (disk C)
Mongod-dbpath = c: \ MongoDB \ DB-port 4000
- Arbiterserver (Elastic Block Storage)
Mongod -- dbpath = E: \ MongoDB \ DB-port 4004-replset superlab/192.168.111.111: 4000
Virtual Server-I (192.168.111.111)
- Configserver-II (disk D)
Mongod -- configsvr -- dbpath = D: \ MongoDB \ dB -- port 2000
- Mongos (disk C)
Mongos -- Port 8848 -- configdb = 192.168.111.111: 2000,192.168 .111.222: 2000,192.168 .111.11: 2000 (disk C)
- Shardserver (repset) (Elastic Block Storage (edisk) must be larger than 2 GB)
Mongod -- dbpath = E: \ MongoDB \ dB -- port 4000 -- replset Halab/192.168.111.222: 4000
Virtual Server-II (192.168.111.222)
- Configserver-III (disk D)
Mongod -- configsvr -- dbpath = D: \ MongoDB \ dB -- port 2000
- Mongos (disk C)
Mongos -- Port 8848 -- configdb = 192.168.111.111: 2000,192.168 .111.222: 2000,192.168 .111.11: 2000 (disk C)
- Shardserver (repset) (Elastic Block Storage (edisk) must be larger than 2 GB)
Mongod -- dbpath = E: \ MongoDB \ dB -- port 4000 -- replset Halab/192.168.111.111: 4000