Question

Using MongoDb on Arch Linux 64bit. Brand new install. Trying as root:

/etc/rc.d/mongodb start

Log says:

***** 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

Directory and file persmissions:

[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

I can start a MongoDB instance by mongod, but not in the background as above. Any help would be great, thanks.

Was it helpful?

Solution

I verified /etc/rc.d/mongodb, and I think it will use mongodb user to run the service:

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

I think this error may caused by run mongod using root, so the owner of the mongod.lock is changed to root.

OTHER TIPS

I can start a MongoDB instance by mongod, but not in the background as above

When you start mongod this way are you actually starting it with all of the same parameters? The lock file is only for that specific folder.

Things to check:

  1. Is there already an instance of mongod running (ps -ef | grep mongod)?
  2. Is there something else running on that port?
  3. Are you configs correct? Why do you have the --journal command, shouldn't this be --nojournal in v2.0+ or simply nothing?
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top