关灯
开启左侧

[Linux主机] 在Gluster上使用CTDB和Samba

[复制链接]
云V小编 发表于 2022-5-13 14:43:35 | 显示全部楼层 |阅读模式 打印 上一主题 下一主题
 
单独的使用Samba挂载gluster volume并不能实现High Availability,有了CTDB就可以解决这个问题了.

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

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=[SAMBA] OS=[Windows 6.1] Server=[Samba 4.4.4]
Server Comment
--------- -------
Workgroup Master
--------- -------
[root@node02mnt]#mount-tcifs-ousername=smbuser,password=redhat//node01.lab.example.com/gluster-repvol/mnt/samba-test/[root@node02/]#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
[root@node01~]#yuminstall-yctdb为ctdb放开防火墙限制
[root@node01~]#firewall-cmd--add-port=4379/tcp2.2更新volume设置
[root@node01~]#glustervolumestoprepvol[root@node01post]#cd/var/lib/glusterd/hooks/1/start/post[root@node01post]#viS29CTDBsetup.shMETA="all"修改前
META="ctdbmeta" 修改后
2.3更新Samba配置
编辑/etc/samba/smb.conf文件,并在[global]选项下添加 clustering=yes
[root@node01post]#cat/etc/samba/smb.conf...[global]clustering=yes....

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

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

2.6启动并验证ctdb service
[root@node01post]#systemctlstartctdb[root@node01post]#ctdbpnnPNN:0[root@node01post]#ctdbping-nallresponsefrom0time=0.000049sec(2clients)responsefrom1time=0.008014sec(1clients)[root@node01post]#ctdbstatusNumberofnodes:2pnn:0192.168.133.144OK(THISNODE)pnn:1192.168.133.149OKGeneration:2009096591Size:2hash:0lmaster:0hash:1lmaster:1Recoverymode:RECOVERY(1)Recoverymaster:1[root@node01post]#ctdbipPublicIPsonnode0192.168.133.1000[root@node01post]#ctdbipinfo192.168.133.100PublicIPsonnode0192.168.133.10002.7使用浮动ip挂载gluster volume
[root@node02post]#mount-tcifs-ousername=smbuser,password=redhat//192.168.133.100/gluster-repvol/mnt/samba-test/
 
您需要登录后才可以回帖 登录 | 立即注册

本版积分规则


0关注

0粉丝

101帖子

热门图文
热门帖子
排行榜
作者专栏

关注我们:微信订阅号

官方微信

APP下载

全国服务Q Q:

956130084

中国·湖北

Email:956130084@qq.com

Copyright   ©2015-2022  站长技术交流论坛|互联网技术交流平台Powered by©Discuz!技术支持:得知网络  

鄂公网安备 42018502006730号

  ( 鄂ICP备15006301号-5 )