Ondrej Famera - top logo

Pacemaker 2.0 with Corosync 3.0 on Gentoo - Installation

As longtime Gentoo user I like to try out some of things I have worked with on different distros on Gentoo. This time the High Availability clustering with pacemaker came to my mind. I have worked mainly with Pacemaker 1.1.x stack on RHEL/CentOS 6/7. Looking at official repos of Gentoo these seems to be present but there is nothing for Pacemaker 2.0 which requires now Corosync 3.0 and can be tested in Fedora 28 or newer. So lets have a look how to get this to Gentoo.

In examples below I will be using the two Gentoo systems with systemd which I have conveniently available as fast-vm image. As the Pacemaker 2.0 nor Corosync 3.0 are not available from official Gentoo repos I have created ebuilds for both these in my ondrejhome-gentoo-overlay. Note that Corosync 3.0 comes with new type of transport named knet that requires KNET library as hard dependency (this library is included in 'ondrejhome-gentoo-overlay'). I will use systems with disabled firewall. Configuration explained here would need at minimum ports 5404/udp and 5405/udp to be opened between cluster nodes for proper corosync configuration.

Installing Pacemaker

Note that for High Availability systems it makes sense to have cluster running on more than 1 node. Otherwise we are basically configuring overly complicated (for the purpose it serves) systems to manage local services. All steps below must be done on all nodes you plan to use unless stated otherwise.

1. Install dev-vcs/git in case that you don't have it - this is needed to sync the 'ondrejhome-gentoo-overlay'.
# emerge -av dev-vcs/git
2. Add the 'ondrejhome-gentoo-overlay' to system and sync it.
# mkdir /etc/portage/repos.conf/
# curl https://raw.githubusercontent.com/OndrejHome/ondrejhome-gentoo-overlay/master/ondrejhome-overlay.conf > /etc/portage/repos.conf/ondrejhome-overlay.conf
# emaint sync --repo ondrejhome
3. Install the Pacemaker 2.0.1 package with its dependencies. Below example unmasks the needed dependencies and install 3 packages from 'ondrejhome-gentoo-overlay' needed for Pacemaker 2. Answer 'yes' for both question to emerge the Pacemaker 2.
# emerge -av \=sys-cluster/pacemaker-2.0.1 --autounmask-continue y
...
# required by =sys-cluster/pacemaker-2.0.1 (argument)
=sys-cluster/pacemaker-2.0.1 ~amd64
# required by sys-cluster/corosync-3.0.1::ondrejhome
# required by sys-cluster/pacemaker-2.0.1::ondrejhome
# required by =sys-cluster/pacemaker-2.0.1 (argument)
=sys-cluster/kronosnet-1.8 ~amd64
# required by sys-cluster/pacemaker-2.0.1::ondrejhome
# required by =sys-cluster/pacemaker-2.0.1 (argument)
=sys-cluster/corosync-3.0.1 ~amd64
...
Would you like to add these changes to your config files? [Yes/No]
...
[ebuild  N    ~] sys-cluster/kronosnet-1.8::ondrejhome  USE="bzip2 lz4 openssl zlib -docs -lzo -nss -sctp" 206 KiB
[ebuild  N    ~] sys-cluster/corosync-3.0.1::ondrejhome  USE="systemd -doc -snmp -static-libs -watchdog -xml" 413 KiB
[ebuild  N    ~] sys-cluster/pacemaker-2.0.1::ondrejhome  USE="acl systemd -hardened -snmp -static-libs" PYTHON_SINGLE_TARGET="python3_6 -python2_7 -python3_5 -python3_7" PYTHON_TARGETS="python2_7 python3_6 -python3_5 -python3_7" 5,378 KiB
...
Would you like to merge these packages? [Yes/No]
...

Configuring corosync and starting cluster

4. Configure /etc/corosync/corosync.conf on both nodes - this files should be same on all cluster nodes.
# cat /etc/corosync/corosync.conf
totem {
    version: 2
    cluster_name: my_pacemaker2_cluster
    transport: knet
}

nodelist {
    node {
        ring0_addr: 192.168.22.45
        name: node1
        nodeid: 1
    }
    node {
        ring0_addr: 192.168.22.46
        name: node2
        nodeid: 2
    }
}

quorum {
    provider: corosync_votequorum
    two_node: 1
}

logging {
}
5. Start the corosync and pacemaker service on both nodes at same/similar time.
# systemctl start corosync pacemaker
6. Wait for cluster to form. Use the crm_mon command on any of the nodes to watch progress in real time.
Stack: corosync
Current DC: NONE
Last updated: Sat May  4 10:29:10 2019
Last change: Sat May  4 10:28:31 2019 by root via cibadmin on node1

2 nodes configured
0 resources configured

OFFLINE: [ node1 node2 ]

No active resources
After few seconds you should see that both nodes detects the other to be online.
Stack: corosync
Current DC: node1 (version 2.0.1-9e909a5bdd) - partition with quorum
Last updated: Sat May  4 10:29:20 2019
Last change: Sat May  4 10:28:31 2019 by root via cibadmin on node1

2 nodes configured
0 resources configured

Online: [ node1 node2 ]

No active resources

At this point you will have a pacemaker cluster running on both nodes and if the nodes report each other as 'online' then you are ready to start configuring the cluster. You can configure the pacemaker cluster now using crm_* and cibadmin commands or use some high-level tools for configuring the pacemaker clusters. At this moment only masked version of sys-cluster/crmsh is available in Gentoo official repository. Check out the available higher-level interfaces to Pacemaker for more options. Some 'building from source' or 'searching the Internet' seems to be required to get them working.

Last change .