mongodb启动失败

现象:
查看日志的内容如下
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 .
  • 1
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值