情况再现,连接mongodb的网站没有关,直接关闭了mongodb的cmd窗口。再次打开mongodb出现失败。
解决办法:网上说是删除 *.lock文件,再进行 --repair ,最后再打开mongodb就可以了(我没有删除 *.lock,也可以)
参考: http://dochub.mongodb.org/core/repair for recovery instructions.
D:mongodbin>mongod --dbpath d:mongodbdatadb
2015-07-03T07:59:56.140+0800 I CONTROL
2015-07-03T07:59:56.140+0800 W CONTROL 32-bit servers don't have journaling ena bled by default. Please use --journal if you want durability.
2015-07-03T07:59:56.140+0800 I CONTROL
2015-07-03T07:59:56.171+0800 W - [initandlisten] Detected unclean shutdow n - d:mongodbdatadbmongod.lock is not empty.
2015-07-03T07:59:56.187+0800 I STORAGE [initandlisten] **************
Unclean shutdown detected.
Please visit http://dochub.mongodb.org/core/repair for recovery instructions.
*************
2015-07-03T07:59:56.187+0800 I STORAGE [initandlisten] exception in initAndList en: 12596 old lock file, terminating
2015-07-03T07:59:56.187+0800 I CONTROL [initandlisten] dbexit: rc: 100
D:mongodbin>mongod --dbpath d:mongodbdatadb --repair
2015-07-03T08:37:23.937+0800 I CONTROL
2015-07-03T08:37:23.937+0800 W CONTROL 32-bit servers don't have journaling ena bled by default. Please use --journal if you want durability.
2015-07-03T08:37:23.937+0800 I CONTROL
2015-07-03T08:37:23.953+0800 W - [initandlisten] Detected unclean shutdow n - d:mongodbdatadbmongod.lock is not empty.
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten] MongoDB starting : pid=3 356 port=27017 dbpath=d:mongodbdatadb 32-bit host=WWW-AB2946767CC
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten]
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten] ** NOTE: This is a 32 bi t MongoDB binary.
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten] ** 32 bit builds a re limited to less than 2GB of data (or less with --journal).
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten] ** Note that journ aling defaults to off for 32 bit and is currently off.
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten] ** See http://doch ub.mongodb.org/core/32bit
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten]
2015-07-03T08:37:23.984+0800 I CONTROL [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] ** uses to detect impending page faults.
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] ** This may result in slower performance for certain use cases
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten]
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] targetMinOS: Windows XP SP3
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] db version v3.0.4
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] git version: 0481c958dae b2969800511e7475dc66986fa9ed5
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] build info: windows sys. getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Servic e Pack 1') BOOST_LIB_VERSION=1_49
2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] allocator: tcmalloc 2015-07-03T08:37:24.000+0800 I CONTROL [initandlisten] options: { repair: true, storage: { dbPath: "d:mongodbdatadb" } }
2015-07-03T08:37:24.250+0800 I STORAGE [initandlisten] repairDatabase local
2015-07-03T08:37:24.484+0800 I INDEX [initandlisten] allocating new ns file d :mongodbdatadb\_tmp_repairDatabase_0local.ns, filling with zeroes...
2015-07-03T08:37:24.812+0800 I STORAGE [FileAllocator] allocating new datafile d:mongodbdatadb\_tmp_repairDatabase_0local.0, filling with zeroes...
2015-07-03T08:37:24.812+0800 I STORAGE [FileAllocator] creating directory d:mo ngodbdatadb\_tmp_repairDatabase_0\_tmp
2015-07-03T08:37:24.812+0800 I STORAGE [FileAllocator] done allocating datafile d:mongodbdatadb\_tmp_repairDatabase_0local.0, size: 64MB, took 0 secs 2015-07-03T08:37:24.828+0800 I INDEX [initandlisten] build index on: local.st artup_log properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "local.startup_ log" }
2015-07-03T08:37:24.828+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.062+0800 I STORAGE [initandlisten] repairDatabase myworkblo gs
2015-07-03T08:37:25.312+0800 I INDEX [initandlisten] allocating new ns file d :mongodbdatadb\_tmp_repairDatabase_0myworkblogs.ns, filling with zeroes...
2015-07-03T08:37:25.578+0800 I STORAGE [FileAllocator] allocating new datafile d:mongodbdatadb\_tmp_repairDatabase_0myworkblogs.0, filling with zeroes...
2015-07-03T08:37:25.578+0800 I STORAGE [FileAllocator] creating directory d:mo ngodbdatadb\_tmp_repairDatabase_0\_tmp
2015-07-03T08:37:25.578+0800 I STORAGE [FileAllocator] done allocating datafile d:mongodbdatadb\_tmp_repairDatabase_0myworkblogs.0, size: 64MB, took 0 sec s
2015-07-03T08:37:25.593+0800 I INDEX [initandlisten] build index on: myworkbl ogs.app_updates properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "myworkbl ogs.app_updates" }
2015-07-03T08:37:25.593+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.593+0800 I INDEX [initandlisten] build index on: myworkbl ogs.app_updates properties: { v: 1, key: { key: 1 }, name: "key_1", ns: "myworkb logs.app_updates", background: true, safe: null }
2015-07-03T08:37:25.593+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.609+0800 I INDEX [initandlisten] build index on: myworkbl ogs.galleries properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "myworkblog s.galleries" }
2015-07-03T08:37:25.609+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.609+0800 I INDEX [initandlisten] build index on: myworkbl ogs.galleries properties: { v: 1, unique: true, key: { key: 1 }, name: "key_1", ns: "myworkblogs.galleries", background: true, safe: null }
2015-07-03T08:37:25.609+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.625+0800 I INDEX [initandlisten] build index on: myworkbl ogs.postcategories properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "mywor kblogs.postcategories" }
2015-07-03T08:37:25.625+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.625+0800 I INDEX [initandlisten] build index on: myworkbl ogs.postcategories properties: { v: 1, unique: true, key: { key: 1 }, name: "key _1", ns: "myworkblogs.postcategories", background: true, safe: null }
2015-07-03T08:37:25.625+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] build index on: myworkbl ogs.posts properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "myworkblogs.po sts" }
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] build index on: myworkbl ogs.posts properties: { v: 1, unique: true, key: { slug: 1 }, name: "slug_1", ns : "myworkblogs.posts", background: true, safe: null }
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] build index on: myworkbl ogs.posts properties: { v: 1, key: { state: 1 }, name: "state_1", ns: "myworkblo gs.posts", background: true, safe: null }
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] build index on: myworkbl ogs.posts properties: { v: 1, key: { author: 1 }, name: "author_1", ns: "myworkb logs.posts", background: true, safe: null }
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] build index on: myworkbl ogs.posts properties: { v: 1, key: { publishedDate: 1 }, name: "publishedDate_1" , ns: "myworkblogs.posts", background: true, safe: null }
2015-07-03T08:37:25.640+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.656+0800 I INDEX [initandlisten] build index on: myworkbl ogs.users properties: { v: 1, key: { _id: 1 }, name: "_id_", ns: "myworkblogs.us ers" }
2015-07-03T08:37:25.656+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.656+0800 I INDEX [initandlisten] build index on: myworkbl ogs.users properties: { v: 1, key: { email: 1 }, name: "email_1", ns: "myworkblo gs.users", background: true, safe: null }
2015-07-03T08:37:25.656+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.656+0800 I INDEX [initandlisten] build index on: myworkbl ogs.users properties: { v: 1, key: { isAdmin: 1 }, name: "isAdmin_1", ns: "mywor kblogs.users", background: true, safe: null }
2015-07-03T08:37:25.656+0800 I INDEX [initandlisten] building index using bulk method
2015-07-03T08:37:25.875+0800 I STORAGE [initandlisten] finished checking dbs
2015-07-03T08:37:25.875+0800 I CONTROL [initandlisten] now exiting
2015-07-03T08:37:25.875+0800 I NETWORK [initandlisten] shutdown: going to close listening sockets...
2015-07-03T08:37:25.875+0800 I NETWORK [initandlisten] shutdown: going to flush diaglog...
2015-07-03T08:37:25.875+0800 I NETWORK [initandlisten] shutdown: going to close sockets...
2015-07-03T08:37:25.875+0800 I STORAGE [initandlisten] shutdown: waiting for fs preallocator...
2015-07-03T08:37:25.890+0800 I STORAGE [initandlisten] shutdown: closing all fi les...
2015-07-03T08:37:25.890+0800 I STORAGE [initandlisten] closeAllFiles() finished
2015-07-03T08:37:25.890+0800 I STORAGE [initandlisten] shutdown: removing fs lo ck...
2015-07-03T08:37:25.890+0800 I CONTROL [initandlisten] dbexit: rc: 0
D:mongodbin>mongod --dbpath d:mongodbdatadb
2015-07-03T08:37:31.500+0800 I CONTROL 2015-07-03T08:37:31.500+0800 W CONTROL 32-bit servers don't have journaling ena bled by default. Please use --journal if you want durability. 2015-07-03T08:37:31.500+0800 I CONTROL 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] MongoDB starting : pid=2 852 port=27017 dbpath=d:mongodbdatadb 32-bit host=WWW-AB2946767CC 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] ** NOTE: This is a 32 bi t MongoDB binary. 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] ** 32 bit builds a re limited to less than 2GB of data (or less with --journal). 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] ** Note that journ aling defaults to off for 32 bit and is currently off. 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] ** See http://doch ub.mongodb.org/core/32bit 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] ** NOTE: your operating system version does not support the method that MongoDB 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] ** uses to detect impending page faults. 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] ** This may result in slower performance for certain use cases 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] targetMinOS: Windows XP SP3 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] db version v3.0.4 2015-07-03T08:37:31.531+0800 I CONTROL [initandlisten] git version: 0481c958dae b2969800511e7475dc66986fa9ed5 2015-07-03T08:37:31.546+0800 I CONTROL [initandlisten] build info: windows sys. getwindowsversion(major=6, minor=1, build=7601, platform=2, service_pack='Servic e Pack 1') BOOST_LIB_VERSION=1_49 2015-07-03T08:37:31.546+0800 I CONTROL [initandlisten] allocator: tcmalloc 2015-07-03T08:37:31.546+0800 I CONTROL [initandlisten] options: { storage: { db Path: "d:mongodbdatadb" } } 2015-07-03T08:37:31.578+0800 I NETWORK [initandlisten] waiting for connections on port 27017