Below are the steps to build a simple cman + rgmanager based cluster environment in KVM. I write down the steps for future reference. Check https://feichashao.com/pacemaker/ for building pacemaker environment (Chinese edition).
a. Prepare two virtual machines, RHEL6.8 in my case.
I have 2 nodes, one named `ccs1` and `ccs2` for another.
b. Configure Repos in both nodes, and install packages.
[iso]
name=iso
baseurl=file:///mnt/yum
gpgcheck=0
enabled=1
[HA]
name=HA
baseurl=file:///mnt/yum/HighAvailability/
gpgcheck=0
enabled=1
[RS]
name=RS
baseurl=file:///mnt/yum/ResilientStorage/
gpgcheck=0
enabled=1
[root@ccs2 ~]# yum install ccs cman corosync rgmanager
[root@ccs1 ~]# chkconfig cman on
[root@ccs2 ~]# chkconfig cman on
[root@ccs1 ~]# echo redhat | passwd --stdin ricci
[root@ccs2 ~]# echo redhat | passwd --stdin ricci
c. Form a two node cluster using CCS.
[root@ccs1 ~]# ccs -h ccs1 --addnode ccs1
[root@ccs1 ~]# ccs -h ccs1 --addnode ccs2
[root@ccs1 ~]# ccs -h ccs1 --setcman two_node=1 expected_votes=1
d. Configure fence device.
In KVM host, generate a key to /etc/cluster/fence_xvm.key
Copy the same key to all nodes' /etc/cluster/fence_xvm.key
In KVM host, start `fence_virtd` service:
Inside cluster node, add fence configuration.
[root@ccs1 ~]# ccs -h ccs1 --addmethod XVM ccs1
[root@ccs1 ~]# ccs -h ccs1 --addmethod XVM ccs2
[root@ccs1 ~]# ccs -h ccs1 --addfenceinst myfence ccs1 XVM domain=<Virtual-Machine-name-of-ccs1>
[root@ccs1 ~]# ccs -h ccs1 --addfenceinst myfence ccs2 XVM domain=<Virtual-Machine-name-of-ccs2>
e. Sync the cluster.conf to `ccs2`.
f. Start cluster and check status.
[root@ccs1 ~]# clustat
[root@ccs1 ~]# fence_check
For more information, please check Chapter 6 and Chapter 7 of Cluster Administration Guide.
https://access.redhat.com/documentation/en-US/Red_Hat_Enterprise_Linux/6/html-single/Cluster_Administration/#ch-mgmt-conga-CA