标签:
集群构架图如下:
集群大致文件结构:(192.168.137.101节点)
先搭建3个副本集
rs1/mongod.conf
rs1/start.sh
rs2/mongod.conf
后面类似......
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()
开启配置节点
搭建路由节点
分片配置
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();
附上配置:http://pan.baidu.com/s/14NGGQ
标签:
原文地址:http://www.cnblogs.com/riordon/p/4356608.html