Joe
Joe

Reputation: 777

Mongod is not working in Jenkins with "Unable to create/open lock file"

I am using mongo for local integration tests, which has been working for weeks on a few developer's systems. The test suite starts mongo and prepares it for the test. I decided to use the same testing on Jenkins, but Jenkins fails to start mongod. We are using the command mongod --dbpath tmp/data/db before each test run. In Jenkins we get

+ mongod --dbpath tmp/data/db
2015-12-23T10:59:17.291-0500 I CONTROL  [initandlisten] MongoDB starting : pid=9962 port=27017 dbpath=tmp/data/db 64-bit host=ip-172-31-46-41.us-west-2.compute.internal
2015-12-23T10:59:17.291-0500 I CONTROL  [initandlisten] db version v3.0.8
2015-12-23T10:59:17.291-0500 I CONTROL  [initandlisten] git version: 83d8cc25e00e42856924d84e220fbe4a839e605d
2015-12-23T10:59:17.291-0500 I CONTROL  [initandlisten] build info: Linux ip-10-142-160-199 3.10.0-121.el7.x86_64 #1 SMP Tue Apr 8 10:48:19 EDT 2014 x86_64 BOOST_LIB_VERSION=1_49
2015-12-23T10:59:17.291-0500 I CONTROL  [initandlisten] allocator: tcmalloc
2015-12-23T10:59:17.291-0500 I CONTROL  [initandlisten] options: { storage: { dbPath: "tmp/data/db" } }
2015-12-23T10:59:17.314-0500 I STORAGE  [initandlisten] exception in initAndListen: 98 Unable to create/open lock file: tmp/data/db/mongod.lock errno:13 Permission denied Is a mongod instance already running?, terminating
2015-12-23T10:59:17.314-0500 I CONTROL  [initandlisten] dbexit:  rc: 100

This is strange since the folders do exist with no files in them and jenkins owns the folders tmp/data/db with the settings drwxr-xr-x. I modified the user jenkins to create a shell and ran the command just like jenkins. This of course, ran correctly. Any thoughts on what might be the problem?

Upvotes: 0

Views: 1401

Answers (1)

Adam
Adam

Reputation: 550

It looks like a permissions issue still, so try running:

$ sudo mkdir -p tmp/data/db/
$ sudo chown jenkins tmp/data/db

Upvotes: 2

Related Questions