permission error after mongodb dbpath change

982 Views Asked by At

I have moved my mongodb db path to a different mount location as my root directory was getting full. I moved it to a much bigger partition that is mounted under my home directory (which is also a separate partition from root).

First I stopped mongod, then I ran

cp -ra /var/lib/mongodb $HOME/archive/mongodb

to copy the old dbpath over while preserving the permissions and timestamps and everything else as expected.

I checked the 2 directories and everything is the same, group is daemon and user is mongodb.

Yet, for some reason I am getting the following permission error in mongodb.log each time I try to start up mongo:

sudo systemctl start mongodb


Fri Nov  8 14:15:36.412 [initandlisten] options: { bind_ip: "10.10.11.101", config: "/etc/mongodb.conf", dbpath: "/home/dave/archive/mongodb", logappend: "true", logpath: "/var/log/mongodb/mongod.log", quiet: true, rest: "true" }
Fri Nov  8 14:15:36.412 [initandlisten] exception in initAndListen std::exception: boost::filesystem::status: Permission denied: "/home/dave/archive/mongodb", terminating

This is the output of the permissions:

ls -alt $HOME/archive/mongodb

drwxr-xr-x  4 mongodb daemon      4096 Nov  8 13:26 .
drwxrwxr-x 14 dave    users       4096 Nov  8 12:57 ..
drwxr-xr-x  2 mongodb daemon      4096 Nov  8 12:29 journal

I have also run chown -R several times, just to be sure.

I even added mongodb user to the users group in the case that was hanging things up since the group of the archive directory is users. Still not working though.

Could it be some kind of fstab issue?

UUID=88356ad7-9b85-402e-a0ab-86547fae9bcd /home ext4 defaults,user_xattr 0 1

UUID=db4a13df-62df-46eb-8c0d-809d5f2c312f /home/dave/archive ext4 defaults,user_xattr 0 1

Thanks for any ideas.

Edit: I ended up using another drive and mounting that to a newly defined directory at /mnt/data and now everything works, but I still am very interested to know why the above would not work as I set both up the same way, using cp -ra.

1

There are 1 best solutions below

0
On

related to security context at Centos 7

chown -R mongod:mongod /home/dave/archive/mongodb

chcon -Rv --type=mongod_var_lib_t /home/dave/archive/mongodb