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
...
分享到:
相关推荐
本资料是在线教育课程第一天中使用的mongoDB的安装资料以及使用指南
将房产系统在一年多来使用的mongodb管理方面上做了一些基本管理操作的记录,包括了安装启动,还有对mongodb进行监控,备份和修复,安全认证等等,当然了,还没有涉及到分片
介绍php7.0以上使用mongdb的基本方法,并提供mongodb随机获取一条记录的测试实例。
主要介绍了使用aggregate在MongoDB中查询重复数据记录的方法的相关资料,需要的朋友可以参考下
一键启动/关闭MongoDB
mongodb 非关系型数据库 centos 安装好的文件夹,下载解压即可
安装Mongo数据库: 在发布本文的时间官方提供的最新版本是:1.6.5 ,如果不做特殊声明,本教程所用的版本将会是这个...记住,以上窗口不要关闭,重新开一个窗口,到D:\MongoDb输入mongo.exe你就可以查询数据库啦
MongoDB非关系型数据库存储设计
MongoDB非关系型数据库入门资料
MongoDB主从环境搭建;MongoDB主从环境搭建MongoDB主从环境搭建MongoDB主从环境搭建
MongoDB权威指南(第2版) 文字版 非扫描, 假一赔十。
非关联数据库mongodb 的demo,
人工智能-项目实践-深度学习-基于Kafka和MongoDB的结构化日志异步记录和预警框架 简介 breeze是一个基于Java开发的结构化日志异步记录和预警框架。实际上你可以使用它来实现任何结构化的(或理解为POJO的)数据,但...
一、MongoDB简介 3 二、MongoDB结构 3 二、MongoDB 数据库关系型(这里并不是值关系型数据库的关系) 3 1、MongoDB一对一关系型 3 2、MongoDB一对多关系型 4 3、MongoDB多对多关系型 4 三、创建数据库(mongodb_test...
MongoDB 的 Capped Collection是一个天生的日志系统,MongoDB自己的oplog就是用它来存储的,Capped Collection的特点是可以指定Collection的大小,当记录总大小超过设定大小后,老的数据会被自动抹掉用于存储新的...
本课程是一套关于MongoDB应用开发的实战性教程,名为《深入浅出MongoDB应用实战开发(基础、开发指南、系统管理、集群及系统架构)》,教程侧重于讲解MongoDB的常用特性及高级特性,从实际开发的角度出发对MongoDB...
sudo vim /etc/yum.repos.d/mongodb-org-4.2.repo 写入: [mongodb-org-4.2] name=MongoDB Repository baseurl=https://repo.mongodb.org/yum/redhat/$releasever/mongodb-org/4.2/x86_64/ gpgcheck=1 enabled=1 gpg...
资源名称:MongoDB应用设计模式内容简介:无论是在构建社交媒体网站,还是在开发一个仅在内部使用的企业应用程序,《MongoDB应用设计模式》展示了MongoDB需要解决的商业问题之间的连接。你将学到如何把MongoDB设计...
MongoDB 学习PPT
Mybatis拦截器记录数据更新历史记录到MongoDB的源码,另外需要配置拦截器到mybatis配置文件中。