您的位置:首页 > 博客中心 > 数据库 >

mongodb sharding

时间:2022-03-10 17:46

mongod --port 10001 --logpath cluster/log/shard1.log --logappend --shardsvr -dbpath cluster/data/shard1 --directoryperdb --rest
mongod --port 10002 --logpath cluster/log/shard2.log --logappend --shardsvr -dbpath cluster/data/shard2 --directoryperdb --rest
mongod --port 20000 --logpath cluster/log/config.log --logappend --configsvr -dbpath cluster/data/config
mongos --port 27017 --logpath cluster/log/mongos.log --logappend --configdb 127.0.0.1:20000

进入mongos,配置shard:
mongo 127.0.0.1:27017/admin
db.runCommand({ addshard : "127.0.0.1:10001"})
db.runCommand({ addshard : "127.0.0.1:10002"})
db.runCommand({ listshards : 1})
db.runCommand({ enablesharding : "test"})
db.runCommand({ shardcollection : "test.c1",key : {_id: 1} })

 

参考

 

 

mongodb sharding,布布扣,bubuko.com

热门排行

今日推荐

热门手游