Vecloud 发表于 2022-5-13 14:19:08

在Gluster上使用CTDB和Samba

单独的使用Samba挂载gluster volume并不能实现High Availability,有了CTDB就可以解决这个问题了.

1 准备环境
我已经提前准备好了一个gluster环境,创建好了一个volume repvol,并且此volume已经配置为可使用samba client挂载,有关详细配置请参考我前面的博文。
#glusterpoollistUUIDHostnameStatee967c77f-ff39-4927-9645-606294d42751node01.lab.example.comConnected98ef6fd9-9fa1-4005-b8ec-5480d6c04f46localhostConnected#glustervolumelistrepvol#smbclient-Lnode01.lab.example.com-U%
Domain= OS= Server=

Sharename Type Comment
--------- ---- -------
print$ Disk Printer Drivers
gluster-repvol Disk For samba share of volume repvol
IPC$ IPC IPC Service (Samba 4.4.4)
Domain= OS= Server=
Server Comment
--------- -------
Workgroup Master
--------- -------
#mount-tcifs-ousername=smbuser,password=redhat//node01.lab.example.com/gluster-repvol/mnt/samba-test/#df-h|grepsamba//node01.lab.example.com/gluster-repvol2.0G33M2.0G2%/mnt/samba-test从上面可以看到,我这里有两个gluster server,依次为
192.168.133.144 node01.lab.example.com
192.168.133.149 node02.lab.example.com
而挂载的时候,我使用的是//node01.lab.example.com/gluster-repvol,这样有一个问题,虽然我这里的gluster volume repvol是一个2副本的复制卷,但一旦node01.lab.example.com出现故障,虽然node02.lab.example.com上还保留一份数据在,但是却不能直接被client使用,不能够实现自动切换。

2 在两台gluster server上安装配置ctdb
2.1使用yum安装ctdb
#yuminstall-yctdb为ctdb放开防火墙限制
#firewall-cmd--add-port=4379/tcp2.2更新volume设置
#glustervolumestoprepvol#cd/var/lib/glusterd/hooks/1/start/post#viS29CTDBsetup.shMETA="all"修改前
META="ctdbmeta" 修改后
2.3更新Samba配置
编辑/etc/samba/smb.conf文件,并在选项下添加 clustering=yes
#cat/etc/samba/smb.conf...clustering=yes....

2.4start volume,此时会发现volume 会自动挂载到server的/gluster/lock 下
#glustervolumestartrepvolvolumestart:repvol:success#df-h|greprepvolnode01.lab.example.com:/repvol.tcp2.0G33M2.0G2%/gluster/lock

2.5添加/etc/ctdb/nodes 和 /etc/ctdb/public_address文件
#vi/etc/ctdb/nodes192.168.133.144192.168.133.149###这里的ip为gluster server节点的ip
#vi/etc/ctdb/public_addresses192.168.133.100/24ens33###这里的ip是浮动ip, ens33为interface name

2.6启动并验证ctdb service
#systemctlstartctdb#ctdbpnnPNN:0#ctdbping-nallresponsefrom0time=0.000049sec(2clients)responsefrom1time=0.008014sec(1clients)#ctdbstatusNumberofnodes:2pnn:0192.168.133.144OK(THISNODE)pnn:1192.168.133.149OKGeneration:2009096591Size:2hash:0lmaster:0hash:1lmaster:1Recoverymode:RECOVERY(1)Recoverymaster:1#ctdbipPublicIPsonnode0192.168.133.1000#ctdbipinfo192.168.133.100PublicIPsonnode0192.168.133.10002.7使用浮动ip挂载gluster volume
#mount-tcifs-ousername=smbuser,password=redhat//192.168.133.100/gluster-repvol/mnt/samba-test/
页: [1]
查看完整版本: 在Gluster上使用CTDB和Samba