Because there is no virtual machine at home on weekends, you complete the deployment requirements under Windows and write the bat run script.
1. Create configuration files and related directoriesThe total startup script is as follows (Startmc.bat):REM M1
Start Mongod.exe--config=. /config/m1/s1_1
Start Mongod.exe--config=. /config/m1/s1_2
Start Mongod.exe--config=. /config/m1/c1_1
Start Mongod.exe--config=. /config/m1/a1_1
Start Mongod.exe--config=. /config/m1/a1_2
rem m2
Start Mongod.exe--config=. /config/m2/s2_1
Start Mongod.exe--config=. /config/m2/s2_2
Start Mongod.exe--config=. /config/m2/c2_1
Start Mongod.exe--config=. /config/m2/a2_1
Start Mongod.exe--config=. /config/m2/a2_2
rem M3
Start Mongod.exe--config=. /config/m3/s3_1
Start Mongod.exe--config=. /config/m3/s3_2
Start Mongod.exe--config=. /config/m3/c3_1
Start Mongod.exe--config=. /config/m3/a3_1
Start Mongod.exe--config=. /config/m3/a3_2
Start Mongos.exe--config=. /config/m1/s1
Start Mongos.exe--config=. /config/m2/s2
Start Mongos.exe--config=. /config/m3/s32. Configuration FilesThe configuration file is divided into several cluster folders, namely M1, M2, M3Each folder contains two shards (s*_1,s*_2), one config (c*_1), one MONGOs (s*), two quorum nodes (A*_1,a*_2) (M1 For example, the other two folders correspond to log and DB files, The port number is added separately):
A1_1 (Note that there is no fork in Windows, so use start to create different processes in Bat):Dbpath=. /data/db/a1_1
Logpath=. /data/a1_1.log
port=8451
Shardsvr=true
Replset=shard1
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true
a1_2: dbpath=. /data/db/a1_2
Logpath=. /data/a1_2.log
port=8452
Shardsvr=true
Replset=shard2
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true
C1_1:
Dbpath=. /data/db/c1_1
Logpath=. /data/c1_1.log
port=8441
Configsvr=true
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true
S1: logpath=. /data/s1.log
port=8440
chunksize=100
Logappend=true
configdb=localhost:8441,localhost:8541,localhost:8641
s1_1: Dbpath=. /data/db/s1_1
Logpath=. /data/s1_1.log
port=8442
Shardsvr=true
Replset=shard1
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true
s1_2: dbpath=. /data/db/s1_2
Logpath=. /data/s1_2.log
port=8443
Shardsvr=true
Replset=shard2
Logappend=true
oplogsize=2048
Storageengine=wiredtiger
Nojournal=true
3. Set the Shard accordinglyUse adminconfig = {_id: ' shard1 ', members:[{_id:0, Host: ' localhost:8442 '},{_id:1, host: ' LocalHost: 8542'},{_id:2, host: ' LocalHost: 8642', slavedelay:7200,priority:0},{_id:3, host: ' LocalHost: 8451', arbiteronly:true},{_id:4, host: ' LocalHost: 8551', arbiteronly:true},{_id:5, host: ' LocalHost: 8651', arbiteronly:true}]};rs.initiate (config);config = {_id: ' Shard2 ', members:[{_id:0, Host: ' localhost:8443 '},{_id:1, host: ' LocalHost: 8543'},{_id:2, host: ' LocalHost: 8643', slavedelay:7200,priority:0},{_id:3, host: ' LocalHost: 8452', arbiteronly:true},{_id:4, host: ' LocalHost: 8552', arbiteronly:true},{_id:5, host: ' LocalHost: 8652', arbiteronly:true}]};rs.initiate (config);
Use adminDb.runcommand ({addshard: "shard1/localhost:8442,localhost: 8542", Name: "S1"});Db.runcommand ({addshard: "shard2/localhost:8443,localhost: 8543", Name: "S2"});Db.runcommand ({listshards:1})3. Directory structure and operation situationProfile Directory (M1 as an example):
File record log
DB folder
Run the program (15+3 process)
Shard Condition:
Copyright NOTICE: This article for Bo Master original article, without Bo Master permission not reproduced.
One-click deployment of MongoDB Cluster Windows edition