Howto Automount GlusterFS
From GlusterDocumentation
Contents |
Why
Automount is functionality in GNU/Linux, where filesystems are automatically mounted in response to access operations by user programs. These are system utilities (daemons under GNU/Linux) which, when notified of file and directory access attempts under selectively monitored subdirectory trees, dynamically and transparently make remote or local devices accessible.
Automount functionality can be used with GlusterFS with the same ease as NFS is used with autofs.
Mandatory Checks
Please ensure that you have a system ready with following:
1. Kernel automounter version 4 support (also supports v3)
2. Autofs userspace programs.
3. GlusterFS client.
System setup and configuration
Verify Manual Mounting
After installing GlusterFS client, get the GlusterFS server details and try mounting like the following command on the client node
bash-3.02# mount -t glusterfs [YOURSERVERNAME] /[MOUNTPOINT]
If everything goes fine, you will see glusterfs listed in /proc/mounts like the following
bash-3.02# grep glusterfs /proc/mounts
glusterfs /[MOUNTPOINT] fuse \
rw,nosuid,nodev,user_id=0,group_id=0, \
default_permissions,allow_other,max_read=1048576 0 0
If you find any error please refer GlusterFS Troubleshooting Guide
Autofs config files
Modify the autofs master configuration file. This file lists one or more directories to take control over (it will automatically create and remove directories as you access them). This directory (the "mount point") will be controlled by the autofs daemon and it's therefore strongly recommended that you do *not* use the "mount" command to explicitly mount filesystems to this directory.
Each line in the master configuration file gives autofs a mount point, and the name of another configuration file that contains the file systems to auto-mount there. You can add any number of mount points as you wish.
All config files must have a new line at the end
File: /etc/autofs/auto.master
# As usual, lines in the file that start with '#' are comments
# mount point config file options #/misc /etc/autofs/auto.misc #/home /etc/autofs/auto.home /export /etc/autofs/auto.gfs1 --timeout=5 --ghost /storage /etc/autofs/auto.gfs2 --timeout=60
The --timeout option in auto.master tells the automounter to unmount the file systems after (in this case) 5 and 60 seconds of inactivity. There are many discussions on the internet about whether this should be very short (several seconds) or long (a minute or more). That discussion is outside the scope of this document.
The --ghost option tells the automounter to create "ghost" versions (i.e. empty directories) of all the mount points listed in the configuration file (in this case /etc/autofs/auto.gfs1), regardless of whether any of the file systems is actually mounted or not. This is very convenient and highly recommended, because it will show you the available auto-mountable file systems as existing directories, even when their file systems aren't currently mounted. Without the --ghost option, you'll have to remember the names of the directories. As soon as you try to access one of them, the directory will be created and the file system will be mounted. When the file system gets unmounted again, the directory is destroyed too, unless the --ghost option was given.
File: /etc/autofs/auto.gfs1 mysql -fstype=glusterfs :/etc/glusterfs/glusterfs-client.vol apps -fstype=glusterfs :grid1.hostname.com File: /etc/autofs/auto.gfs2 zresearch -fstype=glusterfs :glusterfs.zresearch.com users -fstype=glusterfs :/usr/etc/glusterfs/custom-client.vol
As you can see from the above config files, In glusterfs you can provide two different type of options
- Passing client spec file residing on the client itself.
- Passing server information through which client spec file will be fetched from server itself.
Now after adding the following lines, we are good to go with autofs startup.
Create the directory named in master configuration files on the client node.
bash-3.02# mkdir -p {/storage,/export}
Now we can go into the startup process.
Startup and System Boot
Start the AUTOFS daemon by issuing following command under Redhat Enterprise Linux:
bash-3.02# /etc/init.d/autofs start
If you wish to have this behavior on default startup, issue:
bash-3.02# chkconfig --level 35 autofs on
Testing
After successfully finishing the autofs start, we wish to test in the glusterfs directories are mounting successfully
bash-3.02# cd /export/zresearch
bash-3.02# grep glusterfs /proc/mounts
glusterfs /export/zresearch fuse \
rw,nosuid,nodev,user_id=0,group_id=0, \
default_permissions,allow_other,max_read=1048576 0 0
Looks like we have successfully mounted the GlusterFS through autofs.

