Corosync

From Gentoo Wiki
Jump to: navigation, search
IconInformation.png
This article is a stub. You can help Gentoo Wiki by expanding it.

Corosync is the currently preferred cluster messaging layer in the Linux cluster community. It is typically used with Pacemaker to set up Gentoo-based clusters.

Installing

Recently there has been a fair amount of standardization-oriented changes within the Linux cluster community. Perhaps as a result, at present the version of Corosync available in the portage tree is out of date.

Download

To get the absolutely latest version of Corosync installed (usually a good idea), you can take the following steps.

First, download the 'git HEAD' (latest release) corosync ebuild from here (bug #429416) and temporarily install it in to your local overlay.

root # mkdir -p /usr/local/portage/sys-cluster/corosync
root #
cd /usr/local/portage/sys-cluster/corosync
root #
wget -O corosync-9999.ebuild 'https://bugs.gentoo.org/attachment.cgi?id=320006'
root #
ebuild corosync-9999.ebuild manifest

You can also unmask/ emerge the version from portage which is pretty recent as of Q1 2013.

Unmask

Next, unmask the package:

root # echo '=sys-cluster/corosync-9999' >>/etc/portage/package.unmask

If you are on amd64 or another untested architecture, you may also need to do the following:

root # echo '=sys-cluster/corosync-9999' >>/etc/portage/package.accept_keywords

Install

Now install corosync:

root # emerge --ask corosync

Configuring

Gentoo installs the example corosync configuration in to /etc/corosync/corosync.conf.example. First copy this to /etc/corosync/corosync.conf:

root # cp /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf

Then edit the file to express your appropriate configuration. The main resources for configuration are the man pages, accessible via:

user $ man corosync_overview
user $
man corosync.conf

For the quorum section, you can also review:

user $ man votequorum

Note for two-node clusters

If you only have two nodes, you will need to enable the two_nodes directive under the quorum{} section, ie:

quorum {
 provider: corosync_votequorum
 expected_votes: 2
 two_nodes: 1
}

Note on hostnames

When building clusters with Corosync and Pacemaker, the primary management tool crm_mon will identify hosts based upon their hostname. Therefore it is desirable to set a hostname that is definitely unique on each node. You can achieve this easily in one of two ways, either setting up hostname entries on your DHCP server (if nodes are DHCP configured), or by setting the hostname from a unique identifier (such as the eth0 MAC address). Here's my hack for the latter, which I run from a custom /init (passed as a kernel option to diskless nodes with NFS root):

# set hostname
hostname `cat /sys/class/net/eth0/address|sed 's/://'`
echo "hostname=\"`hostname`\"" >/etc/conf.d/hostname

If you find yourself with the cluster remembering old/wrong hostname for nodes and you are still in the testing phase, then you can resolve the issue by shutting down all cluster nodes, removing their /var/lib/corosync/ring* cache files, and restarting. This might not be a good idea on live clusters.

Running

Corosync is managed as a standard OpenRC service, ie. you can start and stop it as follows.

root # /etc/init.d/corosync start
root # /etc/init.d/corosync restart
root # /etc/init.d/corosync status
root # /etc/init.d/corosync stop

Debugging

Corosync logs to /var/log/cluster/corosync.log by default. To view the log, run:

user $ tailf /var/log/cluster/corosync.log

If you are having issues even starting Corosync successful (such as receiving "Status: crashed" when executing /etc/init.d/corosync status), then you can start the daemon manually with the -f (foreground) option as follows. (You might also consider first enabling the log_to_stderr directive within /etc/corosync/corosync.conf):

root # /usr/sbin/corosync -f

Next steps

Once you have corosync installed and talking between a couple of machines, you may wish to move on to installing Pacemaker.

See also

External resources

  • For help with configurations, try #linux-cluster (Corosync-oriented) or #linux-ha (Pacemaker-oriented) on Freenode IRC.