MongoDB对集合分片
2020-07-16 05:19
507 查看
1 创建数据库,直接use database_name 切换至你想创建的数据库。
mongos> use DataPlatform switched to db DataPlatform
2 创建集合
mongos> db.createCollection("risk_dag_hive_to_mongo", {"autoIndexId":true}) { "note" : "the autoIndexId option is deprecated and will be removed in a future release", "ok" : 1 }
3 首先要对库DataPlatform开启分片功能
mongos> sh.enableSharding("DataPlatform"); { "ok" : 1 }
可以通过 命令验证
sh.status()
4 对集合开启分片
mongos> sh.shardCollection("DataPlatform.risk_dag_hive_to_mongo",{"user_id":1}) { "collectionsharded" : "DataPlatform.risk_dag_hive_to_mongo", "ok" : 1 }
通过命令验证 看截图中sharded已经为true,说明开启了分片
mongos> db.risk_dag_hive_to_mongo.stats()
5 为数据库创建账号
mongos> db.createUser( ... { ... user:"DataPlatform_rw", ... pwd:"", ... roles:[{role:"readWrite",db:"DataPlatform"}] ... }) Successfully added user: { "user" : "DataPlatform_rw", "roles" : [ { "role" : "readWrite", "db" : "DataPlatform" } ] }
相关文章推荐
- mongodb分片集群的管理命令集合
- 13、MongoDB的分片,以及分布式的实现(分片,拆分的是集合,不是单条数据)
- mongodb撤销集合分片
- 安装mongodb集群及分片(所有命令集合)
- MongoDB文档翻译-Map Reduce与分片集合
- mongodb 中 Aggregation 的管道和分片集合( Pipeline and Sharded Collections)
- 【MongoDB】查看集合是否分片
- mongodb分片集合不支持group操作解决之mapreduce的使用
- mongodb集合设置分片键
- MongoDB文档翻译-聚集-聚集管道与分片集合
- MongoDB分片集群配置实例
- 八天学会MongoDB:第六天 分片技术
- MongoDB通过Shell 实现集合的日常归档
- MongoDB 分片集群搭建
- mongoVUE按所在时区显示mongoDB集合中的时间
- 【MongoDB】在windows平台下搭建mongodb的分片集群(二)
- MongoDB中关于查询条件中包含集合中字段的查询
- mongodb集群分片部署实践
- MongoDB分片集群部署
- mongoDB应用篇——固定集合和GridFS文件