OCFS2 Multi-Node Cluster Setup
This guide provides a step-by-step procedure for configuring the O2CB cluster stack, configuring nodemanager daemons, formatting shared LUNs, and mounting OCFS2 across all PiVirt cluster nodes.
Prerequisites
Section titled “Prerequisites”# Install OCFS2 toolsapt-get install -y ocfs2-tools
# Load kernel modulesmodprobe ocfs2modprobe ocfs2_dlmfsmodprobe ocfs2_nodemanagerCluster Configuration
Section titled “Cluster Configuration”Configure O2CB Cluster
Section titled “Configure O2CB Cluster”# Create cluster configurationcat > /etc/ocfs2/cluster.conf <<EOFcluster: node_count = 3 name = pivirt-cluster
node: ip_port = 7777 ip_address = 10.0.1.10 number = 0 name = node-01 cluster = pivirt-cluster
node: ip_port = 7777 ip_address = 10.0.1.11 number = 1 name = node-02 cluster = pivirt-cluster
node: ip_port = 7777 ip_address = 10.0.1.12 number = 2 name = node-03 cluster = pivirt-clusterEOFStart O2CB Service
Section titled “Start O2CB Service”# Start O2CBsystemctl start o2cb
# Enable on bootsystemctl enable o2cb
# Check statussystemctl status o2cbFormat OCFS2 Volume
Section titled “Format OCFS2 Volume”Using pvcli
Section titled “Using pvcli”pvcli storage ocfs2 create \ --name vm-shared \ --device /dev/disk/by-id/scsi-360050764008181c60000000000000001 \ --cluster pivirt-cluster \ --label vm-sharedUsing mkfs.ocfs2
Section titled “Using mkfs.ocfs2”# Format volumemkfs.ocfs2 \ --cluster-stack=pcmk \ --cluster-name=pivirt-cluster \ -N 3 \ -L vm-shared \ /dev/disk/by-id/scsi-360050764008181c60000000000000001Mount OCFS2
Section titled “Mount OCFS2”Manual Mount
Section titled “Manual Mount”# Create mount pointmkdir -p /var/lib/pivirtd/shared
# Mount OCFS2mount -t ocfs2 -o _netdev,nointr \ /dev/disk/by-id/scsi-360050764008181c60000000000000001 \ /var/lib/pivirtd/sharedUsing pvcli
Section titled “Using pvcli”pvcli storage ocfs2 mount \ --name vm-shared \ --mount-point /var/lib/pivirtd/shared \ --all-nodesFstab Entry
Section titled “Fstab Entry”# Add to /etc/fstab/dev/disk/by-id/scsi-360050764008181c60000000000000001 /var/lib/pivirtd/shared ocfs2 _netdev,nointr 0 0Fencing Configuration
Section titled “Fencing Configuration”SBD Fencing
Section titled “SBD Fencing”# Install SBDapt-get install -y sbd
# Configure SBDcat > /etc/default/sbd <<EOFSBD_DEVICE="/dev/disk/by-id/scsi-360050764008181c60000000000000002"SBD_PACEMAKER=yesSBD_STARTMODE=alwaysSBD_DELAY_START=noEOF
# Initialize SBDsbd -d /dev/disk/by-id/scsi-360050764008181c60000000000000002 createIPMI Fencing
Section titled “IPMI Fencing”cluster: fencing: enabled: true agent: "ipmi" devices: - name: "node-01-fence" ip: "10.0.0.11" user: "admin" password_ref: "vault:secret/data/bmc/node-01#password" lanplus: trueMonitoring
Section titled “Monitoring”Check Cluster Status
Section titled “Check Cluster Status”# Check O2CB statuso2cb cluster-status
# Check node statuso2cb node-status
# Check mounted filesystemsmounted.ocfs2 -fCheck DLM Status
Section titled “Check DLM Status”# Check DLMdlm_tool ls
# Check lockspacedlm_tool lockdebug pivirt-dlmTroubleshooting
Section titled “Troubleshooting”Mount Fails
Section titled “Mount Fails”# Check cluster statuso2cb cluster-status
# Check DLMdlm_tool ls
# Check logsjournalctl -u o2cb -fdmesg | grep -i ocfs2Quorum Lost
Section titled “Quorum Lost”# Check node connectivityping 10.0.1.11ping 10.0.1.12
# Check O2CB logsjournalctl -u o2cb -f
# Restart O2CBsystemctl restart o2cbFilesystem Corruption
Section titled “Filesystem Corruption”# Unmount filesystemumount /var/lib/pivirtd/shared
# Check filesystemfsck.ocfs2 -f /dev/disk/by-id/scsi-360050764008181c60000000000000001
# Mount againmount -t ocfs2 -o _netdev,nointr \ /dev/disk/by-id/scsi-360050764008181c60000000000000001 \ /var/lib/pivirtd/shared