MongeDb分片命令

授权
db.auth('spec','pDj0Xwz7exD_');
show collections;


db.runCommand( { shardcollection : "market-data-temp.KLine",key : {"code" : 1,"period":1,"barTime":1} } )

db.KLine.insert({"code":"CU000","period":1,barTime:20180608090101})


给snapshot分片的 片key创建索引
db.Snapshot.ensureIndex({"code":1,"timestamp":1})
在snapshot插入一条数据
db.Snapshot.insert({"code":"CU000","timestamp":20180608090101000})
在admin下执行分片命令详情
db.runCommand( { shardcollection : "market-data-temp.Snapshot",key : {"code" : 1,"timestamp":1} } )
查看分片信息
sh.status({"verbose":1})

posted on 2018-06-08 19:49  RedBackIce  阅读(302)  评论(0编辑  收藏  举报