ClusterStorage-7-配置灾备地址( Samba CTDB )

0.实验前的环境检查与配置

[student@workstation ~]$ lab ctdb setup
 

1.配置环境

yum install -y samba ctdb安装软件包。firewall-cmd --add-service=samba放行服务。firewall-cmd --add-port=4379/tcp放行端口。 firewall-cmd --runtime-to-permanent使防火墙配置永久有效。 firewall-cmd --list-all查看防火墙配置。serverb参照servera操作。

[root@servera ~]# yum install -y samba ctdb
[root@serverb ~]# yum -y install samba ctdb
[root@servera ~]# firewall-cmd --add-service=samba
success
[root@servera ~]# firewall-cmd --add-port=4379/tcp
success
[root@servera ~]# firewall-cmd --runtime-to-permanent
success
[root@servera ~]# firewall-cmd --list-all
public (default, active)
  interfaces: eth0
  sources: 
  services: dhcpv6-client glusterfs samba ssh
  ports: 4379/tcp
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 
[root@serverb ~]# firewall-cmd --add-service=samba
success
[root@serverb ~]# firewall-cmd --add-port=4379/tcp
success
[root@serverb ~]# firewall-cmd --runtime-to-permanent
success
[root@serverb ~]# firewall-cmd --list-all
public (default, active)
  interfaces: eth0
  sources: 
  services: dhcpv6-client glusterfs samba ssh
  ports: 4379/tcp
  masquerade: no
  forward-ports: 
  icmp-blocks: 
  rich rules: 
 

2.配置元数据

gluster volume info ctdbmeta查看存储卷信息。gluster volume stop ctdbmeta停止存储卷。vim /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh编辑启动后操作脚本中的元数据参数。grep META= /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh查看修改后的值。vim /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh关闭前操作脚本中的元数据参数。grep META= /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh查看修改后的值。 grep '^\[' /etc/samba/smb.conf查看samba配置文件框架(其中global是后面选中修改的区块)。 vim /etc/samba/smb.conf编辑配置文件。grep clustering= /etc/samba/smb.conf参看修改值。serverb参照servera操作。

[root@servera ~]# gluster volume info ctdbmeta
 
Volume Name: ctdbmeta
Type: Replicate
Volume ID: 749bf115-4750-41e9-9835-f51c6c229492
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: servera:/bricks/brick-a1/brick
Brick2: serverb:/bricks/brick-b1/brick
Options Reconfigured:
performance.readdir-ahead: on
[root@servera ~]# gluster volume stop ctdbmeta
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: ctdbmeta: success
[root@servera ~]# grep META= /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
META="all"
[root@servera ~]# vim /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
[root@servera ~]# grep META= /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
META=ctdbmeta
[root@servera ~]# grep META= /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
META="all"
[root@servera ~]# vim /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
[root@servera ~]# grep META= /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
META=ctdbmeta

[root@servera ~]# grep '^\[' /etc/samba/smb.conf
[global]
[homes]
[printers]
[gluster-custdata]

[root@servera ~]# vim /etc/samba/smb.conf
[root@servera ~]# grep clustering= /etc/samba/smb.conf
        clustering=yes

[root@serverb ~]# grep META= /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
META="all"
[root@serverb ~]# vim /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
[root@serverb ~]# grep META= /var/lib/glusterd/hooks/1/start/post/S29CTDBsetup.sh
META=ctdbmeta
[root@serverb ~]# grep META= /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
META="all"
[root@serverb ~]# vim /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
[root@serverb ~]# grep META= /var/lib/glusterd/hooks/1/stop/pre/S29CTDB-teardown.sh
META=ctdbmeta
[root@serverb ~]# grep '^\[' /etc/samba/smb.conf
[global]
[homes]
[printers]
[gluster-custdata]
[root@serverb ~]# vim /etc/samba/smb.conf
[root@serverb ~]# grep clustering= /etc/samba/smb.conf
        clustering=yes
 

3.配置节点

gluster volume start ctdbmeta启动存储卷。gluster volume info ctdbmeta查看存储卷信息。vim /etc/ctdb/nodes编辑节点文件。cat /etc/ctdb/nodes查看文件。vim /etc/ctdb/public_addresses编辑公共地址文件。cat /etc/ctdb/public_addresses查看文件。systemctl enable ctdb载入启动项。systemctl start ctdb启动服务。serverb参照servera操作。

