From Gentoo Wiki
Jump to: navigation, search
This article is a stub. You can help 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.


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.

USE flags

Cannot load package information. Is the atom sys-cluster/corosync correct?


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 to an ebuild repository.

root #mkdir -p /usr/local/portage/sys-cluster/corosync
root #cd /usr/local/portage/sys-cluster/corosync
root #wget -O corosync-9999.ebuild ''
root #ebuild corosync-9999.ebuild manifest

You can also unmask and emerge the latest version from portage which is pretty recent.


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


Now install corosync:

root #emerge --ask sys-cluster/corosync


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.


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


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

user $tail -f /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.