--Create a configuration server
Mongod.exe--logpath "G:\USERDATA\MONGODB\Test2\Log\mongodb.log"--logappend--dbpath "G:\USERDATA\MONGODB\Test2\DB "--port 27031--servicename" MongoTest2 "--servicedisplayname" MongoTest2 "--install--configsvr
--Create a shard controller
MONGOs--configdb 172.23.88.116:27031--port 27041--chunksize 1--servicename "MongoTest2"--logpath "G:\USERDATA\ Mongodb\test2\log\mongodb.log "--servicedisplayname" MongoTest2 "--install
--Create two specific shard servers
Mongod.exe--logpath "G:\USERDATA\MONGODB\Test\Log\mongodb.log"--logappend--dbpath "G:\USERDATA\MONGODB\Test\DB"- -port 27030--servicename "mongotest"--servicedisplayname "Mongotest"--install
--Uninstall MongoDB service
Mongod.exe--remove--servicename "Mongotest"
Mongod.exe--remove--servicename "MongoTest2"
--Adding shards
Db.runcommand ({addshard: "172.23.88.116:27030"})
Db.runcommand ({addshard: "172.23.88.116:27040"})
--View shard status
Db.printshardingstatus ();
--Set up a library of shards
Db.runcommand ({enablesharding: "Relationlist"})
--Set the collection of shards, note that the name must be the library name + table name
Db.runcommand ({shardcollection: "relationlist.mactable", key: {_id:1}})
MongoDB Shard cluster Environment construction record