mongodb sharding
sharding_config.conf
configsvr = truebind_ip = 0.0.0.0
dbpath=/etc/mongodb/config_db
logpath=/var/log/mongodb/mongodb_config.log
bind_ip = 0.0.0.0
logappend=true
port = 9211
logpath = /var/log/mongodb/mongodb_route_1.log
logappend = true
bind_ip = 0.0.0.0
configdb = 127.0.0.1:9211
port = 9200
shardsvr = true
dbpath=/hdd1/mongodb_shard
logpath=/var/log/mongodb/mongodb_shard_1.log
logappend=true
port = 9201
# tuning configuration
bind_ip = 0.0.0.0
objcheck = false
journal = false
nojournal = true
nohttpinterface = true
sh.getBalancerState()
sh.startBalancer()
sh.stopBalancer()
db.runCommand({ addshard:"localhost:9201" })
{ "shardAdded" : "shard0000", "ok" : 1 }
> db.runCommand({ addshard:"localhost:9202" })
{ "shardAdded" : "shard0001", "ok" : 1 }
> db.runCommand({ enablesharding:"test" })
{ "ok" : 1 }
> db.runCommand({ shardcollection: "test.main", key: { _id:1 }}) --设置分片的集合名称,且必 须指定 Shard Key,系统会自动创建索引
{ "collectionsharded" : "test.users", "ok" : 1 }
> use test
switched to db test
> db.users_2.stats()
db.runCommand({"removeshard" : "localhost:9203"});
Reference: http://docs.mongodb.org/manual/reference/ulimit/
http://docs.mongodb.org/manual/tutorial/deploy-shard-cluster/
sh.addShard("10.10.4.5:27011")
sh.enableSharding("lexicon")
sh.shardCollection("lexicon.main",{"_id":1})
use admin
db.runCommand( { removeShard: "mongodb0" } )