课程/MongoDB/数据库
MongoDB复制集—复制集的同步机制
-
-
白羽玄天
2017-06-20
- 1.人工干预选举,priority权重,rs.freeze()冷冻,rs.stepDown()降级
2.创建索引
背景:主节点,又连接,请求特别多(rw),其他从节点也有很多r操作
Db.coll.ensureIndex({background:true})在空闲情况下创建索引,但是还是会有影响
解决办法:如果是主节点的话,先降级到从节点,然后转为单机模式启动,然后创建索引。就可以随心所欲的创建索引,从而不影响线上。等创建完毕,再恢复成复制集成员,再将其他类似节点安装以上方法依次创建。
-
截图
0赞 · 1采集
-
-
blacksherry
2016-04-08
- Deprecated since version 3.0.0: db.collection.ensureIndex() is now an alias for db.collection.createIndex().
Optional. Builds the index in the background so that building an index does not block other database activities. Specify true to build in the background. The default value is false.
-
0赞 · 0采集