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

  • 28 Nov 2019
    Planning ahead for Gluster releases

    In order to plan the content for upcoming releases, it is good to take a moment of pause, step back and attempt to look at the consumption of GlusterFS within large enterprises. With the enterprise architecture taking large strides towards cloud and more specifically, the hybrid cloud, continued efforts towards...

    Read more
  • 13 Nov 2019
    Announcing Gluster 7.0

    The Gluster community is pleased to announce the release of 7.0, our latest release. This is a major release that includes a range of code improvements and stability fixes along with a few features as noted below. A selection of the key features and bugs addressed are documented in this...

    Read more
  • 15 Oct 2019
    Gluster and CentOS Stream

    Progress cannot be made without change. As technologists, we recognize this every day. Most of the time, these changes are iterative: progresssive additions of features to projects like Gluster. Sometimes those changes are small, and sometimes not. And that’s, of course, just talking about our project. But one of the...

    Read more