Configuring the Cluster Layout

The following task describes how to create a cluster, add nodes, and configure the chosen heartbeat mode. Run the commands on a single host that you want to be a node in the cluster.

The examples shown create a cluster called mycluster, with the following hostnames and IP addresses as nodes in the cluster:
  • ol-sys0: 10.1.0.100

  • ol-sys1: 10.1.0.110

  • ol-sys2: 10.1.0.120

  1. Define the cluster.

    Create a cluster definition by running the following command on any node:

    sudo o2cb add-cluster cluster-name

    For example, to create the cluster mycluster from the ol-sys1 host, run the following command on ol-sys1:

    sudo o2cb add-cluster mycluster
  2. Add nodes to the cluster.

    Add the current host and all other required hosts as nodes to the cluster.

    sudo o2cb add-node cluster-name hostname --ip ip_address

    The IP address is the IP address that's used by the node for private communication in the cluster.

    For example, to add nodes to mycluster from ol-sys1, you would type the following commands on ol-sys1:

    sudo o2cb add-node mycluster ol-sys0 --ip 10.1.0.100
    sudo o2cb add-node mycluster ol-sys1 --ip 10.1.0.110
    sudo o2cb add-node mycluster ol-sys2 --ip 10.1.0.120

    Note:

    OCFS2 only works with IPv4 addresses.

  3. (Optional) Configure the global heartbeat mode.

    The default heartbeat mode for the cluster is local. If you want the cluster to run in global heartbeat mode, do the following:

    1. Run the following command on every cluster device:

      sudo o2cb add-heartbeat cluster-name device-name

      For example, for mycluster, you set the cluster heartbeat on /dev/sdd, /dev/sdg, and /dev/sdj as follows:

      sudo o2cb add-heartbeat mycluster /dev/sdd
      sudo o2cb add-heartbeat mycluster /dev/sdg
      sudo o2cb add-heartbeat mycluster /dev/sdj
    2. Set the cluster's heartbeat mode to global.

      sudo o2cb heartbeat-mode cluster-name global

    Important:

    You must configure the global heartbeat feature to use whole disk devices. You can't use disk partitions for global heartbeat mode.

  4. Copy the cluster configuration file to each cluster node.

    Copy the cluster /etc/ocfs2/cluster.conf file to each node in the cluster.

  5. (Optional) Show information about the cluster.

    Run the following command to display information about the cluster:

    sudo o2cb list-cluster cluster-name

    A three-node cluster with a global heartbeat would display information similar to the following:

    node:
           name = ol-sys0
           cluster = mycluster
           number = 0
           ip_address = 10.1.0.100
           ip_port = 7777
    
    node:
           name = ol-sys1
           cluster = mycluster
           number = 1
           ip_address = 10.1.0.110
           ip_port = 7777
    
    node:
           name = ol-sys2
           cluster = mycluster
           number = 2
           ip_address = 10.1.0.120
           ip_port = 7777
    
    cluster:
           name = mycluster
           heartbeat_mode = global
           node_count = 3
    
    heartbeat:
           cluster = mycluster
           region = 7DA5015346C245E6A41AA85E2E7EA3CF
    
    heartbeat:
           cluster = mycluster
           region = 4F9FBB0D9B6341729F21A8891B9A05BD
    
    heartbeat:
           cluster = mycluster
           region = B423C7EEE9FC426790FC411972C91CC3

    The heartbeat regions are represented by the UUIDs of their block devices.

    The same cluster mycluster with a local heartbeat would display the following information:

    node:
           name = ol-sys0
           cluster = mycluster
           number = 0
           ip_address = 10.1.0.100
           ip_port = 7777
      
    node:
           name = ol-sys1
           cluster = mycluster
           number = 1
           ip_address = 10.1.0.110
           ip_port = 7777
      
    node:
           name = ol-sys2
           cluster = mycluster
           number = 2
           ip_address = 10.1.0.120
           ip_port = 7777
      
    cluster:
           name = mycluster
           heartbeat_mode = local
           node_count = 3