[root@servera ~]# gluster volume start ctdbmeta
volume start: ctdbmeta: success
[root@servera ~]# gluster volume info ctdbmeta
 
Volume Name: ctdbmeta
Type: Replicate
Volume ID: 749bf115-4750-41e9-9835-f51c6c229492
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: servera:/bricks/brick-a1/brick
Brick2: serverb:/bricks/brick-b1/brick
Options Reconfigured:
performance.readdir-ahead: on
[root@servera ~]# vim /etc/ctdb/nodes
[root@servera ~]# cat /etc/ctdb/nodes
172.25.250.10
172.25.250.11
[root@servera ~]# vim /etc/ctdb/public_addresses
[root@servera ~]# cat /etc/ctdb/public_addresses
172.25.250.15/24 eth0
[root@servera ~]# systemctl enable ctdb
[root@servera ~]# systemctl start ctdb
[root@serverb ~]# vim /etc/ctdb/nodes
[root@serverb ~]# cat /etc/ctdb/nodes
172.25.250.10
172.25.250.11
[root@serverb ~]# vim /etc/ctdb/public_addresses
[root@serverb ~]# cat /etc/ctdb/public_addresses
172.25.250.15/24 eth0
[root@serverb ~]# systemctl enable ctdb
[root@serverb ~]# systemctl start ctdb
 

4.配置gluster

smbpasswd -a smbuser创建samba用户。gluster volume set labdata stat-prefetch off关闭控制存储中元数据缓存的使用。gluster volume set labdata server.allow-insecure on允许非安全访问。gluster volume set labdata storage.batch-fsync-delay-usec 0控制聚合发送的请求数量为0。vim /etc/glusterfs/glusterd.vol编辑参数文件。grep rpc /etc/glusterfs/glusterd.vol允许用户为特定导出卷组定义规则的功能开启。systemctl restart glusterd重启服务。serverb参照servera操作。gluster volume stop custdata关闭存储卷。gluster volume start custdata启动存储卷。gluster volume info custdata查看存储卷信息。

[root@servera ~]# smbpasswd -a smbuser
db_ctdb_fetch_locked for /var/lib/ctdb/g_lock.tdb.0 key 7472616E73616374696F6E5F64625F3078373133326331383400, chain 0 needed 1 attempts, 9945 milliseconds, chainlock: 9879.292000 ms, CTDB 65.968000 ms
New SMB password:
Retype new SMB password:
Added user smbuser.
[root@servera ~]# gluster volume set custdata stat-prefetch off
volume set: success
[root@servera ~]# gluster volume set custdata server.allow-insecure on
volume set: success
[root@servera ~]# gluster volume set custdata storage.batch-fsync-delay-usec 0
volume set: success
[root@servera ~]# vim /etc/glusterfs/glusterd.vol
[root@servera ~]# grep rpc /etc/glusterfs/glusterd.vol
    option rpc-auth-allow-insecure on
[root@servera ~]# systemctl restart glusterd
[root@serverb ~]# vim /etc/glusterfs/glusterd.vol
[root@serverb ~]# grep rpc /etc/glusterfs/glusterd.vol
    option rpc-auth-allow-insecure on
[root@serverb ~]# systemctl restart glusterd
[root@servera ~]# gluster volume stop custdata
Stopping volume will make its data inaccessible. Do you want to continue? (y/n) y
volume stop: custdata: success
[root@servera ~]# gluster volume start custdata
volume start: custdata: success
[root@servera ~]# gluster volume info custdata
 
Volume Name: custdata
Type: Replicate
Volume ID: e74fa744-cd61-4790-b16c-350e36478d14
Status: Started
Number of Bricks: 1 x 2 = 2
Transport-type: tcp
Bricks:
Brick1: servera:/bricks/brick-a2/brick
Brick2: serverb:/bricks/brick-b2/brick
Options Reconfigured:
performance.readdir-ahead: on
performance.stat-prefetch: off
server.allow-insecure: on
storage.batch-fsync-delay-usec: 0

 

5.配置挂载

mkdir /mnt/custdata创建挂载目录。echo "//172.25.250.15/gluster-custdata /mnt/custdata cifs user=smbuser,pass=redhat 0 0" >> /etc/fstab挂载信息写入配置文件。tail -1 /etc/fstab查看配置文件。mount /mnt/custdata挂载。mount | grep custdata确认挂载。df -Th | grep custdata查看文件系统。

[root@workstation ~]# mkdir /mnt/custdata

