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

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

WBOY
WBOYOriginal
2016-06-07 16:50:471156browse

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

问题描述:

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

解决方案:

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

var names  = db.getCollectionNames();

for( var i in names ){

    var name = names[i];

    print(name);

   

    var coll = db.getCollection(name);

    coll.reIndex();

}

CentOS编译安装MongoDB

CentOS 编译安装 MongoDB与mongoDB的php扩展

CentOS 6 使用 yum 安装MongoDB及服务器端配置

Ubuntu 13.04下安装MongoDB2.4.3

MongoDB入门必读(概念与实战并重)

《MongoDB 权威指南》(MongoDB: The Definitive Guide)英文文字版[PDF]

MongoDB 的详细介绍:请点这里
MongoDB 的下载地址:请点这里

本文永久更新链接地址:

linux

Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn