Installing MySQL/Galera

Demo Setup

To setup MySQL/Galera demo cluster you will need several networked computers - one for each mysqld instance you plan to use. For best performance those computers should be of approximately same configuration: Galera replication is synchronous and one slow machine will slow down the whole cluster.

You must also select one machine that would host group communication daemon (hereafter arbitrator). For best performance it should be a separate computer, but it also can be one of the MySQL nodes. The only requirement is that arbitrator is accessible to all other cluster nodes.

It takes 3 steps to set up the cluster:

  1. Copy demo distribution to all prospective nodes of the cluster and unpack it to location of your choice.
  2. Start group communication daemon on arbitrator node by running gcomm script from the distribution.
  3. Start MySQL servers.

(NOTE: You can easily set up the cluster on a single computer. However this makes little sense, as you won't see the the benefits of high availability and scalability. Hence, single node setup is not covered by this document.)

Demo Installation

Just copy and unpack the demo on the prospective cluster nodes to wherever you have privileges. The demo was designed to be able to run on most systems without reconfiguration. It is a self-contained MySQL installation and comes with its own data directory and a preconfigured empty database with users:

  • 'root' (password 'rootpass')
  • 'test' (password 'testpass', privileges on schema 'test')

As a result default installation will require at least 1Gb of free space for InnoDB files (will be created on first start). This requirement, as well as other MySQL and Galera options can be changed by editing configuration file which can be found at <DEMO_ROOT>/mysql/etc/my.cnf.

Starting Group Communication Daemon

Select one of the nodes to act as an arbitrator and on that node, issue the following command:

$ <DEMO_ROOT>/gcomm start

This will start a Galera group communication daemon listening on all interfaces at port 4567. GCS_ADDRESS environment variable can be used to bind the daemon to particular interface or port, e.g.:

$ GCS_ADDRESS=tcp:192.168.0.1:3333 <DEMO_ROOT>/gcomm start

Starting MySQL Servers

<DEMO_ROOT>/mysql-galera is a special MySQL startup script that sets proper options (including data directory path) for mysqld. If you're running it as a superuser, you have to make sure there is 'mysql' user in the system and it has sufficient privileges on the demo directory (see MySQL Manual about running mysqld as root).

You will need to tell mysqld the address of the group communication daemon. For the purpose of this demo the address follows this layout: gcomm://tcp:<IP address>:<port>.

Thus, if you have started gcomm on the node with IP address 192.168.1.1, then GCS address would be gcomm://tcp:192.168.1.1:4567

  1. Either supply the address as the option on the command line:

    $ <DEMO_ROOT>/mysql-galera -g gcomm://tcp:192.168.1.1:4567 start

  2. Or you can hardcode it in <DEMO_ROOT>/mysql/etc/my.cnf by setting wsrep_gcs_address="gcomm://tcp:192.168.1.1:4567" and then just launch mysql-galera script:

    $ <DEMO_ROOT>/mysql-galera start

It might take few minutes to start mysqld for the first time as it will have to create required InnoDB files.

For full description of mysql-galera options and commands see:

$ <DEMO_ROOT>/mysql-galera --help