标签:blog http io ar os 使用 on div 2014
完整的搭建mongodb集群(副本集+分片)的例子。。。
准备四台机器,分别是bluejoe1,bluejoe2,bluejoe3,以及bluejoe0
副本集及分片策略确定如下:
/usr/local/mongodb/bin/mongod --dbpath /usr/local/mongodb/data/node1 --port 10001 --replSet shard1/bluejoe2:10002 --logpath=/usr/local/mongodb/log/node1.log /usr/local/mongodb/bin/mongod --dbpath /usr/local/mongodb/data/node2 --port 10002 --replSet shard3/bluejoe3:10001 --logpath=/usr/local/mongodb/log/node2.log
db.runCommand( { "replSetInitiate": { "_id":"shard1", "members": [ { "_id":1, "host":"bluejoe1:10001" }, { "_id":2, "host":"bluejoe2:10002" } ] } })
/usr/local/mongodb/bin/mongod --dbpath /usr/local/mongodb/data/configdb --port 20000 --logpath=/usr/local/mongodb/log/configdb.log
/usr/local/mongodb/bin/mongos --port 30000 --configdb bluejoe1:20000,bluejoe2:20000,bluejoe3:20000
mongos> use admin switched to db admin db.runCommand({"addShard":"shard1/bluejoe1:10001"}) db.runCommand({"addShard":"shard2/bluejoe2:10001"}) db.runCommand({"addShard":"shard3/bluejoe3:10001"})
mongos> use admin switched to db admin mongos> db.runCommand({"enablesharding":"test"}) { "ok" : 1 } mongos> db.runCommand({"shardcollection":"test.person","key":{"name":1}}) { "collectionsharded" : "test.person", "ok" : 1 }
标签:blog http io ar os 使用 on div 2014
原文地址:http://blog.csdn.net/bluejoe2000/article/details/41323051