[root@workstation ~]# echo "//172.25.250.15/gluster-custdata /mnt/custdata cifs user=smbuser,pass=redhat 0 0" >> /etc/fstab
[root@workstation ~]# tail -1 /etc/fstab
//172.25.250.15/gluster-custdata /mnt/custdata cifs user=smbuser,pass=redhat 0 0
[root@workstation ~]# mount /mnt/custdata
[root@workstation ~]# mount | grep custdata
//172.25.250.15/gluster-custdata on /mnt/custdata type cifs (rw,relatime,vers=1.0,cache=strict,username=smbuser,domain=SERVERA,uid=0,noforceuid,gid=0,noforcegid,addr=172.25.250.15,unix,posixpaths,serverino,acl,rsize=1048576,wsize=65536,actimeo=1)
[root@workstation ~]# df -Th | grep custdata
//172.25.250.15/gluster-custdata cifs      2.0G   33M  2.0G   2% /mnt/custdata
 

6.灾备地址测试

touch /mnt/custdata/file{00..49}创建测试文件。ctdb ip -n all查看浮动IP运行节点。ctdb status查看服务状态。poweroff测试关闭一个节点。touch /mnt/custdata/file{50..99}继续创建测试文件。rht-vmctl start servera启动刚才关闭的节点。

[root@workstation ~]# touch /mnt/custdata/file{00..49}
[root@servera ~]# ctdb ip -n all
Public IPs on ALL nodes
172.25.250.15 0
[root@servera ~]# ctdb status
Number of nodes:2
pnn:0 172.25.250.10    OK (THIS NODE)
pnn:1 172.25.250.11    OK
Generation:225522759
Size:2
hash:0 lmaster:0
hash:1 lmaster:1
Recovery mode:NORMAL (0)
Recovery master:0
[root@servera ~]# poweroff
Connection to servera closed by remote host.
Connection to servera closed.
[root@workstation ~]# touch /mnt/custdata/file{50..99}
[kiosk@foundation0 ~]$ rht-vmctl start servera
Starting servera.
 

7.查看日志

tail /var/log/log.ctdb查看日志。Trigger takeoverrun这里可以看到Trigger触发。

[root@servera ~]# tail /var/log/log.ctdb
2019/01/29 22:16:18.861569 [ 1401]: Thawing priority 2
2019/01/29 22:16:18.861576 [ 1401]: Release freeze handler for prio 2
2019/01/29 22:16:18.861587 [ 1401]: Thawing priority 3
2019/01/29 22:16:18.861593 [ 1401]: Release freeze handler for prio 3
2019/01/29 22:16:29.313040 [recoverd: 1724]: Trigger takeoverrun
2019/01/29 22:16:31.713851 [ 1401]: 50.samba: Redirecting to /bin/systemctl start  smb.service
2019/01/29 22:16:38.183284 [ 1401]: Monitoring event was cancelled
2019/01/29 22:16:38.183346 [ 1401]: ../ctdb/server/eventscript.c:583 Sending SIGTERM to child pid:2535
2019/01/29 22:16:40.201326 [ 1401]: Monitoring event was cancelled
2019/01/29 22:16:47.570390 [ 1401]: Node became HEALTHY. Ask recovery master 1 to perform ip reallocation

 

8.任务测评

lab ctdb grade进行测评。包括:防火墙配置,挂载目录,挂载与取消挂载,配置文件,CTDB节点,浮动IP状态等。

[student@workstation ~]$ lab ctdb grade

Grading the student's work:

 · Testing if all hosts are reachable..........................  SUCCESS
 · Testing runtime firewall on servera for samba...............  PASS
 · Testing permanent firewall on servera for samba.............  PASS
 · Testing runtime firewall on serverb for samba...............  PASS
 · Testing permanent firewall on serverb for samba.............  PASS
 · Checking for current mount on /mnt/custdata on workstation..  PASS
 · Checking if /mnt/custdata on workstation is in use..........  PASS
 · Unmounting /mnt/custdata....................................  PASS
 · Mounting /mnt/custdata......................................  PASS
 · Checking for current mount on /mnt/custdata on workstation..  PASS
 · Checking mount options for /mnt/custdata in /etc/fstab......  PASS
 · Checking configured CTDB nodes..............................  PASS
 · Checking floating ip status.................................  PASS

Overall lab grade..............................................  PASS
 

 

 

你可能感兴趣的:(GLUSTERFS)