So I have to set up a web server on a NeCTAR vm to allow public access to some research data that is sitting on RDSI storage in the QCIF UQ node. The node support team requested that instead of just NFS mounting the data storage to the vm, it would be preferable to use autofs to mount the filesystem.
I'm not a sys-admin type - mostly my linux environments are all set up for me so this was a bit of an adventure. I had quite a few problems so, with the aim of helping out future non sys-admin types in the same position, I thought I should document what I had to do.
So, the VM I have set up is a NeCTAR CentOS 6.4 x86_64 image, so I looked up the CentOS autofs doc and got to work.
- Check that you can actually mount the storage using NFS
- I didn't do this before I started and it took a while to discover that I didn't have all the NFS packages that I needed installed. In the end I had to install the nfs-utils-lib package:
sudo yum install nfs-utils-lib
- I didn't do this before I started and it took a while to discover that I didn't have all the NFS packages that I needed installed. In the end I had to install the nfs-utils-lib package:
- Install autofs on the vm
sudo yum install autofs
- This step installed a number of dependencies but I can't remember what they all were.
- Set up the /etc/auto.master file
- An example file is installed as part of the installation of autofs. The file contains automounter maps and have the format of <mount-point> <map-name> [ <mount-options-separated-by-comma> ]. I deleted most of the contents and added the one line I required:
- /data is the directory I want to use to mount the file system
- /etc/auto.rdsi is the location of the file that contains the mount information
- file indicates that the map name /etc/auto.rdsi refers to a regular file. This could be nis or nisplus instead. This is an optional field but better safe than sorry :)
- Set up the /etc/auto.rdsi file
- This file holds the mount instructions and has the format:
- The mount point is relative to the mount point given in the master file, options are the mount options (more or less what you would put in an fstab file) and the location is the remote-machine:location. So for my case, this was:
- Started the autofs service
- Test that it has actually worked:
ls /data/climate
- If at this point you get the error message:
ls: cannot access /data/climate: No such file or directory
then you have a problem!
- If at this point you get the error message:
/data file:/etc/auto.rdsi
<mount-point> [ <options> ] <location>
climate -rw,nfsvers=3,hard,intr,bg,nosuid,nolock,nodev,timeo=15,retrans=5 10.255.100.50:/collection/Q03/Q03
sudo service autofs start
What to do when it doesn't work
The problem with using the autofs service is of course the complete lack of error messages when things go wrong. An messages from the service go to /var/log/messages and will be prefixed with automount which is the underlying process that is being run by the autofs service. automount can be run from the command line with the --verbose argument but I found that rather messy. Instead, I edited the /etc/init.d/autofs script and added a new option:....
case "$1" in
start)
start
;;
forcestart)
OPTIONS="$OPTIONS --force"
start
;;
debugstart)
OPTIONS="$OPTIONS --verbose"
start
;;
stop)
stop
;;
...
I then stopped the service and used the new debugstart option:
sudo service autofs debugstartand tried to access the mounted area again:
ls /data/climateand then looked in the logs
sudo tail -100 /var/log/messages | grep automountThe error messages are pretty good so once I could see what is going wrong it was pretty easy to fix. In my case, I orginally didn't have the nolock option in the mount options and this was the messages in the log:
automount[21307]: attempting to mount entry /data/climate automount[21307]: >> mount.nfs: rpc.statd is not running but is required for remote locking. automount[21307]: >> mount.nfs: Either use '-o nolock' to keep locks local, or start statd. automount[21307]: >> mount.nfs: an incorrect mount option was specified automount[21307]: mount(nfs): nfs: mount failure 10.255.100.50:/collection/Q03/Q03 on /data/climate automount[21307]: failed to mount /data/climate
Don't forget to turn off the extra logging once you have got it all working - just stop the service and then start as per normal.
No comments:
Post a Comment