MySQL Group Replication is here and with it comes the need to install and configure the underlying group communication toolkit that supports it: Corosync. Corosync is a well known and reliable Group Communication System that is used in such applications as Pacemaker.
“We develop MySQL Group Replication based on Corosync version 2.3.3, so this tutorial is based on this version. Regardless of this, no known problems are know to exist when using different versions, but no extensive testing has been done on those.”
Along with Corosync we also encourage enabling secure communication, that in Corosync is achieved with NSS, to protect your data that is transmitted in the group.
Installing
To install Corosync, you can rely on your packet manager for most distributions or compile it from source.
==> From the package manager
- Debian distributions
1 |
$ sudo apt-get install corosync corosync-dev libcpg-dev |
- RPM based distributions
1 |
$ yum install corosync corosynclib corosynclib-devel |
==> From source
To compile it from source, first download Corosync version 2.3.3 from
1 |
http://corosync.github.io/corosync/ |
Then, follow the INSTALL file inside tarball.
To perform this task you should need NSS headers installed in the system, and LibQB.
Configuring
==> Configure network, logging and security options
The first part when configuring Corosync is to edit its main configuration file that is on:
1 |
/etc/corosync/corosync.conf |
You should have an example configuration on the folder you can use, and
information exists online and on the man pages about each one of the fields.
Hence, here we only present information about the basics to get you running.
To use the example file, just rename it with:
1 |
# mv /etc/corosync/corosync.conf.example /etc/corosync/corosync.conf |
First of all there are several main set of configurations you can find on this file: totem, logging, quorum, nodelist and qb. We only cover the basic options.
On totem to the default options you should activate encryption with
1
2
|
crypto_cipher: aes128 crypto_hash: sha256 |
This are our suggested defaults, but other algorithmic options exist for these options.
Below you should configure your network interface settings
1
2
3
4
5
6
7
8
9
10
11
|
interface { # Only needed if you use redundant rings ringnumber: 0 # Set it to listen on your network, here configured for local # tests, you usually set it to a NNN.NNN.NNN.0 address bindnetaddr: 127.0.0.1 # Multicast address settings, the default should work but contact # your network admin for what address to use on a real scenario mcastaddr: 226.94.1.1 mcastport: 5405 } |
On the logging section you can set where Corosync prints its messages. You can chose it to print to file, to standard output or syslog and what the log level is.
==> Create configuration files to give users access to Corosync
Next step is to create uidgid files that identify which users can run Corosync. For each one of these users:
Create a file with a name at your choice, fill it with:
1
2
3
4
|
uidgid { uid: USERNAME gid: GROUPNAME } |
and place it under
1 |
/etc/corosync/uidgid.d |
==> Generate a cryptographic key for Corosync (when using encryption)
Run the following command as root:
1 |
# corosync-keygen |
Then copy the generated key to all group machines, and place it under the corosync configuration folder.
==> Configure Corosync to start at boot
- Debian distributions:
Go to file:
1 |
/etc/default/corosync |
and check that you have:
1 |
"START=yes" |
- RPM based distributions:
Run as root:
1 |
# chkconfig corosync on |
Run it
==> Start corosync daemon
1 |
$ sudo service corosync start |
Note that, in some systems (e.g. Ubuntu), if you choose not to start Corosync at boot time, the configuration will stop this command from working.
Alternatively, you can start corosync with the command
1 |
$ sudo corosync |
==> Check that Corosync daemon is running
1
2
|
$ sudo service corosync status $ corosync-cfgtool -s |
Conclusion
I hope this suffices in order to get you running. If you encountered a problem, please let’s us know. Happy testing!