mongodb启动失败

2012年4月2日 发表评论 阅读评论


现象:
查看日志的内容如下
Tue Jan  4 09:51:37 MongoDB starting : pid=2794 port=27017 dbpath=/var/lib/mongodb 32-bit

** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
**       see http://blog.mongodb.org/post/137788967/32-bit-limitations

Tue Jan  4 09:51:37 db version v1.6.5, pdfile version 4.5
Tue Jan  4 09:51:37 git version: 0eb017e9b2828155a67c5612183337b89e12e291
Tue Jan  4 09:51:37 sys 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
**************
old lock file: /var/lib/mongodb/mongod.lock.  probably means unclean shutdown
recommend removing file and running –repair
see: http://dochub.mongodb.org/core/repair for more information
*************
Tue Jan  4 09:51:37 exception in initAndListen std::exception: old lock file, terminating
Tue Jan  4 09:51:37 dbexit:

Tue Jan  4 09:51:37 shutdown: going to close listening sockets…
Tue Jan  4 09:51:37 shutdown: going to flush oplog…
Tue Jan  4 09:51:37 shutdown: going to close sockets…
Tue Jan  4 09:51:37 shutdown: waiting for fs preallocator…
Tue Jan  4 09:51:37 shutdown: closing all files…
Tue Jan  4 09:51:37     closeAllFiles() finished

Tue Jan  4 09:51:37 dbexit: really exiting now

解决办法:
sudo rm /****/***/mongodb/mongodb.log
sudo rm /***/***/mongodb/mongod.lock
sudo /usr/bin/mongod –repair –dbpath /var/lib/mongodb/ –repairpath /tmp/mongodb



现象:
Sat Jan 29 12:35:35 MongoDB starting : pid=8298 port=27017 dbpath=/var/lib/mongodb 32-bit

** NOTE: when using MongoDB 32 bit, you are limited to about 2 gigabytes of data
**       see http://blog.mongodb.org/post/137788967/32-bit-limitations

Sat Jan 29 12:35:35 db version v1.6.5, pdfile version 4.5
Sat Jan 29 12:35:35 git version: 0eb017e9b2828155a67c5612183337b89e12e291
Sat Jan 29 12:35:35 sys 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
Sat Jan 29 12:35:35 exception in initAndListen std::exception: Unable to create / open lock file for lockfilepath: /var/lib/mongodb/mongod.lock errno:13 Permission denied, terminating
Sat Jan 29 12:35:35 dbexit:

Sat Jan 29 12:35:35 shutdown: going to close listening sockets…
Sat Jan 29 12:35:35 shutdown: going to flush oplog…
Sat Jan 29 12:35:35 shutdown: going to close sockets…
Sat Jan 29 12:35:35 shutdown: waiting for fs preallocator…
Sat Jan 29 12:35:35 shutdown: closing all files…
Sat Jan 29 12:35:35     closeAllFiles() finished

Sat Jan 29 12:35:35 shutdown: removing fs lock…
Sat Jan 29 12:35:35 couldn’t remove fs lock errno:9 Bad file descriptor
Sat Jan 29 12:35:35 dbexit: really exiting now

解决方法:

  • Manually remove the lockfile: sudo rm /var/lib/mongodb/mongod.lock
  • Run the repair script: sudo -u mongodb /usr/bin/mongod -f /etc/mongodb.conf –repair.
    • You must run this command as the mongodb user. If you run it as root, then root will own files in /var/lib/mongodb/ that are necessary to run the mongodb daemon and therefore when the daemon trys to run later as the mongodb user, it won’t have permissions to start. In that case you’ll get this error: Unable to create / open lock file for lockfilepath: /var/lib/mongodb/mongod.lock errno:13 Permission denied, terminating.
    • On Ubuntu, you must specify the configuration file /etc/mongodb.conf using the -f flag. Otherwise it will look for the data files in the wrong place and you will see the following error: dbpath (/data/db/) does not exist, terminating.
  • Now you can start your MongoDB server with sudo start mongodb and verify it is running with sudo status mongodb and by trying to connect to it with mongo test.


转载请注明来自:[MSN Spaces]http://msn.shandian.biz/112.html

  1. 本文目前尚无任何评论.