# Using CMAN for Cluster Membership and Quorum

## Background

CMAN v3 is a Corsync plugin that monitors the names and number of active cluster nodes in order to deliver membership and quorum information to clients (such as the Pacemaker daemons).

In a traditional Corosync-Pacemaker cluster, a Pacemaker plugin is loaded to provide membership and quorum information. The motivation for wanting to use CMAN for this instead, is to ensure all elements of the cluster stack are making decisions based on the same membership and quorum data. A failure to do this can lead to what is called `internal split-brain` - a situation where different parts of the stack disagree about whether some nodes are alive or dead - which quickly leads to unnecssary down-time and/or data corruption.

CMAN has been around longer than Pacemaker and is part of the Red Hat cluster stack, so it is available and supported by many distributions and other pieces of software (such as OCFS2 and GFS2). For this reason it makes sense to support it.

## Adding CMAN Support

Be sure to disable the Pacemaker plugin before continuing with this section. In most cases, this can be achieved by removing `/etc/corosync/service.d/pcmk` and stopping Corosync.

### Adding CMAN Support - cluster.conf

The preferred approach for enabling CMAN is to configure `cluster.conf` and use the `/etc/init.d/cman` script to start Corosync. Its far easier to maintain and start automatically starts the necessary pieces for using GFS2.

You can find some documentation on Installing CMAN and Creating a Basic Cluster Configuration File at the Red Hat website. However please ignore the parts about `Fencing`, `Failover Domains`, or `HA Services` and anything to do with `rgmanager` and `fenced`. All these continue to be handled by Pacemaker in the normal manner.

#### Sample cluster.conf for a two-node cluster

    <?xml version="1.0"?>
    <cluster config_version="1" name="beekhof">
      <logging debug="true"/>
      <clusternodes>
        <clusternode name="pcmk-1" nodeid="1"/>
        <clusternode name="pcmk-2" nodeid="2"/>
      </clusternodes>
      <cman two_node="1" expected_votes="1"/>
    </cluster>

### Adding CMAN Support - corosync.conf

The alternative is to add the necessary cman configuration elements to `corosync.conf`. We recommend you place these directives in `/etc/corosync/service.d/cman` as they will differ between machines.

If you choose this approach, you would continue to start and stop Corosync with it's init script as previously described in this document.

#### Sample corosync.conf extensions for a two-node cluster

    [root@pcmk-1 ~]# cat <<-END >>/etc/corosync/service.d/cman
    cluster {
        name: beekhof

        clusternodes {
                clusternode {
                        votes: 1
                        nodeid: 1
                        name: pcmk-1
                }
                clusternode {
                        votes: 1
                        nodeid: 2
                        name: pcmk-2
                }
        }
        cman {
                expected_votes: 2
                cluster_id: 123
                nodename: `uname -n`
                two_node: 1
                max_queued: 10
        }
    }

    service {
        name: corosync_cman
        ver: 0
    }

    quorum {
        provider: quorum_cman
    }
    END

Verify that `nodename` was set appropriately on each host.