Debian 11 Bullseye
Sponsored Link

GlusterFS 9 : GlusterFS + SMB2021/08/25

 
GlusterFS ボリュームに SMB プロトコルでアクセスできるよう設定します。
[1] 任意の GlusterFS ボリューム構成ノードで SMB アクセス の設定をします。
root@node01:~#
apt -y install samba-vfs-modules samba ctdb
# 対象の Gluster ボリュームを一旦停止して設定変更

root@node01:~#
gluster volume stop vol_distributed

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

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
# 25行目 : SMB アクセスを有効にする Gluster ボリューム名に変更

META="
vol_distributed
"
root@node01:~#
vi /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
# 13行目 : SMB アクセスを有効にする Gluster ボリューム名に変更

META="
vol_distributed
"
# 対象の Gluster ボリューム開始

root@node01:~#
gluster volume start vol_distributed

volume start: vol_distributed: success
# 以上の設定により [/gluster/lock] へ自動でマウントされる

root@node01:~#
df -h /gluster/lock

Filesystem                             Size  Used Avail Use% Mounted on
node01.srv.world:/vol_distributed.tcp   56G  3.0G   51G   6% /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
# 新規作成

# 対象の Gluster ボリュームを構成するノードを全て記述

10.0.0.51
10.0.0.52
root@node01:~#
vi /etc/ctdb/public_addresses
# 新規作成

# SMB アクセス用の仮想 IP アドレスを設定

# [enp1s0] はネットワークインターフェース名 ⇒ 自身の環境に置き換え

10.0.0.59/24 enp1s0
root@node01:~#
systemctl start ctdb
# 状態確認

root@node01:~#
ctdb status

Number of nodes:2
pnn:0 10.0.0.51        OK (THIS NODE)
pnn:1 10.0.0.52        DISCONNECTED|UNHEALTHY|INACTIVE
Generation:1234023799
Size:1
hash:0 lmaster:0
Recovery mode:NORMAL (0)
Recovery master:0

root@node01:~#
ctdb ip

Public IPs on node 0
10.0.0.59 0
[2] Samba の設定です。
例として、[smbgroup] というグループを作成し、対象の GlusterFS ボリューム直下に SMB 共有フォルダー [smbshare] を作成して、そのグループに属するユーザーのみが認証してアクセスできるようにします。
# 一旦 GlusterFS Native でマウントして共有用のフォルダーを作成

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
[global]
        .....
        .....
        # [global] セクション内に追記
        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

# 以下 9行は自動で設定されている
[gluster-vol_distributed]
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
# 以下 追記
writable = yes
valid users = @smbgroup
force create mode = 777
force directory mode = 777
inherit permissions = yes

root@node01:~#
systemctl restart smbd
# Samba ユーザー登録

root@node01:~#
useradd debian

root@node01:~#
smbpasswd -a debian

New SMB password:    
# パスワード設定

Retype new SMB password:
Added user cent.
root@node01:~#
usermod -aG smbgroup debian

[3] 任意のクライアントコンピューターで SMB マウントして確認します。
以下は Linux クライアントでの接続例ですが、Windows クライアントからも通常の共有アクセス操作で利用できます。
root@client:~#
apt -y install smbclient cifs-utils
# [smbclient] で確認

root@client:~#
smbclient //node01.srv.world/gluster-vol_distributed -U debian

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

# 設定した共有に移動して書き込み可能か確認
smb: \> cd smbshare

smb: \smbshare\> mkdir testdir
smb: \smbshare\> ls

  .                                   D        0  Wed Aug 25 13:15:18 2021
  ..                                  D        0  Wed Aug 25 13:06:43 2021
  testdir                             D        0  Wed Aug 25 13:15:18 2021

                58607392 blocks of size 1024. 53048388 blocks available

smb: \smbshare\> exit

# [mount] で確認

# [10.0.0.59] の部分は [1] で設定した仮想 IP アドレス

root@client:~#
mount -t cifs -o vers=3.0,username=debian //10.0.0.59/gluster-vol_distributed /mnt

Password for debian@//10.0.0.59/gluster-vol_distributed:
root@client:~#
df -hT

Filesystem                          Type      Size  Used Avail Use% Mounted on
udev                                devtmpfs  2.0G     0  2.0G   0% /dev
tmpfs                               tmpfs     394M  936K  393M   1% /run
/dev/mapper/debian--vg-root         ext4       28G  1.2G   26G   5% /
tmpfs                               tmpfs     2.0G     0  2.0G   0% /dev/shm
tmpfs                               tmpfs     5.0M     0  5.0M   0% /run/lock
/dev/vda1                           ext2      470M   48M  398M  11% /boot
tmpfs                               tmpfs     394M     0  394M   0% /run/user/0
//10.0.0.59/gluster-vol_distributed cifs       56G  5.4G   51G  10% /mnt

root@client:~#
touch /mnt/smbshare/testfile.txt

root@client:~#
ll /mnt/smbshare

total 4
drwxr-xr-x 2 root root 0 Aug 25 13:15 testdir
-rwxr-xr-x 1 root root 0 Aug 25 13:16 testfile.txt
関連コンテンツ