mongodb分片集合

#启用数据库分片

sh.enableSharding("vcollege")

#创建集合

db.sys_logs.insert({"_id":ObjectId("5efed792943fafb741259c0c"),"userId":"123456","account":"13375413295","schoolId":"2","busiModel":"登录模块","operation":"获取菜单权限列表","ip":"127.0.0.1, 222.175.156.230","createTime":ISODate("2019-11-15T08:30:38.000Z")})

#创建索引

db.sys_logs.ensureIndex({"schoolId": 1, "userId": 1})

#分片

sh.shardCollection("vcollege.sys_logs",{"schoolId": 1, "userId": 1})

#查看分片情况

sh.status()

#创建集合

db.smsLog.insert({"_id":ObjectId("5efee40cbb8f16bb31bdb709"),"inparam":"18366660091","outparam":"843325&{\"code\":\"0\",\"data\":{\"taskid\":\"052280811263662269276835840\"},\"msg\":\"提交成功\"}","calltime":ISODate("2020-05-22T02:45:37.343Z"),"backtime":ISODate("2020-05-22T02:45:37.343Z"),"type":1.0})

#创建索引

db.smsLog.ensureIndex({"inparam": 1})

#分片

sh.shardCollection("vcollege.smsLog",{"inparam": 1})

#查看分片情况

sh.status()

#创建集合

db.live_comment.insert({"_id":ObjectId("5efee8cabb8f16bb31bdb70a"),"schoolId":37.0,"liveId":12.0,"studentId":1059.0,"studentName":"20级网络与新媒体100","content":"测试","createTime":ISODate("2020-06-17T07:01:41.016Z")})

#创建索引

db.live_comment.ensureIndex({"schoolId": 1,"studentId":1})

#分片

sh.shardCollection("vcollege.live_comment",{"schoolId": 1,"studentId":1})

#查看分片情况

sh.status()

#创建集合

db.app_student_logs.insert({"_id":ObjectId("5efeeb049450b307a736016f"),"schoolId":37.0,"studentId":925.0,"account":"18366660021","busiModel":"学生登录模块","operation":"20级新闻21登录学生端","clientType":"MI NOTE LTE","clientVersion":"MI NOTE LTE","appVersion":"1.0.1","createTime":ISODate("2020-07-01T07:01:28.000Z")})

#创建索引

db.app_student_logs.ensureIndex({"schoolId": 1,"studentId":1})

#分片

sh.shardCollection("vcollege.app_student_logs",{"schoolId": 1,"studentId":1})

#查看分片情况

sh.status()

#创建集合

db.app_message.insert({"_id":ObjectId("5efef5ec9450b307a7360172"),"messageId":82.0,"studentId":909.0,"tdInfoId":1018.0,"title":"老师接收","desc":"我是消介我是","content":"<p>我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是内容我是</p>","type":"1","businessType":"message_school","userType":"1","rangeType":"1","releaseTime":ISODate("2020-06-04T02:23:52.354Z"),"status":"2","isRead":"1","createUser":"18500000000","createTime":ISODate("2020-06-04T02:23:52.132Z"),"appClientid":"d82304e02312e6d6a5f31705e8d98947","platfrom":"app","schoolId":37.0})

#创建索引

db.app_message.ensureIndex({"schoolId": 1,"studentId":1,"teacherId":1,"messageId":1})

#分片

sh.shardCollection("vcollege.app_message",{"schoolId": 1})

#查看分片情况

sh.status()
  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 打赏
    打赏
  • 0
    评论
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包

打赏作者

主主主主公

你的鼓励将大动力作的最是我创

¥1 ¥2 ¥4 ¥6 ¥10 ¥20
扫码支付:¥1
获取中
扫码支付

您的余额不足,请更换扫码支付或充值

打赏作者

实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值