ITeye博客

MongoDB索引文件破坏后导致查询错误的问题

BigBird2012 · 2014-09-04 10:39 · MongoDB · 数据库 · Markdown

问题描述:

MongoDB在非正常情况下关闭时,可能会导致索引文件破坏,造成数据在更新时没有反映到索引上。

解决方案:

 

使用脚本,重建MongoDB所有表的索引。

var names  = db.getCollectionNames();
for( var i in names ){
    var name = names[i];
    print(name);
     
    var coll = db.getCollection(name);
    coll.reIndex();
}

 

 原创地址:http://genuinecx.blog.51cto.com/2890523/1530240

评论(0)

暂无评论。

评论功能维护中,当前仅展示历史评论。