I've mounted my drive like so:
sudo mount /dev/sdb1 /media/usb2
and then I've modified the mongo.conf file to have the following dbpath
dbpath = /media/usb2/mongodb
I've created the mongodb folder on the usb drive. But what I'm noticing is that the database always fails to start with a permission issue. Which ... makes sense because it looks like ubuntu mounts the drive under the current user's name.
me@medev:/media/usb3$ ls -lah
total 36K
drwx------ 3 me me 16K Nov 10 16:13 .
drwxr-xr-x 5 root root 4.0K Nov 10 16:08 ..
drwx------ 2 me me 16K Nov 10 16:13 mongodb
And when I try to change the owner, i get an error:
me@medev:/media/usb2$ sudo chown -R mongodb:mongodb .
chown: changing ownership of ‘./mongodb’: Operation not permitted
chown: changing ownership of ‘.’: Operation not permitted
me@medev:/media/usb2$
Has anyone tried something like this? Is this possible on other versions of linux? I would like to get a prototype of mongoDB on USBs running if at all possible... and on ubuntu. But I'm willing to consider other distros if there's a high level of confidence that it'll work.
Perhaps I could try to add the mongod system user to the root group in ubuntu? Is that a safe thing to do?
Can you provide me with the required steps?
Seems you are trying to assing POSIX permissions to a filesystem that is not supported ie fat32, ntfs.
Format your USB Key to a filesystem that support POSIX permissions and try again. (ext4 for example)
using the disk utilities in ubuntu, i formatted my drive to be of type ext4.
this is what it says when i do an fdisk:Device Boot Start End Blocks Id System
/dev/sda1 * 2048 968613887 484305920 83 Linux
/dev/sda2 968615934 976771071 4077569 5 Extended
/dev/sda5 968615936 976771071 4077568 82 Linux swap / Solaris
Disk /dev/sdc: 7803 MB, 7803174912 bytes
241 heads, 62 sectors/track, 1019 cylinders, total 15240576 sectors
Units = sectors of 1 * 512 = 512 bytes
Sector size (logical/physical): 512 bytes / 512 bytes
I/O size (minimum/optimal): 512 bytes / 512 bytes
Disk identifier: 0x00000000
Disk /dev/sdc doesn't contain a valid partition table
I've named the drive / file system "mongotest". This is what the permissions look like :
me@medev:/media/me/mongotest$ ls -lah
total 28K
drwx------ 4 me me 4.0K Nov 11 09:05 .
drwxr-x---+ 3 root root 4.0K Nov 11 09:18 ..
drwx------ 2 root root 16K Nov 11 09:01 lost+found
drwxr-xr-x 2 root root 4.0K Nov 11 09:05 mongodb
me@medev:/media/me/mongotest$
2014-11-11T09:27:52.635-0500 [initandlisten] allocator: tcmalloc
2014-11-11T09:27:52.635-0500 [initandlisten] options: { config: "/etc/mongod.conf", net: { bindIp: "127.0.0.1" }, storage: { dbPath: "/media/me/mongotest/mongodb" }, systemLog: { destination: "file", logAppend: true, path: "/var/log/mongodb/mongod.log" } }
2014-11-11T09:27:52.635-0500 [initandlisten] exception in initAndListen std::exception: boost::filesystem::status: Permission denied: "/media/me/mongotest/mongodb", terminating
2014-11-11T09:27:52.635-0500 [initandlisten] dbexit:
I've checked the "mount" command and I can see that the drive is read /write:
/dev/sdb1 on /media/usb3 type vfat (rw,umask=000)
/dev/sdc on /media/me/mongotest type ext4 (rw,nosuid,nodev,uhelper= udisks2)
Seems something related to permissions :
2014-11-11T09:27:52.635-0500 [initandlisten] exception in initAndListen std::exception: boost::filesystem::status: Permission denied: "/media/me/mongotest/mongodb", terminating
/media/me/mongotest/mongodb has following permissions :
drwxr-xr-x 2 root root 4.0K Nov 11 09:05 mongodb
/media/me/mongotest/mongodb has following permissions :
drwxr-xr-x 2 root root 4.0K Nov 11 09:05 mongodb
So, you can´t write in there, unless you start mongod as root or you change permissions so that others can write in that directory.
I've added permissions to the folder for the mongod group... like so:
me@medev:~$ sudo setfacl -m g:mongodb:rwx /media/me/mongotest/mongodb
and then to check it worked:
me@medev:~$ getfacl /media/me/mongotest/mongodb/
getfacl: Removing leading '/' from absolute path names
# file: media/jlee/mongotest/mongodb/
# owner: root
# group: root
user::rwx
group::r-x
group:mongodb:rwx
mask::rwx
other::r-x
me@medev:~$ sudo setfacl -m g:mongodb:rwx /media/me/mongotest/mongodb
and then to check it worked:
me@medev:~$ getfacl /media/me/mongotest/mongodb/
getfacl: Removing leading '/' from absolute path names
# file: media/jlee/mongotest/mongodb/
# owner: root
# group: root
user::rwx
group::r-x
group:mongodb:rwx
mask::rwx
other::r-x
I think that's supposed to give the mongodb group the access it needs to write the drive....
Just to test whether the ACL permissions are working or not, I did the following:
- create a new user in ubuntu called "test".
- created a new group called testers
- added test to testers.
- added testers to ACL list for /media/me/mongotest/mongodb folder on the usb:
me@medev:~$ getfacl /media/me/mongotest/mongodb/ getfacl: Removing leading '/' from absolute path names # file: media/me/mongotest/mongodb/ # owner: root # group: root user::rwx group::r-x group:mongodb:rwx group:testers:rwx mask::rwx other::r-x
- Then I changed user to "test":
me@medev:~$ su test Password:
- Tried to change directories into the USB key like so:
test@medev:/home/me$ cd /media/me/mongotest bash: cd: /media/me/mongotest: Permission denied test@medev:/home/me$ cd /media/me/mongotest/mongodb bash: cd: /media/me/mongotest/mongodb: Permission denied test@medev:/home/me$
So it would seem that I'm doing something wrong with the way I'm creating / adding these permissions... because it's failing for both users / groups.
The problem has been resolved. I had to set the ACL at the /media/me level.
So i did this:
setfacl -m g:mongodb:rwx /media/me
I assumed I had to include "mongotest" in the path because that's the name I assigned to the volume / filesystem when I mounted it.
But I guess that's not the case. Sorry for all the noise folks. Hopefully this will help someone else out in the future.
So i did this:
setfacl -m g:mongodb:rwx /media/me
I assumed I had to include "mongotest" in the path because that's the name I assigned to the volume / filesystem when I mounted it.
But I guess that's not the case. Sorry for all the noise folks. Hopefully this will help someone else out in the future.
댓글 없음:
댓글 쓰기