A
A
Alexey Solovyov2021-10-29 15:39:13
MongoDB
Alexey Solovyov, 2021-10-29 15:39:13

How to make MongoDB data folder on nfs?

Good day,

there is a folder connected via nfs as standard in /etc/fstab with a line like

10.1.1.30:/mnt/pool/DBASE /mnt/share3 nfs rw,relatime,user,bg,hard,nolock,noatime,nointr 0 0

with all the keys recommended in the MongoDB documentation

If you start mongod as a user, that is
sudo mongod --dbpath /mnt/share3 --bind_ip 127.0.0.1,10.1.1.32

then everything starts and works.

If you start as a service (by adding /mnt/share3 to /etc/mongod.conf)
sudo service mongod start
sudo service mongod status

then in mongod.service status: Main process exited, code=exited, status=100
in /var/log/mongodb/mongod.log can be found
""Location28596: Unable to determine status of lock file in the data directory /mnt/share3/: boost::filesystem::status: Permission denied: \"/mnt/share3/mongod.lock\""


Googling this error indicates that mongodb from the service does not have enough rights and is advised to chown to the folder with the .lock file. The problem is that as soon as I mount nfs in /mnt/share3 the owner of the directory automatically becomes nobody, disconnect-change owner-attach still leads to the owner of nobody. I did not find normal manuals on how to install MongoDB on nfs. If the folder is in the local system, then chown helps and the service starts. But on nfs - no. Tell me, please, how can I solve this problem?

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
Saboteur, 2021-10-29
@saboteur_kiev

If you start mongod as a user, that is,
sudo mongod --dbpath /mnt/share3 --bind_ip 127.0.0.1,10.1.1.32

So this is not from the user, but from the superuser (root)
10.1.1.30: /mnt/pool/DBASE /mnt/share3 nfs rw,relatime,user,bg,hard,nolock,noatime,nointr 0 0

user allows a normal user to mount a folder, though I forgot not sure what rights this gives
Try to mount directly from a specific user
10.1.1.30:/mnt/pool/DBASE /mnt/share3 nfs rw,relatime,uid=mongouser,gid=mongouser,bg,hard,nolock,noatime,nointr 0 0

and /mnt/share3 should be owned by mongouser

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question