1、查看集群状态
分片信息、数据库信息、集合信息
sh.status()
又是输出会很多,就不会截断,要使用如下查看
too many chunks to print, use verbose if you want to force print
可通过执行以下命令查看
printShardingStatus(db.getSisterDB("config"),1);
2、对集合分片步骤
1)启动数据库分片
sh.enableSharding("test")
2)启动集合分片
对集合分片时要选择一个分片键(shard key)
如果集合已存在,那么分片键上必须有索引
db.users.ensureIndex({"username":1})
sh.shardCollection("test.users",{"username":1})
3、查看chunk信息
db.chunks.find(criteria,{"min":1,"max":1})
原文:https://www.cnblogs.com/xibuhaohao/p/11269523.html