mongodb.lock许可否认

时间:2012-03-15 02:10:18

标签: mongodb archlinux

在Arch Linux 64bit上使用MongoDb。全新安装。以root身份尝试:

/etc/rc.d/mongodb start

日志说:

***** SERVER RESTARTED *****


Thu Mar 15 12:00:18 BackgroundJob starting: DataFileSync
Thu Mar 15 12:00:18 versionCmpTest passed
Thu Mar 15 12:00:18 versionArrayTest passed
Thu Mar 15 12:00:18 shardObjTest passed
Thu Mar 15 12:00:18 shardKeyTest passed
Thu Mar 15 12:00:18 isInRangeTest passed
Thu Mar 15 12:00:18 [initandlisten] MongoDB starting : pid=580 port=27017 dbpath=/data/db 64-bit host=(none)
Thu Mar 15 12:00:18 [initandlisten] db version v2.0.3, pdfile version 4.5
Thu Mar 15 12:00:18 [initandlisten] git version: nogitversion
Thu Mar 15 12:00:18 [initandlisten] build info: Linux brynhild.archlinux.org 3.2.6-1-ARCH #1 SMP PREEMPT Tue Feb 14 09:11:26 CET 2012 x86_64 BOOST_LIB_VERSION=1_49
Thu Mar 15 12:00:18 [initandlisten] options: { config: "/etc/mongodb.conf", dbpath: "/data/db", fork: true, journal: "true", logappend: "true", logpath: "/var/log/mongodb/mongodb.log", port: 27017, rest: "true", vvvv: "true" }
Thu Mar 15 12:00:18 [initandlisten] User Assertion: 10309:Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?
Thu Mar 15 12:00:18 [initandlisten] exception in initAndListen: 10309 Unable to create/open lock file: /data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
Thu Mar 15 12:00:18 dbexit: 
Thu Mar 15 12:00:18 [initandlisten] shutdown: going to close listening sockets...
Thu Mar 15 12:00:18 [initandlisten] shutdown: going to flush diaglog...
Thu Mar 15 12:00:18 [initandlisten] shutdown: going to close sockets...
Thu Mar 15 12:00:18 [initandlisten] shutdown: waiting for fs preallocator...
Thu Mar 15 12:00:18 [initandlisten] shutdown: lock for final commit...
Thu Mar 15 12:00:18 [initandlisten] shutdown: final commit...
Thu Mar 15 12:00:18 [initandlisten] shutdown: closing all files...
Thu Mar 15 12:00:18 [initandlisten] closeAllFiles() finished
Thu Mar 15 12:00:18 [initandlisten] shutdown: removing fs lock...
Thu Mar 15 12:00:18 [initandlisten] couldn't remove fs lock errno:9 Bad file descriptor
Thu Mar 15 12:00:18 dbexit: really exiting now

目录和文件持久性:

[root@(none) ~]# ls -lisa /data/db/
total 12
262711 4 drwxr-xr-x 3 root root 4096 Mar 15 11:43 .
262710 4 drwxr-xr-x 3 root root 4096 Mar 15 11:25 ..
262714 4 drwxr-xr-x 2 root root 4096 Mar 15 11:43 journal
261775 0 -rwxr-xr-x 1 root root    0 Mar 15 11:43 mongod.lock

MongoDB conf:

port = 27017
dbpath = /data/db
logpath = /var/log/mongodb/mongodb.log
logappend = true
vvvv = true
journal = true
rest = true

我可以通过mongod启动MongoDB实例,但不能像上面那样在后台启动。任何帮助都会很棒,谢谢。

2 个答案:

答案 0 :(得分:7)

我验证了/etc/rc.d/mongodb,我认为它将使用mongodb用户来运行该服务:

[ -z "$PID" ] && /bin/su mongodb -c "/usr/bin/mongod --config /etc/mongodb.conf --fork" > /dev/null

我认为这个错误可能是由使用root运行mongod引起的,因此mongod.lock的所有者被更改为root。

答案 1 :(得分:0)

  

我可以通过mongod启动MongoDB实例,但不能像上面那样在后台启动

以这种方式启动mongod时,您实际上是否使用所有相同的参数启动它?锁定文件仅适用于该特定文件夹。

要检查的事项:

  1. 是否已有mongod正在运行的实例(ps -ef | grep mongod)?
  2. 该端口上还有其他东西在运行吗?
  3. 你的配置是否正确?为什么你有--journal命令,这不应该是--nojournal in v2.0+或者什么都不是?