`

MongoDB非正常关闭后修复记录

阅读更多

MongoDB非正常关闭后修复记录

mongod没有后台执行,在终端连接非正常断开后,再次执行mongod报错,如下所示:

[root@sunrise16 bin]# ./mongod
./mongod --help for help and startup options
Tue Oct 25 19:49:02
Tue Oct 25 19:49:02 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Tue Oct 25 19:49:02
Tue Oct 25 19:49:02 [initandlisten] MongoDB starting : pid=13626 port=27017 dbpath=/data/db/ 32-bit host=sunrise16
Tue Oct 25 19:49:02 [initandlisten]
Tue Oct 25 19:49:02 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Tue Oct 25 19:49:02 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Tue Oct 25 19:49:02 [initandlisten] **       with --journal, the limit is lower
Tue Oct 25 19:49:02 [initandlisten]
Tue Oct 25 19:49:02 [initandlisten] db version v2.0.0, pdfile version 4.5
Tue Oct 25 19:49:02 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
Tue Oct 25 19:49:02 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Tue Oct 25 19:49:02 [initandlisten] options: {}
**************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
Tue Oct 25 19:49:02 [initandlisten] exception in initAndListen: 12596 old lock file, terminating
Tue Oct 25 19:49:02 dbexit:
Tue Oct 25 19:49:02 [initandlisten] shutdown: going to close listening sockets...
Tue Oct 25 19:49:02 [initandlisten] shutdown: going to flush diaglog...
Tue Oct 25 19:49:02 [initandlisten] shutdown: going to close sockets...
Tue Oct 25 19:49:02 [initandlisten] shutdown: waiting for fs preallocator...
Tue Oct 25 19:49:02 [initandlisten] shutdown: closing all files...
Tue Oct 25 19:49:02 [initandlisten] closeAllFiles() finished
Tue Oct 25 19:49:02 dbexit: really exiting now

 

http://www.mongodb.org/display/DOCS/Durability+and+Repair#DurabilityandRepair-RepairCommand 写道
Repair Command

When not using journaling (--nojournal), after a machine crash or kill -9 termination, run the repairDatabase command. This command will check all data for corruption, remove any corruption found, and compact data files a bit. Repair is analogous to running fsck for a file system.

When journaling is enabled, it should not be necessary to run repair. However one could still use the repair command to compact a database.

From the command line:

mongod --repair

From the shell (you have to do for all dbs including local if you go this route):

> db.repairDatabase();

During a repair operation, mongod must store temporary files to disk. By default, mongod creates temporary directories under the dbpath for this purpose. Alternatively, the --repairpath command line option can be used to specify a base directory for temporary repair files.

Note that repair is a slow operation which inspects the entire database.

After running with --repair, mongod will start up normally.
 

现在执行修复。
[root@sunrise16 bin]# ./mongod --repair
Tue Oct 25 19:50:21
Tue Oct 25 19:50:21 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Tue Oct 25 19:50:21
Tue Oct 25 19:50:21 [initandlisten] MongoDB starting : pid=14452 port=27017 dbpath=/data/db/ 32-bit host=sunrise16
Tue Oct 25 19:50:21 [initandlisten]
Tue Oct 25 19:50:21 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Tue Oct 25 19:50:21 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Tue Oct 25 19:50:21 [initandlisten] **       with --journal, the limit is lower
Tue Oct 25 19:50:21 [initandlisten]
Tue Oct 25 19:50:21 [initandlisten] db version v2.0.0, pdfile version 4.5
Tue Oct 25 19:50:21 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
Tue Oct 25 19:50:21 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Tue Oct 25 19:50:21 [initandlisten] options: { repair: true }
Tue Oct 25 19:50:22 [initandlisten] ****
Tue Oct 25 19:50:22 [initandlisten] ****
Tue Oct 25 19:50:22 [initandlisten] need to upgrade database mydb with pdfile version 4.5, new version: 4.5
Tue Oct 25 19:50:22 [initandlisten]      starting upgrade
Tue Oct 25 19:50:22 [initandlisten]  mydb repairDatabase mydb
Tue Oct 25 19:50:22 [FileAllocator] allocating new datafile /data/db/$tmp_repairDatabase_0/mydb.ns, filling with zeroes...
Tue Oct 25 19:50:22 [FileAllocator] creating directory /data/db/$tmp_repairDatabase_0/_tmp
Tue Oct 25 19:50:26 [FileAllocator] done allocating datafile /data/db/$tmp_repairDatabase_0/mydb.ns, size: 16MB,  took 4 secs
Tue Oct 25 19:50:26 [FileAllocator] allocating new datafile /data/db/$tmp_repairDatabase_0/mydb.0, filling with zeroes...
Tue Oct 25 19:50:30 [FileAllocator] done allocating datafile /data/db/$tmp_repairDatabase_0/mydb.0, size: 16MB,  took 4.004 secs
Tue Oct 25 19:50:30 [FileAllocator] allocating new datafile /data/db/$tmp_repairDatabase_0/mydb.1, filling with zeroes...
Tue Oct 25 19:50:30 [initandlisten] build index mydb.things { _id: 1 }
Tue Oct 25 19:50:30 [initandlisten] build index done 22 records 0.008 secs
Tue Oct 25 19:50:38 [FileAllocator] done allocating datafile /data/db/$tmp_repairDatabase_0/mydb.1, size: 32MB,  took 7.981 secs
Tue Oct 25 19:50:38 [initandlisten] ****
Tue Oct 25 19:50:38 [initandlisten] ****
Tue Oct 25 19:50:38 [initandlisten] need to upgrade database test with pdfile version 4.5, new version: 4.5
Tue Oct 25 19:50:38 [initandlisten]      starting upgrade
Tue Oct 25 19:50:38 [initandlisten]  test repairDatabase test
Tue Oct 25 19:50:38 [FileAllocator] allocating new datafile /data/db/$tmp_repairDatabase_0/test.ns, filling with zeroes...
Tue Oct 25 19:50:38 [FileAllocator] creating directory /data/db/$tmp_repairDatabase_0/_tmp
Tue Oct 25 19:50:42 [FileAllocator] done allocating datafile /data/db/$tmp_repairDatabase_0/test.ns, size: 16MB,  took 3.995 secs
Tue Oct 25 19:50:42 [FileAllocator] allocating new datafile /data/db/$tmp_repairDatabase_0/test.0, filling with zeroes...
Tue Oct 25 19:50:46 [FileAllocator] done allocating datafile /data/db/$tmp_repairDatabase_0/test.0, size: 16MB,  took 4.06 secs
Tue Oct 25 19:50:46 [FileAllocator] allocating new datafile /data/db/$tmp_repairDatabase_0/test.1, filling with zeroes...
Tue Oct 25 19:50:46 [initandlisten] build index test.foo { _id: 1 }
Tue Oct 25 19:50:46 [initandlisten] build index done 1 records 0 secs
Tue Oct 25 19:50:54 [FileAllocator] done allocating datafile /data/db/$tmp_repairDatabase_0/test.1, size: 32MB,  took 8.031 secs
Tue Oct 25 19:50:54 [initandlisten] finished checking dbs
Tue Oct 25 19:50:54 dbexit:
Tue Oct 25 19:50:54 [initandlisten] shutdown: going to close listening sockets...
Tue Oct 25 19:50:54 [initandlisten] shutdown: going to flush diaglog...
Tue Oct 25 19:50:54 [initandlisten] shutdown: going to close sockets...
Tue Oct 25 19:50:54 [initandlisten] shutdown: waiting for fs preallocator...
Tue Oct 25 19:50:54 [initandlisten] shutdown: closing all files...
Tue Oct 25 19:50:54 [initandlisten] closeAllFiles() finished
Tue Oct 25 19:50:54 [initandlisten] shutdown: removing fs lock...
Tue Oct 25 19:50:54 dbexit: really exiting now

 

现在正常启动mongod。
[root@sunrise16 bin]# ./mongod
./mongod --help for help and startup options
Tue Oct 25 19:51:00
Tue Oct 25 19:51:00 warning: 32-bit servers don't have journaling enabled by default. Please use --journal if you want durability.
Tue Oct 25 19:51:00
Tue Oct 25 19:51:00 [initandlisten] MongoDB starting : pid=14459 port=27017 dbpath=/data/db/ 32-bit host=sunrise16
Tue Oct 25 19:51:00 [initandlisten]
Tue Oct 25 19:51:00 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
Tue Oct 25 19:51:00 [initandlisten] **       see http://blog.mongodb.org/post/137788967/32-bit-limitations
Tue Oct 25 19:51:00 [initandlisten] **       with --journal, the limit is lower
Tue Oct 25 19:51:00 [initandlisten]
Tue Oct 25 19:51:00 [initandlisten] db version v2.0.0, pdfile version 4.5
Tue Oct 25 19:51:00 [initandlisten] git version: 695c67dff0ffc361b8568a13366f027caa406222
Tue Oct 25 19:51:00 [initandlisten] build info: Linux domU-12-31-39-01-70-B4 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Tue Oct 25 19:51:00 [initandlisten] options: {}
Tue Oct 25 19:51:00 [initandlisten] waiting for connections on port 27017
Tue Oct 25 19:51:00 [websvr] admin web console waiting for connections on port 28017

Tue Oct 25 19:52:00 [clientcursormon] mem (MB) res:12 virt:92 mapped:0
Tue Oct 25 19:57:00 [clientcursormon] mem (MB) res:12 virt:92 mapped:0

 

...

 

 

 

2
1
分享到:
评论

相关推荐

    mongoDB非关系型数据库安装以及使用指南

    MongoDB是一款流行且功能强大的非关系型数据库系统,它以其灵活的数据模型、高可用性和可扩展性而受到广泛赞誉。本教程将引导你完成MongoDB的安装过程,并介绍其基本使用方法,适合在线教育初学者。 一、MongoDB...

    Mybatis拦截器记录数据更新历史记录到MongoDB

    在IT行业中,数据库管理系统是核心组成部分,而MongoDB作为一个流行的NoSQL数据库,广泛应用于存储非结构化或半结构化数据。Mybatis,作为Java领域的持久层框架,它提供了灵活的SQL映射机制,使得数据库操作变得简单...

    mongodb随机获取一条记录实例

    MongoDB是一种分布式文档数据库,常用于处理和存储结构化与半结构化的数据。它使用JSON-like的BSON格式存储数据,具有高性能、高可用性和可扩展性。在PHP7.0及以上版本中,可以通过PHP的MongoDB扩展来与MongoDB进行...

    记录MongoDB管理操作

    - **正确关闭MongoDB**:切记不要使用`kill -9`强行终止MongoDB进程,这可能导致数据文件损坏。正确的做法是使用`kill -2`或者通过MongoDB客户端发送`shutdownServer()`命令来优雅地关闭服务。 - 示例:在MongoDB...

    MongoDB之conf配置文件详解

    MongoDB的oplog日志记录等级是指mongoDB服务器的oplog日志记录方式。这个设置非常重要,因为它将影响mongoDB的日志记录和故障诊断。在生产环境中,通常将oplog日志记录等级设置为true,以提高性能和可靠性。 十三、...

    mongodb 非关系型数据库

    MongoDB 是一个流行的开源、非关系型数据库系统,它属于NoSQL数据库的一种,以其灵活性、高性能和可扩展性而受到广泛关注。MongoDB的设计理念是处理大量数据并支持高并发读写操作,尤其适合于需要存储半结构化或结构...

    一键启动/关闭MongoDB

    一键启动/关闭MongoDB

    linux安装mongodb教程

    将解压后的 MongoDB 安装包复制到 /usr/local/mongodb/ 目录下,并创建以下结构: * /usr/local/mongodb/mongodb-linux-2.0.7/ * /usr/local/mongodb/mongodb-linux-2.0.7/logs/ * /usr/local/mongodb/mongodb-...

    MongoDB入门指南.pdf

    MongoDB中的每一行记录就是一个文档,它是一个由键值对构成的数据结构,MongoDB文档与JSON对象类似。键的值可以包含其他的文档、数组、文档数组。 MongoDB的主要特点包括: 1. 高性能:MongoDB使用了高性能的存储...

    非关系型数据库MongoDb

    安装Mongo数据库:  在发布本文的时间官方提供的最新版本是:1.6.5 ,如果不做特殊声明,本教程所用的版本将会是这个...记住,以上窗口不要关闭,重新开一个窗口,到D:\MongoDb输入mongo.exe你就可以查询数据库啦

    MongoDB非关系型数据库存储设计

    MongoDB非关系型数据库存储设计

    mongodb7.0.0安装包

    MongoDB是一款开源、高性能、无...MongoDB 7.0.0版本可能引入了新的特性、改进和修复,因此在升级前,建议阅读官方文档,了解新版本的详细信息和可能的影响。同时,定期更新到最新版本有助于保持系统的安全性和性能。

    MongoDB实验 - .docx

    在安装完成后,我们需要配置 MongoDB,编辑 `/etc/mongod.conf` 文件,添加以下内容: ``` systemLog: destination: file path: /var/log/mongodb/mongod.log logAppend: true storage: dbPath: /var/lib/mongo ...

    Mongodb连接池for java

    当连接不再使用时,它们会被放回池中,等待下一次被复用,而非直接关闭。这种方式可以显著提高系统效率,尤其在处理大量并发请求时。 在标签中,“MongoDB”是数据库的名字,“Mongo连接池”指的是针对MongoDB...

    mongodb4.4.6安装包

    3. **安全增强**:MongoDB持续加强安全特性,4.4.6可能包含了安全漏洞的修复和认证授权机制的强化。 4. **多文档事务**:在4.x系列中,MongoDB实现了跨文档的ACID事务,提高了应用程序的复杂性处理能力。 接下来,...

    mongoDB非关系型数据库第一天建表语句

    MongoDB是一种流行的开源、分布式、无模式的非关系型数据库(NoSQL),它以其灵活性、高性能和可扩展性而受到广泛关注。在MongoDB中,数据以文档的形式存储,每个文档都是一个JSON(JavaScript Object Notation)...

    MongoDB4.2.21 Linux版本安装包

    MongoDB是一款高性能、无模式的分布式文档型数据库,被广泛应用于大数据分析、内容管理系统、物联网(IoT)、实时应用程序和地理位置...同时,记得关注MongoDB的更新,及时升级到最新版本,以获得最新的特性和安全修复。

    非关联数据库mongodb 的demo

    MongoDB是一款非常流行的开源、非关系型数据库系统,属于NoSQL数据库的一种,它以其灵活性、高性能和可扩展性而受到广泛关注。在这个“非关联数据库mongodb的demo”中,我们可以探索MongoDB的一些核心特性以及如何...

    mongodb linux 64位安装包

    在MongoDB shell中输入`db.runCommand({connectionStatus : 1})`,如果返回的结果中`ok`字段为1,则表示MongoDB已正常运行。 以上就是在Linux 64位系统上安装MongoDB 3.4.7的基本步骤。请注意,MongoDB的版本更新...

    mongodb c#驱动最新驱动mongodb.driver.dll 版本2.12.0-beta1

    MongoDB 是一个流行的开源、基于分布式文件存储的数据库系统,主要设计用于处理大量数据的分布式环境。C# 驱动是 MongoDB 提供的一种客户端库,允许 .NET 开发者与 MongoDB 数据库进行交互。标题提到的是 MongoDB 的...

Global site tag (gtag.js) - Google Analytics