Skip to content

antony@notes:~/suse$ cat "Cluster-Managed-Storage.md"

Cluster Managed Storage

2024-03-13· suse ·SLE HAE

Cluster Managed Storage

Preface

本篇文章會主要會採取 Step by Step 和 ScreenShot 的方式介紹,如何建立與管理 Cluster Managed Storage

可以透過點擊以下目錄,選擇想看的內容,跳轉至特定章節

:::warning

:::spoiler {state=“open”} 目錄

[TOC]

:::

1. 設定 sle-ha-1 存取 san 上用於 DRBD 的 storage

Task 1: Connect sle-ha-1 to the iSCSI device to be used for the DRBD

  1. SSH 連線至 sle-ha-1
  2. 啟動 Yast 的 iSCSI initiator module
$ sudo yast2 iscsi-client
  • After writing configuration 的值改成 : Restart

image

  1. 選擇 Connected Targets 選項
  2. 選擇 Add

image

  1. 輸入以下訊息 :
IP Address: 10.12.2.13
Port: 3260
No Discovery Authentication: Box checked
  1. 選擇 Next

image

在 iSCSI Initiator Discovery 螢幕中會看到多個 targets

  1. 選擇 iqn.2023-11.com.example:app-disk1
  2. 選擇 Connect

image

  1. Startup 選項的值改成 : automatic
  2. 選擇 NextNext

image

image

  1. In the iSCSI Initiator Overview screens Connected Targets tab check the Start-up is set to automatic
  2. 點選 OK

image

Task 2: Check the iscsi configuration

  1. 檢查總共有 4 個連接,3 個是 sbd,另外一個是給 DRBD
$ sudo iscsiadm -m session

螢幕輸出 :

tcp: [11] 10.12.2.13:3260,1 iqn.2023-11.com.example:sbd-disk1 (non-flash)
tcp: [12] 10.12.2.13:3260,1 iqn.2023-11.com.example:sdb-disk2 (non-flash)
tcp: [13] 10.12.2.13:3260,1 iqn.2023-11.com.example:sdb-disk3 (non-flash)
tcp: [14] 10.12.2.13:3260,1 iqn.2023-11.com.example:app-disk1 (non-flash)
  1. 列出 scsi disks
$ lsscsi

螢幕輸出 :

