The Gluster Blog

Gluster blog stories provide high-level spotlights on our users all over the world

Configuring autofs for GlusterFS 3.5

Gluster
2014-04-15

GlusterFS 3.5 has not been released yet, but that should happen hopefully anytime soon (currently in beta). The RPM-packaging in this version has changed a little, and now offers a glusterfs-cli package. This package mainly contains the gluster commandline interface (and pulls in any dependencies).

On of the very useful things that is now made possible, is to list the available volumes on Gluster Storge Servers. This similar functionality is used by the /etc/auto.net script to list NFS-exports that are available for mounting. The auto.net script is by default enabled after installing and starting autofs:

# yum install autofs
# systemctl enable autofs.service
# systemctl start autofs.service

Checking, and mounting NFS-exports is made as easy as:

$ ls /net/nfs-server.example.net
archive media mock_cache olpc
$ ls /net/nfs-server.example.net/mock_cache/fedora-rawhide-armhfp/
yum_cache

Making this functionality available for Gluster Volumes is simple, just follow these steps:

  1. install the gluster command

     # yum install glusterfs-cli
  2. save the file below as /etc/auto.glfs

     #!/bin/bash
    # /etc/auto.glfs -- based on /etc/auto.net
    #
    # This file must be executable to work! chmod 755!
    #
    # Look at what a host is exporting to determine what we can mount.
    # This is very simple, but it appears to work surprisingly well
    #

    key="$1"

    # add "nosymlink" here if you want to suppress symlinking local filesystems
    # add "nonstrict" to make it OK for some filesystems to not mount
    opts="-fstype=glusterfs,nodev,nosuid"

    for P in /usr/local/bin /usr/local/sbin /usr/bin /usr/sbin /bin /sbin
    do
    if [ -x ${P}/gluster ]
    then
    GLUSTER_CLI=${P}/gluster
    break
    fi
    done

    [ -x ${GLUSTER_CLI} ] || exit 1

    ${GLUSTER_CLI} --remote-host="${key}" volume list | \
    awk -v key="$key" -v opts="$opts" -- '
    BEGIN { ORS=""; first=1 }
    { if (first) { print opts; first=0 }; print " \\\n\t/" $1, key ":/" $1 }
    END { if (!first) print "\n"; else exit 1 }' | \
    sed 's/#/\\#/g'
  3. make the script executable

     # chmod 0755 /etc/auto.glfs
  4. add an automount point to the autofs configuration

     # echo /glfs /etc/auto.glfs > /etc/auto.master.d/glfs.autofs
  5. reload the autofs configuration

     # systemctl reload autofs.service

After this, autofs should have created a new /glfs directory. The directory itself is empty, but a ls /glfs/gluster.example.net will show all the available volumes on the gluster.example.net server. These volumes can now be accessed through the autofs mountpoint. When the volumes are not used anymore, autofs will automatically unmount them after a timeout.

BLOG

  • 06 Dec 2020
    Looking back at 2020 – with g...

    2020 has not been a year we would have been able to predict. With a worldwide pandemic and lives thrown out of gear, as we head into 2021, we are thankful that our community and project continued to receive new developers, users and make small gains. For that and a...

    Read more
  • 27 Apr 2020
    Update from the team

    It has been a while since we provided an update to the Gluster community. Across the world various nations, states and localities have put together sets of guidelines around shelter-in-place and quarantine. We request our community members to stay safe, to care for their loved ones, to continue to be...

    Read more
  • 03 Feb 2020
    Building a longer term focus for Gl...

    The initial rounds of conversation around the planning of content for release 8 has helped the project identify one key thing – the need to stagger out features and enhancements over multiple releases. Thus, while release 8 is unlikely to be feature heavy as previous releases, it will be the...

    Read more