Fedora 35
Sponsored Link

GlusterFS 9 : GlusterFS + SMB
Configure GlusterFS volume to enable SMB protocol.
[1] Configure GlusterFS to enable SMB setting on a Node in GlusterFS Cluster.
[root@node01 ~]#
dnf -y install samba ctdb samba-vfs-glusterfs
# stop the target Gluster volume and change settings

[root@node01 ~]#
gluster volume stop vol_distributed

Stopping volume will make its data inaccessible. Do you want to continue? (y/n)

volume stop: vol_distributed: success
[root@node01 ~]#
gluster volume set vol_distributed user.smb enable

volume set: success
[root@node01 ~]#
gluster volume set vol_distributed performance.write-behind off

volume set: success
[root@node01 ~]#
gluster volume set vol_distributed group samba

volume set: success
[root@node01 ~]#
vi /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
# line 25 : change to the target Gluster volume name

[root@node01 ~]#
vi /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
# line 13 : change to the target Gluster volume name

# start Gluster volume

[root@node01 ~]#
gluster volume start vol_distributed

volume start: vol_distributed: success
# with the settings above, follwing mounting is done automatically

[root@node01 ~]#
df -h /gluster/lock

Filesystem                             Size  Used Avail Use% Mounted on
node01.srv.world:/vol_distributed.tcp   30G  3.5G   27G  12% /gluster/lock

[root@node01 ~]#
tail -1 /etc/fstab

node01.srv.world:/vol_distributed /gluster/lock glusterfs _netdev,transport=tcp,xlator-option=*client*.ping-timeout=10 0 0

[root@node01 ~]#
vi /etc/ctdb/nodes
# create new
# write all Nodes that configure target Gluster volume
[root@node01 ~]#
vi /etc/ctdb/public_addresses
# create new
# set virtual IP address for SMB access
# [enp1s0] means network interface name ⇒ replace to your environment enp1s0
[root@node01 ~]#
systemctl enable --now ctdb
# confirm status

[root@node01 ~]#
ctdb status

Number of nodes:2
pnn:0        OK (THIS NODE)
hash:0 lmaster:0
Recovery mode:NORMAL (0)
Recovery master:0

[root@node01 ~]#
ctdb ip

Public IPs on node 0 0
[2] Configure Samba.
For example, Create a shared Folder that users in [smbgroup] group can only access to shared folder [smbshare] and also they are required user authetication.
# mount Gluster volume with GlusterFS Native and create a shared folder for SMB access

[root@node01 ~]#
mount -t glusterfs node01.srv.world:/vol_distributed /mnt

[root@node01 ~]#
mkdir /mnt/smbshare

[root@node01 ~]#
groupadd smbgroup

[root@node01 ~]#
chgrp smbgroup /mnt/smbshare

[root@node01 ~]#
chmod 770 /mnt/smbshare

[root@node01 ~]#
umount /mnt

[root@node01 ~]#
vi /etc/samba/smb.conf
        workgroup = SAMBA
        security = user

        passdb backend = tdbsam

        printing = cups
        printcap name = cups
        load printers = yes
        cups options = raw
        # add follows
        clustering = yes
        kernel share modes = no
        kernel oplocks = no
        map archive = no
        map hidden = no
        map read only = no
        map system = no
        store dos attributes = yes

# follwoing 9 lines are configred automatically
comment = For samba share of volume vol_distributed
vfs objects = glusterfs
glusterfs:volume = vol_distributed
glusterfs:logfile = /var/log/samba/glusterfs-vol_distributed.%M.log
glusterfs:loglevel = 7
path = /
read only = no
kernel share modes = no
# add follows
writable = yes
valid users = @smbgroup
force create mode = 777
force directory mode = 777
inherit permissions = yes

[root@node01 ~]#
systemctl enable --now smb
# add Samba user

[root@node01 ~]#
useradd fedora

[root@node01 ~]#
smbpasswd -a fedora

New SMB password:    
# set any SMB password

Retype new SMB password:
Added user fedora.
[root@node01 ~]#
usermod -G smbgroup fedora

[3] If SELinux is enabled, change policy.
[root@node01 ~]#
setsebool -P use_fusefs_home_dirs on

[root@node01 ~]#
setsebool -P samba_load_libgfapi on

[root@node01 ~]#
setsebool -P domain_kernel_load_modules on

[4] If Firewalld is running, allow services.
[root@node01 ~]#
firewall-cmd --add-service={samba,ctdb}

[root@node01 ~]#
firewall-cmd --runtime-to-permanent

[5] Verify it can access to the target share with SMB from any Linux client computer.
The examples below are on Linux clients but it's possible to access from Windows clients with common way.
# verify with [smbclient]

[root@client ~]#
smbclient //node01.srv.world/gluster-vol_distributed -U fedora

Enter SAMBA\fedora's password:
Try "help" to get a list of possible commands.

# verify witable to move to shared folder
smb: \> cd smbshare

smb: \smbshare\> mkdir testdir
smb: \smbshare\> ls
  .                                   D        0  Tue Nov  9 15:13:16 2021
  ..                                  D        0  Tue Nov  9 15:09:06 2021
  anaconda-ks.cfg                     A      872  Tue Nov  9 15:13:17 2021
  testdir                             D        0  Tue Nov  9 15:12:38 2021

                31436800 blocks of size 1024. 27701820 blocks available

smb: \smbshare\> exit
Matched Content