This post is mainly aimed to provide a quick guidance to anyone looking at exporting Gluster volume via a stand-alone NFS-Ganesha server, on any of the Gluster storage pool nodes, without getting into much internals.
We shall use few configurations scripts packaged as part of ‘gluserfs-ganesha’ rpm which were ideally designed to be used to configure HA for nfs-ganesha service. However these scripts are modelled such a way that they can be used (with some tweaks) to export volumes on a stand-alone machine as well without HA configuration needed.
Assumptions are that a GlusterFS trusted storage pool is set up and a volume has been created to be exported. If you would like to have a more detailed walk through with instructions on setting up either Gluster or NFS-Ganesha, please look at the links of few guides provided in the References section at the end of this post.
I used a machine with fedora24 installed.
#cat /etc/redhat-release
Fedora release 24 (Twenty Four)
Install nfs-ganesha
On one of the storage pool nodes, install nfs-ganesha-gluster package using the below command
# sudo dnf install nfs-ganesha-gluster
#sudo dnf install nfs-ganesha-gluster
Last metadata expiration check: 0:28:38 ago on Mon Aug 15 23:22:51 2016.
Dependencies resolved.
==================================================================================
Package Arch Version Repository Size
==================================================================================
Installing:
jemalloc x86_64 4.1.0-1.fc24 fedora 180 k
libntirpc x86_64 1.4.0-0.3pre3.fc24 updates 124 k
nfs-ganesha x86_64 2.4.0-0.14dev27.fc24 updates 599 k
nfs-ganesha-gluster x86_64 2.4.0-0.14dev27.fc24 updates 49 k
Transaction Summary
==================================================================================
Install 4 Packages
Total download size: 953 k
Installed size: 2.5 M
Is this ok [y/N]: y
Downloading Packages:
(1/4): nfs-ganesha-gluster-2.4.0-0.14dev27.fc24.x 33 kB/s | 49 kB 00:01
(2/4): jemalloc-4.1.0-1.fc24.x86_64.rpm 103 kB/s | 180 kB 00:01
(3/4): libntirpc-1.4.0-0.3pre3.fc24.x86_64.rpm 219 kB/s | 124 kB 00:00
(4/4): nfs-ganesha-2.4.0-0.14dev27.fc24.x86_64.rp 252 kB/s | 599 kB 00:02
----------------------------------------------------------------------------------
Total 175 kB/s | 953 kB 00:05
Running transaction check
Transaction check succeeded.
Running transaction test
Transaction test succeeded.
Running transaction
Installing : libntirpc-1.4.0-0.3pre3.fc24.x86_64 1/4
Installing : jemalloc-4.1.0-1.fc24.x86_64 2/4
Installing : nfs-ganesha-2.4.0-0.14dev27.fc24.x86_64 3/4
warning: /etc/sysconfig/ganesha created as /etc/sysconfig/ganesha.rpmnew
Installing : nfs-ganesha-gluster-2.4.0-0.14dev27.fc24.x86_64 4/4
Verifying : nfs-ganesha-gluster-2.4.0-0.14dev27.fc24.x86_64 1/4
Verifying : nfs-ganesha-2.4.0-0.14dev27.fc24.x86_64 2/4
Verifying : jemalloc-4.1.0-1.fc24.x86_64 3/4
Verifying : libntirpc-1.4.0-0.3pre3.fc24.x86_64 4/4
Installed:
jemalloc.x86_64 4.1.0-1.fc24
libntirpc.x86_64 1.4.0-0.3pre3.fc24
nfs-ganesha.x86_64 2.4.0-0.14dev27.fc24
nfs-ganesha-gluster.x86_64 2.4.0-0.14dev27.fc24
Complete!
Stop other NFS services
Stop kernel-NFS and gluster-NFS services if already running on that system.
To stop kernel-NFS:
#sudo systemctl stop nfs
To stop gluster-NFS:
#gluster vol set <volname> nfs.disable ON (Note: this command has to be repeated for all the volumes in the trusted-pool)
Start NFS-Ganesha service
Now start NFS-Ganesha service using the below command –
#sudo systemctl start nfs-ganesha
Verify the status
Verify if the service is successfully started using any of the following ways:
To know the status of the service –
#systemctl status nfs-ganesha
#sudo systemctl status nfs-ganesha
● nfs-ganesha.service - NFS-Ganesha file server
Loaded: loaded (/usr/lib/systemd/system/nfs-ganesha.service; disabled; vendor preset: disabled)
Active: active (running) since Mon 2016-08-15 23:58:05 IST; 2min 37s ago
Docs: http://github.com/nfs-ganesha/nfs-ganesha/wiki
Process: 14780 ExecStartPost=/bin/bash -c prlimit --pid $MAINPID --nofile=$NOFILE:$NOFILE (code=exited, status=0/SUCCESS)
Process: 14778 ExecStart=/bin/bash -c ${NUMACTL} ${NUMAOPTS} /usr/bin/ganesha.nfsd ${OPTIONS} ${EPOCH} (code=exited, status=0/SUCCESS)
Main PID: 14779 (ganesha.nfsd)
Tasks: 32 (limit: 512)
CGroup: /system.slice/nfs-ganesha.service
└─14779 /usr/bin/ganesha.nfsd -L /var/log/ganesha.log -f /etc/ganesha/ganesha.conf -N NIV_EVENT -E 6319123899418411008
Aug 15 23:58:04 xxx.yyy.com systemd[1]: Starting NFS-Ganesha file server...
Aug 15 23:58:05 xxx.yyy.com systemd[1]: Started NFS-Ganesha file server.
Verify if the ports used by NFS(& side-band services like mountd, nlm etc) are listed in the below command output –
#rpcinfo -p
# rpcinfo -p
program vers proto port service
100000 4 tcp 111 portmapper
100000 3 tcp 111 portmapper
100000 2 tcp 111 portmapper
100000 4 udp 111 portmapper
100000 3 udp 111 portmapper
100000 2 udp 111 portmapper
100024 1 udp 54009 status
100024 1 tcp 59721 status
100003 3 udp 2049 nfs
100003 3 tcp 2049 nfs
100003 4 udp 2049 nfs
100003 4 tcp 2049 nfs
100005 1 udp 37090 mountd
100005 1 tcp 46233 mountd
100005 3 udp 37090 mountd
100005 3 tcp 46233 mountd
100021 4 udp 50560 nlockmgr
100021 4 tcp 45229 nlockmgr
100011 1 udp 875 rquotad
100011 1 tcp 875 rquotad
100011 2 udp 875 rquotad
100011 2 tcp 875 rquotad
Verify if the pseudo-path is exported by the default –
#showmount -e localhost
#showmount -e localhost
Export list for localhost:
Download configuration scripts
Below configuration scripts are packaged to be installed at ‘/usr/libexec/ganesha’ location as part of ‘ganesha-gluster’ rpm. If that package is not installed, download them explictily.
#sudo mkdir -p /usr/libexec/ganesha
#sudo cd /usr/libexec/ganesha
#sudo wget https://raw.githubusercontent.com/gluster/glusterfs/release-3.10/extras/ganesha/scripts/create-export-ganesha.sh
#sudo wget https://raw.githubusercontent.com/gluster/glusterfs/release-3.10/extras/ganesha/scripts/dbus-send.sh
#sudo chmod 755 create-export-ganesha.sh dbus-send.sh
#sudo touch /etc/ganesha/exports/.export_added
#mkdir -p /usr/libexec/ganesha
#cd /usr/libexec/ganesha
#sudo wget https://raw.githubusercontent.com/gluster/glusterfs/master/extras/ganesha/scripts/create-export-ganesha.sh
--2016-08-16 00:15:07-- https://raw.githubusercontent.com/gluster/glusterfs/master/extras/ganesha/scripts/create-export-ganesha.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.56.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.56.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2103 (2.1K) [text/plain]
Saving to: ‘create-export-ganesha.sh’
create-export-ganesha.sh 100%[=====================================================================================>] 2.05K --.-KB/s in 0s
2016-08-16 00:15:08 (17.2 MB/s) - ‘create-export-ganesha.sh’ saved [2103/2103]
#sudo wget https://raw.githubusercontent.com/gluster/glusterfs/master/extras/ganesha/scripts/dbus-send.sh
--2016-08-16 00:14:16-- https://raw.githubusercontent.com/gluster/glusterfs/master/extras/ganesha/scripts/dbus-send.sh
Resolving raw.githubusercontent.com (raw.githubusercontent.com)... 151.101.56.133
Connecting to raw.githubusercontent.com (raw.githubusercontent.com)|151.101.56.133|:443... connected.
HTTP request sent, awaiting response... 200 OK
Length: 2928 (2.9K) [text/plain]
Saving to: ‘dbus-send.sh’
dbus-send.sh 100%[=====================================================================================>] 2.86K --.-KB/s in 0s
2016-08-16 00:14:17 (30.7 MB/s) - ‘dbus-send.sh’ saved [2928/2928]
#sudo chmod 744 create-export-ganesha.sh dbus-send.sh
#sudo touch /etc/ganesha/exports/.export_added
Create export config file for the volume
To create export config file (with default options) for any volume, use the below command –
#sudo /usr/libexec/ganesha/create-export-ganesha.sh /etc/ganesha on <volume_name>
Verify that an export configuration file for that volume is created in ‘/etc/ganesha/exports’ directory. To include any new or modify existing options, edit this file.
#sudo /usr/libexec/ganesha/create-export-ganesha.sh /etc/ganesha on testvol
#cat /etc/ganesha/exports/export.testvol.conf
# WARNING : Using Gluster CLI will overwrite manual
# changes made to this file. To avoid it, edit the
# file and run ganesha-ha.sh --refresh-config.
EXPORT{
Export_Id = 2;
Path = "/testvol";
FSAL {
name = GLUSTER;
hostname="localhost";
volume="testvol";
}
Access_type = RW;
Disable_ACL = true;
Squash="No_root_squash";
Pseudo="/testvol";
Protocols = "3", "4" ;
Transports = "UDP","TCP";
SecType = "sys";
}
Export the volume via nfs-ganesha
Make sure the above step (creating export configuration file) is done.
To export the volume, use the command –
#sudo /usr/libexec/ganesha/dbus-send.sh /etc/ganesha on <volume_name>
#sudo bash -x /usr/libexec/ganesha/dbus-send.sh /etc/ganesha on testvol
Now verify if the volume is exported using showmount
command –
#showmount -e localhost
Export list for localhost:
/testvol (everyone)
To export any other volume, repeat last two steps.
Unexport the volume via nfs-ganesha
To export the volume, use the command –
#sudo /usr/libexec/ganesha/dbus-send.sh /etc/ganesha off <volume_name>
#sudo bash -x /usr/libexec/ganesha/dbus-send.sh /etc/ganesha off testvol
Now verify if the volume is exported using showmount
command –
#showmount -e localhost
Export list for localhost:
References: