Galera is a synchronous multi-master cluster for MySQL/InnoDB databases. For more information about the product and its features, please visit the official webpage.
Enable at startup
To enable mysql daemon to start at boot, add the mysqld service to systemd:
# systemctl enable mysqld.service
Once you have installed the galera and mysql-wsrep packages, you need to configure the cluster.
On each node edit /etc/mysql/my.cnf and update the variable wsrep_cluster_address so it contains the list of all nodes in the cluster:
Also, change wsrep_node_address and wsrep_node_name variables to the IP address/hostname and name(this doesn't need to be unique) for each node, e.g.:
The wsrep_cluster_name variable should contain the same name for all cluster nodes:
Also, set the wsrep_sst_method variable to the desired state snapshot transfer method, the default one is rsync.
When you have finished with my.cnf file, start the mysqld service on the first node:
# systemctl start mysqld-bootstrap.service
This will bootstrap the cluster. Use MySQL's command line tool to log in as root into your MySQL server:
$ mysql -p -u root
Check the status of the cluster:
mysql> SHOW STATUS LIKE 'wsrep_%';
This will show you wsrep-related status variables:
... | wsrep_local_state | 4 | | wsrep_local_state_comment | Synced | | wsrep_cert_index_size | 0 | | wsrep_causal_reads | 0 | | wsrep_incoming_addresses | 192.168.1.4:3306 | | wsrep_cluster_conf_id | 1 | | wsrep_cluster_size | 1 | | wsrep_cluster_state_uuid | 6cd96745-2ea8-11e3-bbc8-d666651b51ef | | wsrep_cluster_status | Primary | | wsrep_connected | ON | | wsrep_local_index | 0 | | wsrep_provider_name | Galera | ...
If you use xtrabackup or mysqldump SST method, you will need to create a MySQL user for sst transfers.
Once you configured the first node, you should be able to start all other nodes with:
# systemctl start mysqld.service