Lab 04: Linux Clustering & Shared Storage

Time: 45 minutes | Level: Architect | Docker: docker run -it --rm --privileged ubuntu:22.04 bash


Overview

Enterprise Linux clustering requires more than just failover — it requires coordinated access to shared storage. In this lab you will explore cluster storage architectures including GFS2 and OCFS2 cluster filesystems, DRBD block-level replication, DLM distributed lock management, cluster LVM, and fencing devices that protect data integrity in split-brain scenarios.

Learning Objectives:

  • Distinguish shared-nothing vs shared-disk cluster architectures

  • Understand GFS2/OCFS2 cluster filesystem concepts and configuration

  • Configure DRBD (Distributed Replicated Block Device)

  • Understand DLM (Distributed Lock Manager) operation

  • Configure fencing devices (fence_xvm, fence_ipmilan)

  • Use clvmd for cluster LVM management


Step 1: Install Cluster Storage Tools

apt-get update
DEBIAN_FRONTEND=noninteractive apt-get install -y \
    pacemaker corosync pcs \
    lvm2 \
    kmod \
    2>/dev/null

echo "=== Installed tools ==="
lvm version 2>&1 | head -3

📸 Verified Output:

💡 Tip: In a real production environment, you would also install drbd-utils, gfs2-utils, ocfs2-tools, and dlm-controld. These require kernel modules and real block devices — Docker containers use the host kernel.


Step 2: Cluster Architecture Comparison

Shared-Nothing Architecture

Shared-Disk Architecture


Step 3: DRBD — Distributed Replicated Block Device

DRBD provides synchronous block-level replication between two nodes (RAID-1 over the network):

DRBD resource configuration (/etc/drbd.d/mydata.res):

📸 Verified Output:

DRBD management commands:

💡 Tip: DRBD Protocol C is synchronous — the write is only acknowledged to the application when BOTH nodes have written the data to disk. This guarantees zero data loss on failover but adds write latency proportional to network RTT. Use Protocol A for geo-replication where some data loss is acceptable.


Step 4: GFS2 — Global Filesystem 2

GFS2 is a cluster filesystem allowing simultaneous read/write from multiple nodes on shared storage:

📸 Verified Output:

💡 Tip: GFS2 requires fencing (STONITH). Without proper fencing, if a node fails mid-write, surviving nodes cannot be sure the failed node stopped writing. The filesystem could be corrupted. Never disable STONITH on a GFS2 cluster.


Step 5: OCFS2 — Oracle Cluster Filesystem 2

OCFS2 is Oracle's cluster filesystem, better suited for VM image storage and databases:

📸 Verified Output:


Step 6: DLM — Distributed Lock Manager

DLM provides distributed locking services for GFS2, OCFS2, and cluster LVM:

📸 Verified Output:

💡 Tip: DLM lockspace names must be unique and match between all cluster nodes. GFS2 uses lock_dlm as its locking protocol with lockspace name matching the cluster name specified in mkfs.gfs2 -t <cluster>:<fs>.


Step 7: Cluster LVM (clvmd) and Fencing Devices

Cluster LVM:

📸 Verified Output:

💡 Tip: fence_ipmilan requires the lanplus option for IPMI 2.0 (required for most modern servers with iDRAC/iLO). Test fencing manually before relying on it: fence_ipmilan -a <ip> -l admin -p secret --lanplus -o status. Never configure fencing that you haven't tested!


Step 8: Capstone — Design a Shared Storage Cluster

Scenario: Design a 2-node database cluster using DRBD + GFS2 + Pacemaker with proper fencing for a PostgreSQL HA solution.

📸 Verified Output:

📸 Verified Output:


Summary

Technology
Use Case
Key Tool
Config File

Shared-Nothing

General HA, cloud

DRBD, replication

/etc/drbd.d/*.res

Shared-Disk

Concurrent access

GFS2, OCFS2

/etc/cluster/

DRBD

Block-level replication

drbdadm

/etc/drbd.d/

GFS2

Cluster filesystem (shared)

mkfs.gfs2, gfs2_tool

Corosync cluster name

OCFS2

Oracle cluster filesystem

mkfs.ocfs2

/etc/ocfs2/cluster.conf

DLM

Distributed locking

dlm_tool

Auto via Corosync

Cluster LVM

Shared VG/LV management

lvmlockd, lvmlockctl

/etc/lvm/lvm.conf

fence_ipmilan

Physical server fencing

fence_ipmilan

pcs stonith config

fence_aws

AWS EC2 fencing

fence_aws

pcs stonith config

fence_xvm

VM/hypervisor fencing

fence_xvm

/etc/cluster/fence_xvm.key

Last updated