mongodb 关闭无法正常启动, use –journal

Tue Aug 21 09:12:20

Tue Aug 21 09:12:20 warning: 32-bit servers don’t have journaling enabled by default. Please use –journal if you want durability.

Tue Aug 21 09:12:20

Tue Aug 21 09:12:20 [initandlisten] MongoDB starting : pid=1192 port=27017 dbpath=/Users/mc2/mongo/db 32-bit host=localhost

Tue Aug 21 09:12:20 [initandlisten]

Tue Aug 21 09:12:20 [initandlisten] ** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data

Tue Aug 21 09:12:20 [initandlisten] **?????? see http://blog.mongodb.org/post/137788967/32-bit-limitations

Tue Aug 21 09:12:20 [initandlisten] **?????? with –journal, the limit is lower

Tue Aug 21 09:12:20 [initandlisten]

Tue Aug 21 09:12:20 [initandlisten] db version v2.0.2, pdfile version 4.5

Tue Aug 21 09:12:20 [initandlisten] git version: 514b122d308928517f5841888ceaa4246a7f18e3

Tue Aug 21 09:12:20 [initandlisten] build info: Darwin broadway.local 9.8.0 Darwin Kernel Version 9.8.0: Wed Jul 15 16:55:01 PDT 2009; root:xnu-1228.15.4~1/RELEASE_I386 i386 BOOST_LIB_VERSION=1_40

Tue Aug 21 09:12:20 [initandlisten] options: { dbpath: “/Users/mc2/mongo/db”, logpath: “/Users/mc2/mongo/log.log” }

**************

Unclean shutdown detected.

Please visit http://dochub.mongodb.org/core/repair for recovery instructions.

*************

Tue Aug 21 09:12:20 [initandlisten] exception in initAndListen: 12596 old lock file, terminating

Tue Aug 21 09:12:20 dbexit:

Tue Aug 21 09:12:20 [initandlisten] shutdown: going to close listening sockets…

Tue Aug 21 09:12:20 [initandlisten] shutdown: going to flush diaglog…

Tue Aug 21 09:12:20 [initandlisten] shutdown: going to close sockets…

Tue Aug 21 09:12:20 [initandlisten] shutdown: waiting for fs preallocator…

Tue Aug 21 09:12:20 [initandlisten] shutdown: closing all files…

Tue Aug 21 09:12:20 [initandlisten] closeAllFiles() finished

Tue Aug 21 09:12:20 dbexit: really exiting now

造成原因

ps aux|grep mongol

kill -9

这个强行杀进程的办法会导致mongodb 数据库出现无法启动的情况。

正确的关闭数据库方式为

use admin

db.shutdownServer()

也可以按照文档粗暴的杀掉它,它内部应该有KILL信号处理程序。

killall mongod

请不要 kill -9 会发生最后文件损坏的情况。

解决方法:进入 mongod 上一次启动的时候指定的 data 目录? –dbpath=/Users/mc2/mongo/db

 

cd /Users/mc2/mongo/db

 

 

 

删除掉该文件:

 

rm /Users/mc2/mongo/db/mongo.lock

 

再执行:

 

./mongod? –repair

 

启动

bin/mongod -dbpath /Users/mc2/mongo/db -logpath /Users/mc2/mongo/log.log &

 

礼成


This entry was posted in JAVA, MAC, PHP, 数据库, 高并发与大数据 and tagged . Bookmark the permalink.
月小升QQ 2651044202, 技术交流QQ群 178491360
首发地址:月小升博客https://java-er.com/blog/mongodb-close/
无特殊说明,文章均为月小升原创,欢迎转载,转载请注明本文地址,谢谢
您的评论是我写作的动力.
2020.03.24 评论已经全局关闭,有事加QQ聊天