Mongodb.lock permission is prohibited

Using MongoDb on Arch Linux 64bit. New installation. Attempt with root privileges:

/etc/rc.d/mongodb start 

The magazine 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 

Interception of directories and files:

 [ 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 an instance of MongoDB using mongod , but not in the background as above. Any help would be great, thanks.

+4
source share
2 answers

I confirmed /etc/rc.d/mongodb and I think that he will use the mongodb user to start the service:

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

I think this error can be caused by running mongod using root, so the owner of mongod.lock will be changed to root.

+7
source

I can start an instance of MongoDB using mongod, but not in the background as above

When you start mongod this way, do you start it with all the same parameters? The lock file is for this particular folder only.

What you need to check:

  • Is there already a mongod running instance ( ps -ef | grep mongod )?
  • Is there anything else on this port?
  • Are you set up right? Why do you have the --journal command, should it not be --nojournal in version 2.0 + or just nothing?
0
source

Source: https://habr.com/ru/post/1401510/


All Articles