启动mongod作为服务:
sudo service mongod start
(一旦我开始工作,我想在服务器通过chkconfig重新启动时启动mongod:
sudo /sbin/chkconfig --level 345 mongod on
)
它以[FAILED]返回,我在日志中收到此消息:
2014-08-27T03:17:40.126+0000 ***** SERVER RESTARTED *****
2014-08-27T03:17:40.132+0000 [initandlisten] MongoDB starting : pid=3950 port=27017 dbpath=/var/lib/mongo 64-bit host=162-144-108-42.ipage.com
2014-08-27T03:17:40.132+0000 [initandlisten] db version v2.6.4
2014-08-27T03:17:40.132+0000 [initandlisten] git version: 3a830be0eb92d772aa855ebb711ac91d658ee910
2014-08-27T03:17:40.132+0000 [initandlisten] build info: Linux build7.nj1.10gen.cc 2.6.32-431.3.1.el6.x86_64 #1 SMP Fri Jan 3 21:39:27 UTC 2014 x86_64 BOOST_LIB_VERSION=1_49
2014-08-27T03:17:40.132+0000 [initandlisten] allocator: tcmalloc
2014-08-27T03:17:40.132+0000 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, processManagement: { fork: true, pidFilePath: "/var/run/mongodb/mongod.pid" }, storage: { dbPath: "/var/lib/mongo" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-08-27T03:17:40.133+0000 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2014-08-27T03:17:40.133+0000 [initandlisten] dbexit:
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to close listening sockets...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to flush diaglog...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: going to close sockets...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: waiting for fs preallocator...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: lock for final commit...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: final commit...
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: closing all files...
2014-08-27T03:17:40.133+0000 [initandlisten] closeAllFiles() finished
2014-08-27T03:17:40.133+0000 [initandlisten] shutdown: removing fs lock...
2014-08-27T03:17:40.133+0000 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
2014-08-27T03:17:40.133+0000 [initandlisten] dbexit: really exiting now
点击当前进程找不到任何mongod进程:
ps aux | grep mongod
删除mongod.lock文件没有帮助:
sudo rm mongod.lock
更改数据库的所有者无济于事:
sudo chown -R my_username / var / lib / mongo
答案 0 :(得分:3)
这看起来像权限问题:
2014-08-27T03:17:40.133+0000 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /var/lib/mongo/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
查看运行mongo的用户是否具有在该文件夹上写入的权限,假设您已经删除了.lock文件。
您正在使用chown和您的用户名,但似乎用户必须是mongo,而不是您的用户名。当服务尝试启动时检查自己。
答案 1 :(得分:1)
我能够验证在我的CentOS系统上运行sudo chown -R mongodb /var/lib/mongo
是否有效。我的/etc/init.d/mongod脚本以用户mongod的身份运行mongod进程。当我做了一个sudo chown -R root / var / lib / mongo我收到了相同的Permission denied错误,但当我将目录权限设置为mongod(sudo chown -R mongodb /var/lib/mongo
)时,运行sudo service mongod start
工作