最後更新: 2021-03-24


GFS2 = Global File System

All nodes in a GFS2 cluster function as peers. (no client or server roles)

Using GFS2 in a cluster requires hardware to allow access to the shared storage,
and a lock manager to control access to the storage.




# Centos 7

yum install -y gfs2-utils dlm

Package: gfs2-utils

  • /usr/sbin/fsck.gfs2
  • /usr/sbin/gfs2_convert
  • /usr/sbin/gfs2_edit
  • /usr/sbin/gfs2_grow
  • /usr/sbin/gfs2_jadd
  • /usr/sbin/gfs2_withdraw_helper
  • /usr/sbin/glocktop
  • /usr/sbin/mkfs.gfs2
  • /usr/sbin/tunegfs2

Package: DLM

DLM = Distributed Lock Manager

kernel is the base component used by OCFS2, GFS2, Cluster MD, and Cluster LVM (lvmlockd)

to provide active-active storage at each respective layer.

  • /etc/sysconfig/dlm    # set command line options for dlm_controld
  • /usr/lib/systemd/system/dlm.service   # start dlm_controld


  • /usr/sbin/dlm_controld
  • /usr/sbin/dlm_stonith      # a proxy for fencing via stonith/pacemaker
  • /usr/sbin/dlm_tool           #  a utility for the dlm and dlm_controld daemon

# 建立 File System

mkfs.gfs2 -p lock_dlm -j 2 -t mycluster:web /dev/drbd1

-p lock_dlm         # specifies that we want to use the kernel 's DLM.

-j 2                     # indicates that the filesystem should reserve enough space for two journals

-t mycluster:web  # specifies the lock table name.
                          # The format for this field is clustername:fsname
                          # grep cluster_name /etc/corosync/corosync.conf





without a redundant communication channel, DLM communication will fail if the TCP link is down.

DLM uses the cluster membership services from Pacemaker which run in user space.
Therefore, DLM needs to be configured as a clone resource that is present on each node in the cluster.

A distributed lock manager (DLM) runs in every machine in a cluster,
with an identical copy of a cluster-wide lock database.

Lock modes

When all processes have unlocked a resource, the system's information about the resource is destroyed.

Null (NL).

Indicates interest in the resource,
but does not prevent other processes from locking it.

Concurrent Read (CR)

Indicates a desire to read (but not update) the resource.
It allows other processes to read or update the resource,
but prevents others from having exclusive access to it.

Concurrent Write (CW)

Indicates a desire to read and update the resource.
It also allows other processes to read or update the resource, but prevents others

Protected Read (PR)

a desire to read the resource but prevents other from updating it

Protected Write (PW)

a desire to read and update the resource and prevents others from updating it

Exclusive (EX)

prevents others from having any access to it