[0:0:0:0]    disk    QEMU     QEMU HARDDISK    2.5+  /dev/sda
[2:0:0:0]    cd/dvd  QEMU     QEMU DVD-ROM     2.5+  /dev/sr0
[3:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdb
[4:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdc
[5:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdd
[6:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sde
  1. 檢查 persistent device names 和空間大小
$ lsblk

螢幕輸出 :

NAME     MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda        8:0    0  200G  0 disk
├─sda1     8:1    0    8M  0 part
└─sda2     8:2    0  200G  0 part  /boot/grub2/x86_64-efi
                                   /home
                                   /boot/grub2/i386-pc
                                   /root
                                   /var
                                   /opt
                                   /tmp
                                   /usr/local
                                   /srv
                                   /.snapshots
                                   /
sdb        8:16   0    1G  0 disk
└─mpathd 254:0    0    1G  0 mpath
sdc        8:32   0    1G  0 disk
└─mpathe 254:3    0    1G  0 mpath
sdd        8:48   0    1G  0 disk
└─mpathf 254:1    0    1G  0 mpath
sde        8:64   0  100G  0 disk
└─mpathb 254:2    0  100G  0 mpath
sr0       11:0    1 13.5G  0 rom

2. Configure sle-ha-2 access to storage for DRBD

Task 1: Connect sle-ha-2 to the iSCSI device to be used for the DRBD

  1. SSH 連線至 sle-ha-2
  2. 啟動 Yast 的 iSCSI initiator module
$ sudo yast2 iscsi-client
  • After writing configuration 的值改成 : Restart

image

  1. 選擇 Connected Targets 選項
  2. 選擇 Add

image

  1. 輸入以下訊息 :
IP Address: 10.12.2.13
Port: 3260
No Discovery Authentication: Box checked
  1. 選擇 Next

image

在 iSCSI Initiator Discovery 螢幕中會看到多個 targets

  1. 選擇 iqn.2023-11.com.example:app-disk2
  2. 選擇 Connect

image

  1. Startup 選項的值改成 : automatic
  2. 選擇 NextNext

image

image

  1. In the iSCSI Initiator Overview screens Connected Targets tab check the Start-up is set to automatic
  2. 點選 OK

image

Task 2: Check the iscsi configuration

  1. 檢查總共有 4 個連接,3 個是 sbd,另外一個是給 DRBD
$ sudo iscsiadm -m session

螢幕輸出 :

tcp: [11] 10.12.2.13:3260,1 iqn.2023-11.com.example:sbd-disk1 (non-flash)
tcp: [12] 10.12.2.13:3260,1 iqn.2023-11.com.example:sdb-disk2 (non-flash)
tcp: [13] 10.12.2.13:3260,1 iqn.2023-11.com.example:sdb-disk3 (non-flash)
tcp: [14] 10.12.2.13:3260,1 iqn.2023-11.com.example:app-disk2 (non-flash)
  1. 列出 scsi disks
$ lsscsi

螢幕輸出 :

[0:0:0:0]    disk    QEMU     QEMU HARDDISK    2.5+  /dev/sda
[2:0:0:0]    cd/dvd  QEMU     QEMU DVD-ROM     2.5+  /dev/sr0
[3:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdb
[4:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdc
[5:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sdd
[6:0:0:0]    disk    LIO-ORG  IBLOCK           4.0   /dev/sde
  1. 檢查 persistent device names 和空間大小
$ lsblk

螢幕輸出 :

NAME     MAJ:MIN RM  SIZE RO TYPE  MOUNTPOINTS
sda        8:0    0  200G  0 disk
├─sda1     8:1    0    8M  0 part
└─sda2     8:2    0  200G  0 part  /var
                                   /tmp
                                   /home
                                   /root
                                   /usr/local
                                   /srv
                                   /boot/grub2/i386-pc
                                   /boot/grub2/x86_64-efi
                                   /.snapshots
                                   /opt
                                   /
sdb        8:16   0    1G  0 disk
└─mpathd 254:1    0    1G  0 mpath
sdc        8:32   0    1G  0 disk
└─mpathe 254:2    0    1G  0 mpath
sdd        8:48   0    1G  0 disk
└─mpathf 254:3    0    1G  0 mpath
sde        8:64   0  100G  0 disk
└─mpathc 254:0    0  100G  0 mpath
sr0       11:0    1 13.5G  0 rom

3. Create cluster IPaddr2 resources for DRBD

Task 1: Create the first IP address resource

  1. SSH 連線至 sle-ha-1
  2. open the crm shell in the configure context
$ sudo crm configure
  1. 建立 IPaddr2 Resource
$ primitive p-IP_20 IPaddr2 \
params ip=10.12.2.20 nic=eth1 cidr_netmask=24 \
op start timeout=20 \
op stop timeout=20 \
op monitor interval=10 timeout=20
  1. Commit the changes:
$ commit
  1. Change to the resource context
$ cd ../resource
  1. Show the status of the new resource
$ status p-IP_20

螢幕輸出 :

resource p-IP_20 is running on: sle-ha-2

Task 2: Create the second IP address resource

  1. In the crm shell change back to the configure context:
$ cd ../configure
  1. 建立 IPaddr2 Resource
$ primitive p-IP_21 IPaddr2 \
params ip=10.12.2.21 nic=eth1 cidr_netmask=24 \
op start timeout=20 \
op stop timeout=20 \
op monitor interval=10 timeout=20
  1. Commit the changes:
$ commit
  1. Change to the resource context
$ cd ../resource
  1. Show the status of the new resource
$ status p-IP_21

螢幕輸出 :

resource p-IP_21 is running on: sle-ha-2
  1. Exit the crm shell:
$ q

4. Configure and test DRBD outside the cluster environment

Task 1: Create mount points for DRBD

  1. 在 sle-ha-1 上執行以下建立目錄的命令
$ sudo mkdir /drbdvol
  1. 在 sle-ha-2 上執行以下建立目錄的命令
$ sudo mkdir /drbdvol

Task 2: Configure DRBD using YaST

  1. 在 sle-ha-1 節點上找出測試 DRBD 用的 Disk 對應的 ID
$ sudo multipath -ll mpathb

螢幕輸出 :

mpathb (360014053be325d33ebb4e7e966df3a4f) dm-2 LIO-ORG,IBLOCK
size=100G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  `- 6:0:0:0 sde 8:64 active ready running
  1. 透過 ID 列出 Disk
$ ls -l /dev/disk/by-id/scsi-3600*

螢幕輸出應該和以下類似 :

/dev/disk/by-id/scsi-360014053be325d33ebb4e7e966df3a4f -> ../../dm-2
/dev/disk/by-id/scsi-3600140552d947e312e24a4f8a9a0f9b1 -> ../../dm-1
/dev/disk/by-id/scsi-36001405c2d16cc2065f4004ac0a1c188 -> ../../dm-0
/dev/disk/by-id/scsi-36001405e9b0b982a26f493e97b88ca61 -> ../../dm-3

確認 /dev/disk/by-id/scsi-360014053be325d33ebb4e7e966df3a4f 對應的是測試 DRBD 用的 Disk

  1. Configure DRBD on sle-ha-1 using yast:
$ sudo yast2 drbd
  1. At the Warning screen click YES

image

  1. 讓 Booting option 保留預設值: Off - Server Only Starts Manually ,因為不要透過 systemd 去管理 DRBD

image

  1. 在左側選單選 Resource Configuration
  2. 選擇 Add 開始新增 DRBD configuration

image

  1. 輸入以下內容 :
  • Resource Name: r0
  • Address Port: 10.12.2.20:7788
  • Device: /dev/drbd0
  • Disk: <enter the disk by id noted in step 2 above>
    • for example: /dev/disk/by-id/scsi-360014053be325d33ebb4e7e966df3a4f
  • Meta-disk: internal
  1. 點選 Save

image

  1. 開始新增 sle-ha-2 到 DRBD configuration
  2. 在 sle-ha-2 節點上找出測試 DRBD 用的 Disk 對應的 ID
$ sudo multipath -ll mpathc

螢幕輸出 :

mpathc (36001405ee25a89d7a8a4df09f6a3a5f0) dm-0 LIO-ORG,IBLOCK
size=100G features='1 queue_if_no_path' hwhandler='1 alua' wp=rw
`-+- policy='service-time 0' prio=50 status=active
  `- 6:0:0:0 sde 8:64 active ready running
  1. 透過 ID 列出 Disk
$ ls -l /dev/disk/by-id/scsi-3600*

螢幕輸出應該和以下類似 :

/dev/disk/by-id/scsi-3600140552d947e312e24a4f8a9a0f9b1 -> ../../dm-3
/dev/disk/by-id/scsi-36001405c2d16cc2065f4004ac0a1c188 -> ../../dm-1
/dev/disk/by-id/scsi-36001405e9b0b982a26f493e97b88ca61 -> ../../dm-2
/dev/disk/by-id/scsi-36001405ee25a89d7a8a4df09f6a3a5f0 -> ../../dm-0

確認 /dev/disk/by-id/scsi-36001405ee25a89d7a8a4df09f6a3a5f0 對應的是測試 DRBD 用的 Disk

  1. Continue configuring DRBD using yast. in the DRBD - Resource Basic Configuration screen click Add
  2. Complete the form using the details below:
  • Name: sle-ha-2

image

  1. 點選 OK,再輸入以下內容 :
  • Resource Name: r0
  • Address Port: 10.12.2.21:7788
  • Device: /dev/drbd0
  • Disk: <enter the disk by id noted in step 12 above>
    • for example: /dev/disk/by-id/scsi-36001405ee25a89d7a8a4df09f6a3a5f0
  • Meta-disk: internal
  1. 點選 Save

image

  1. 點選 OK -> Finish
  2. View the content of the r0.res file
$ sudo cat /etc/drbd.d/r0.res

螢幕輸出 :

resource r0 {
   disk {
      on-io-error       pass_on;
   }
   net {
      protocol  C;
   }
   connection-mesh {
      hosts     sle-ha-1 sle-ha-2;
   }
   on sle-ha-1 {
      address   10.12.2.20:7788;
      device    /dev/drbd0;
      disk      /dev/disk/by-id/scsi-360014053be325d33ebb4e7e966df3a4f;
      meta-disk internal;
      node-id   0;
   }
   on sle-ha-2 {
      address   10.12.2.21:7788;
      device    /dev/drbd0;
      disk      /dev/disk/by-id/scsi-36001405ee25a89d7a8a4df09f6a3a5f0;
      meta-disk internal;
      node-id   1;
   }
}
  1. 把設定檔同步到 sle-ha-2
$ sudo csync2 -xv

螢幕輸出 :

Marking file as dirty: /etc/sysconfig/nfs
Marking file as dirty: /etc/lvm/lvm.conf
Marking file as dirty: /etc/drbd.d/r0.res
Marking file as dirty: /etc/drbd.d/global_common.conf.YaST2save
Marking file as dirty: /etc/drbd.d/global_common.conf
Marking file as dirty: /etc/drbd.conf
Connecting to host sle-ha-2 (SSL) ...
Connect to 192.168.11.172:30865 (sle-ha-2).
Updating /etc/drbd.conf on sle-ha-2 ...
Updating /etc/drbd.d/global_common.conf on sle-ha-2 ...
Updating /etc/drbd.d/global_common.conf.YaST2save on sle-ha-2 ...
Updating /etc/drbd.d/r0.res on sle-ha-2 ...
Updating /etc/lvm/lvm.conf on sle-ha-2 ...
Updating /etc/sysconfig/nfs on sle-ha-2 ...
File is already up to date on peer.
Connection closed.
Finished with 0 errors.

Task 3: Complete the configuration of DRBD

  1. 10.12.2.20 這個 IP 設定在 sle-ha-1 主機上,並且設定 10.12.2.21 在 sle-ha-2 主機上
$ sudo crm configure

$ location loc_p-IP_20 p-IP_20 -inf: sle-ha-2
    
$ location loc_p-IP_21 p-IP_21 -inf: sle-ha-1
  1. Ensure the resources are running on the required nodes:
$ cd ../resource

$ stop p-IP_20

$ stop p-IP_21

$  start p-IP_20

$  locate p-IP_20
resource p-IP_20 is running on: sle-ha-1

$  start p-IP_21

$  locate p-IP_21
resource p-IP_21 is running on: sle-ha-2
  1. Exit the crm shell:
$ q
  1. 在 sle-ha-1 上建立 DRBD Resource
$ sudo drbdadm create-md r0

螢幕輸出 :

initializing activity log
initializing bitmap (3200 KB) to all zero
Writing meta data...
New drbd meta data block successfully created.
  1. Bring up r0
$ sudo drbdadm up r0

螢幕輸出 :

  --==  Thank you for participating in the global usage survey  ==--
The server's response is:

you are the 116812th user to install this version
  1. You will now repeat some steps on sle-ha-2

  2. 在 sle-ha-2 上建立 DRBD Resource

$ sudo drbdadm create-md r0

螢幕輸出 :

initializing activity log
initializing bitmap (3200 KB) to all zero
Writing meta data...
New drbd meta data block successfully created.
  1. Bring up r0
$ sudo drbdadm up r0

螢幕輸出 :

  --==  Thank you for participating in the global usage survey  ==--
The server's response is:

you are the 116812th user to install this version
  1. To finalize and test the DRBD configuration you need to temporarily start the service. Do NOT enable the DRBD service because it will be managed by the cluster. Start the drbd service on nodes 1 and 2. Note: The startup on the first node will wait to contact the drbd service on the second node

  2. 先在 sle-ha-2 啟動 drbd 服務

$ ssh rancher@sle-ha-2 sudo systemctl start drbd &

螢幕輸出 :

[1] 23818
  1. 在 sle-ha-1 啟動 drbd 服務
$ sudo systemctl start drbd

螢幕輸出 :

[1]+  Done                    ssh rancher@sle-ha-2 sudo systemctl start drbd
  1. Check the status of drbd resource r0 on sle-ha-2:
$ ssh rancher@sle-ha-2 sudo drbdadm status r0

螢幕輸出 :

r0 role:Secondary
  disk:Inconsistent
  sle-ha-1 role:Secondary
    peer-disk:Inconsistent
  1. Check the status of drbd resource r0 on sle-ha-1:
$ sudo drbdadm status r0

螢幕輸出 :

r0 role:Secondary
  disk:Inconsistent
  sle-ha-2 role:Secondary
    peer-disk:Inconsistent
  1. force sle-ha-1 to be the primary and initiate a synchronization
$ sudo drbdadm primary --force r0
  1. View the status:
$ sudo drbdadm status r0

螢幕輸出 :

r0 role:Primary
  disk:UpToDate
  sle-ha-2 role:Secondary
    replication:SyncSource peer-disk:Inconsistent done:0.29
  1. Note the last line, the disks are preforming and initial synchronization. Do NOT continue until synchronization has completed
  2. When synchronization has completed the output of the command drbdadm status r0 should look like this:
r0 role:Primary
  disk:UpToDate
  sle-ha-2 role:Secondary
    peer-disk:UpToDate
  1. Create a file system on the DRBD r0 resource:
$ sudo mkfs.xfs /dev/drbd0

螢幕輸出 :

meta-data=/dev/drbd0             isize=512    agcount=4, agsize=6553398 blks
         =                       sectsz=512   attr=2, projid32bit=1
         =                       crc=1        finobt=1, sparse=1, rmapbt=0
         =                       reflink=0    bigtime=0 inobtcount=0
data     =                       bsize=4096   blocks=26213591, imaxpct=25
         =                       sunit=0      swidth=0 blks
naming   =version 2              bsize=4096   ascii-ci=0, ftype=1
log      =internal log           bsize=4096   blocks=12799, version=2
         =                       sectsz=512   sunit=0 blks, lazy-count=1
realtime =none                   extsz=4096   blocks=0, rtextents=0

Task 4: Test the DRBD configuration

  1. 在 sle-ha-1 上 mount the filesystem:
$ sudo mount /dev/drbd0 /mnt
  1. Create a file:
$ sudo touch /mnt/file.txt && ls -l /mnt

螢幕輸出 :

total 0
-rw-r--r-- 1 root root 0 Jan  2 18:26 file.txt
  1. Unmount the filesystem:
$ sudo umount /mnt
  1. Demote sle-ha-1 to secondary
$ sudo drbdadm secondary r0
  1. promote sle-ha-2 to primary
$ ssh sle-ha-2 'sudo drbdadm primary r0'
  1. View the status of the DRBD device
$ sudo drbdadm status r0

螢幕輸出 :

r0 role:Secondary
  disk:UpToDate
  sle-ha-2 role:Primary
    peer-disk:UpToDate
  1. 在 sle-ha-2 上 Mount the filesystem,並查看檔案是否存在
$ ssh sle-ha-2 'sudo mount /dev/drbd0 /mnt && ls -l /mnt'

螢幕輸出 :

total 0
-rw-r--r-- 1 root root 0 Jan  2 18:26 file.txt
  1. 在 sle-ha-2 上 Create a file
$ ssh sle-ha-2 'sudo touch /mnt/node2.txt && ls -l /mnt'

螢幕輸出 :

total 0
-rw-r--r-- 1 root root 0 Jan  2 18:26 file.txt
-rw-r--r-- 1 root root 0 Jan  2 18:32 node2.txt
  1. 在 sle-ha-2 上 Unmount the filesystem:
$ ssh sle-ha-2 'sudo umount /mnt'
  1. 在 sle-ha-2 上 Demote this node to secondary:
$ ssh sle-ha-2 'sudo drbdadm secondary r0'

the primary is going to be managed by the cluster. So we do not want either of these to be a primary when it’s under cluster control.

  1. Confirm node2 r0 is a secondary:
$ sudo drbdadm status r0

螢幕輸出 :

r0 role:Secondary
  disk:UpToDate
  sle-ha-2 role:Secondary
    peer-disk:UpToDate
  1. Stop the DRBD service on sle-ha-1 and sle-ha-2
$ sudo systemctl stop drbd && ssh sle-ha-2 'sudo systemctl stop drbd'

5. Create and configure cluster resources required for DRBD

Task 1: Create a DRBD cluster resource and a make it a multistate resource

  1. 在 sle-ha-1 執行 crm shell in the configure context:
$ sudo crm configure

螢幕輸出 :

crm(live/sle-ha-1)configure#
  1. 建立 DRBD Primitive Reources
$ primitive p-drbd0 ocf:linbit:drbd \
params drbd_resource=r0 drbdconf="/etc/drbd.conf" \
op monitor interval=29s role=Master \
op monitor interval=31s role=Slave
  1. 建立 DRBD Multi-State resource
$ clone ms-drbd0 p-drbd0 meta master-max=1 master-node-max=1 \
clone-max=2 clone-node-max=1 notify=true promotable=true
  1. Commit the changes
$ commit

Task 2: Create a file system cluster resource for the drbd volume, a colocation constraint and an order constraint

  1. 在 sle-ha-1 執行 crm shell in the configure context:
$ sudo crm configure

螢幕輸出 :

crm(live/sle-ha-1)configure#
  1. create a filesystem resource for the DBRD device:
$ primitive p-drbdvol Filesystem \
params device="/dev/drbd0" directory="/drbdvol" fstype=xfs \
op start timeout=60 \
op stop timeout=60 \
op monitor timeout=40 interval=20
  1. Create an order constraint to ensure that the DRBD Multi-State resource is promoted to master before the filesystem resource is started (mounted):
$ order drbdvol_after_ms-drbd0 inf: ms-drbd0:promote \
p-drbdvol:start
  1. Create a colocation constraint to mount the filesystem on the node running the DRBD Multi-State master:
$ colocation coloc_ms-drbd0_p-drbdvol inf: p-drbdvol \
ms-drbd0:Master
  1. Commit the changes:
$ commit
  1. Exit the crm shell
$ q

Task 3: Check the resources and constrains are correctly configured

  1. In Firefox access the Hawk Web UI, the url is https://172.17.11.10:7630
  2. If required from the left select Monitoring -> Status
  3. Check that the ms-drbd0 and its child resource p-drbd0 are running, to see the child resource click on the + icon next to the ms-drbd0 resource

image

  1. Check the p-drbdvol cluster resource is running

image

  1. Notice which node is the Master for the ms-drbd0 resource, it is displayed in bold

image

  1. 在 sle-ha-1 上列出 /drbdvol 目錄區的內容
$ ls -l /drbdvol

螢幕輸出 :

total 0
-rw-r--r-- 1 root root 0 Jan  2 18:26 file.txt
-rw-r--r-- 1 root root 0 Jan  2 18:32 node2.txt

The files named file.txt and node2.txt are listed

  1. Using the Hawk Web UI check the resources constraints are correctly configured, first stop the ms-drbd0 resource: In the Status screen make sure the Resources tab is selected

image

  1. Click OK to confirm

image

  1. 在 sle-ha-1 上列出 /drbdvol 目錄區的內容
$ ls -l /drbdvol

螢幕輸出 :

total 0

The files are not listed because the volume is not mounted

  1. Using the Hawk Web UI start the ms-drbd0 resource by clicking the Play icon

image

  1. Click OK to start the resources

image

  1. Check the ms-drbd-r0, p-drbd-r0 and p-drbdvol resources are active

image

  1. 在 sle-ha-1 上列出 /drbdvol 目錄區的內容
$ ls -l /drbdvol

螢幕輸出 :

total 0
-rw-r--r-- 1 root root 0 Jan  2 18:26 file.txt
-rw-r--r-- 1 root root 0 Jan  2 18:32 node2.txt

The test files are listed

Summary

本章節建立了 drbd cluster resource,然後建立了 multistate parent resource。

接著,為 drbd volume 創建了一個 cluster resource,並創建了一個 colocation constraint,以確保它在 multistate master 的主機上運作,還創建了一個 order constrain,以確保 drbdvol resource 在 multistate drbd resource promoted 之後被激活。

檢查掛載點的內容以確保 Cluster Resource 已啟動,然後停止 multistate resource 並測試 constraints.

最後再次啟動 multistate resource,檢查 resources 和檔案系統掛載點的內容。

6. Test failover of clustered DRBD

Task 1: Test DRBD configuration in a failover situation

  1. 建立測試檔案
$ sudo touch /drbdvol/isthisfilehere.txt
  1. 檢查檔案是否建立
$ ls -l /drbdvol/

螢幕輸出 :

total 0
-rw-r--r-- 1 root root 0 Jan  2 18:26 file.txt
-rw-r--r-- 1 root root 0 Jan  3 13:32 isthisfilehere.txt
-rw-r--r-- 1 root root 0 Jan  2 18:32 node2.txt
  1. 在沒有運作 master 的節點 (sle-ha-2) 上,執行 cluster monitor
$ sudo crm_mon

螢幕輸出 :

Cluster Summary:
  * Stack: corosync
  * Current DC: sle-ha-1 (version 2.1.5+20221208.a3f44794f-150500.4.9-2.1.5+20221208.a3f44794f) - partition with quorum
  * Last updated: Wed Jan  3 13:49:25 2024
  * Last change:  Wed Jan  3 13:03:50 2024 by hacluster via cibadmin on sle-ha-1
  * 2 nodes configured
  * 8 resource instances configured

Node List:
  * Online: [ sle-ha-1 sle-ha-2 ]

Active Resources:
  * sbd (stonith:external/sbd):  Started sle-ha-1
  * Resource Group: Group-mysql:
    * admin-ip  (ocf::heartbeat:IPaddr2):        Started sle-ha-1
    * mysql     (systemd:mariadb):       Started sle-ha-1
  * p-IP_20     (ocf::heartbeat:IPaddr2):        Started sle-ha-1
  * p-IP_21     (ocf::heartbeat:IPaddr2):        Started sle-ha-2
  * Clone Set: ms-drbd0 [p-drbd0] (promotable):
    * Masters: [ sle-ha-1 ]
    * Slaves: [ sle-ha-2 ]
  * p-drbdvol   (ocf::heartbeat:Filesystem):     Started sle-ha-1
  1. 關閉執行 ms-drbd0 master 程式的節點 (sle-ha-1):
$ sudo poweroff
  1. View the cluster monitor session, the cluster will reconfigure to restore the services. In this test we are only interested in DRBD failing over
  2. Because you have a two node cluster the ms-drbd0 resource will have the Master running on this node, confirm this from crm_mon
Cluster Summary:
  * Stack: corosync
  * Current DC: sle-ha-2 (version 2.1.5+20221208.a3f44794f-150500.4.9-2.1.5+20221208.a3f44794f) - partition with quorum
  * Last updated: Wed Jan  3 13:52:58 2024
  * Last change:  Wed Jan  3 13:03:50 2024 by hacluster via cibadmin on sle-ha-1
  * 2 nodes configured
  * 8 resource instances configured

Node List:
  * Online: [ sle-ha-2 ]
  * OFFLINE: [ sle-ha-1 ]

Active Resources:
  * sbd (stonith:external/sbd):  Started sle-ha-2
  * Resource Group: Group-mysql:
    * admin-ip  (ocf::heartbeat:IPaddr2):        Started sle-ha-2
    * mysql     (systemd:mariadb):       Started sle-ha-2
  * p-IP_21     (ocf::heartbeat:IPaddr2):        Started sle-ha-2
  * Clone Set: ms-drbd0 [p-drbd0] (promotable):
    * Masters: [ sle-ha-2 ]
  * p-drbdvol   (ocf::heartbeat:Filesystem):     Started sle-ha-2
  1. Cancel crm_mon:

CTRL +c

  1. List the contents of /drbdvol
$ ls -l /drbdvol

螢幕輸出 :

total 0
-rw-r--r-- 1 root root 0 Jan  2 18:26 file.txt
-rw-r--r-- 1 root root 0 Jan  3 13:32 isthisfilehere.txt
-rw-r--r-- 1 root root 0 Jan  2 18:32 node2.txt

The test files are listed

在 SLES 12 SP5 安裝和設定 SELinuxSUSE Linux Enterprise HAE