ubuntu - 为什么我不能启动mongodb

这是错误:

(mysite)zjm1126@zjm1126-G41MT-S2:~$ /usr/local/mongodb/bin/mongod 
/usr/local/mongodb/bin/mongod --help for help and startup options
Wed Apr 27 10:02:41 [initandlisten] MongoDB starting : pid=2652 port=27017 dbpath=/data/db/ 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
**       with --dur, the limit is lower

Wed Apr 27 10:02:41 [initandlisten] db version v1.8.1, pdfile version 4.5
Wed Apr 27 10:02:41 [initandlisten] git version: a429cd4f535b2499cc4130b06ff7c26f41c00f04
Wed Apr 27 10:02:41 [initandlisten] build sys info: Linux bs-linux32.10gen.cc 2.6.21.7-2.fc8xen #1 SMP Fri Feb 15 12:39:36 EST 2008 i686 BOOST_LIB_VERSION=1_37
Wed Apr 27 10:02:41 [initandlisten] exception in initAndListen std::exception: Unable to create / open lock file for lockfilepath: /data/db/mongod.lock errno:13 Permission denied, terminating
Wed Apr 27 10:02:41 dbexit: 
Wed Apr 27 10:02:41 [initandlisten] shutdown: going to close listening sockets...
Wed Apr 27 10:02:41 [initandlisten] shutdown: going to flush diaglog...
Wed Apr 27 10:02:41 [initandlisten] shutdown: going to close sockets...
Wed Apr 27 10:02:41 [initandlisten] shutdown: waiting for fs preallocator...
Wed Apr 27 10:02:41 [initandlisten] shutdown: closing all files...
Wed Apr 27 10:02:41 closeAllFiles() finished
Wed Apr 27 10:02:41 [initandlisten] shutdown: removing fs lock...
Wed Apr 27 10:02:41 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Wed Apr 27 10:02:41 dbexit: really exiting now

最佳答案

启动 MongoDB 的用户帐户需要对 /data/db/ 目录具有写入权限 ...您可以这样更改...

此命令会将 /data/db/ 的所有者更改为正在使用的用户帐户。

$ sudo chown `id -u` /data/db
$ mongod 

如果您在启动 MongoDB 时仍然遇到问题,您需要删除 /data/db/mongod.lock 然后对您的数据库运行修复...

mongod --repair

更多关于修复命令here .

https://stackoverflow.com/questions/5798549/

相关文章:

ruby-on-rails - Mongoid 3 + Heroku (MongoHQ) 导致 Mo

mongodb - 在键值数据存储中存储目录层次结构

php - Mongodb php获取新文档的ID?

mongodb - mongoexport 聚合导出到 csv 文件

mongodb - 在 MongoDB 中存储日期的最佳方式是什么?

ubuntu - MongoDB 仅在 Ubuntu 上以 root 身份运行时才有效 - 数据目录

node.js - 如何在 Mongoose 中执行 id 数组查询?

mongodb - 在MongoDB中获取数组的第n个元素

shell - MongoDB 正在运行但无法使用 shell 连接

javascript - 如何在 Mongoose 模型中定义方法?