The cluster architecture diagram is as follows:
Cluster approximate file structure: (192.168.137.101 nodes)
Build 3 Replica Sets first
Rs1/mongod.conf
rs1/start.sh
Rs2/mongod.conf
The back resembles ...
MONGO 192.168.137.101:10001/admin
conf = {_id: "Rs1", Members:[{_id:0,host: "127.0.0.1:10001", Priority:2},{_id:1,host: "127.0.0.1:20001", priority:1},{ _id:2,host: "127.0.0.1:30001", Arbiteronly:true}]}
Rs.initiate (CONF)
Rs.status ()
To open the configuration node
Building a Routing node
Shard Configuration
conf = {addshard: "rs1/192.168.137.101:10001,192.168.137.102:10001,192.168.137.103:10001", Name: "Rs1"}
conf = {addshard: "rs2/192.168.137.101:20001,192.168.137.102:20001,192.168.137.103:20001", Name: "Rs2"}
conf = {addshard: "rs3/192.168.137.101:30001,192.168.137.103:30001,192.168.137.103:30001", Name: "Rs3"}
Db.runcommand ({listshards:true});
Db.runcommand ({enablesharding: "TestDB"}); Db.runcommand ({shardcollection: "Testdb.table1", key: {id:1}})
Use TestDB; for (var i = 1; I <= 100000; i++) Db.table1.save ({id:i, "test1": "Testval1"}); Db.table1.stats ();
Attached configuration: Http://pan.baidu.com/s/14NGGQ
MongoDB High-availability cluster setup