MySQL Galera Cluster

MySQL Galera Cluster Cheatsheet #

MySQL Galera Cluster is a synchronous multi-master cluster for MySQL, providing high availability and data consistency across multiple nodes.

General Commands #

Command/OptionExampleDescription
mysql -u <user> -p -h <host>mysql -u root -p -h 127.0.0.1Connect to a MySQL server in the cluster
SHOW STATUS LIKE 'wsrep%';SHOW STATUS LIKE 'wsrep%';Display Galera cluster status variables

Cluster Configuration #

Command/OptionExampleDescription
wsrep_cluster_addresswsrep_cluster_address=gcomm://node1,node2,node3Specify the cluster address for initial node bootstrapping
wsrep_node_addresswsrep_node_address=127.0.0.1Set the address of the current node
wsrep_node_namewsrep_node_name=node1Assign a name to the current node
wsrep_sst_methodwsrep_sst_method=xtrabackup-v2Define the state snapshot transfer method (SST)

Cluster Operations #

Command/OptionExampleDescription
SET GLOBAL wsrep_on=OFF;SET GLOBAL wsrep_on=OFF;Disable writes to the cluster (useful for maintenance)
SET GLOBAL wsrep_on=ON;SET GLOBAL wsrep_on=ON;Enable writes to the cluster
SHOW STATUS LIKE 'wsrep_cluster_size';SHOW STATUS LIKE 'wsrep_cluster_size';Check the number of nodes in the cluster

State Snapshot Transfer (SST) #

Command/OptionExampleDescription
wsrep_sst_authwsrep_sst_auth=user:passwordProvide authentication credentials for SST
wsrep_sst_receive_addresswsrep_sst_receive_address=127.0.0.1Specify the address to receive SST

Galera Cluster Status #

Command/OptionExampleDescription
SHOW STATUS LIKE 'wsrep_%';SHOW STATUS LIKE 'wsrep_%';Retrieve detailed Galera cluster status
SHOW VARIABLES LIKE 'wsrep%';SHOW VARIABLES LIKE 'wsrep%';Display Galera cluster configuration variables

Troubleshooting #

Command/OptionExampleDescription
SHOW PROCESSLIST;SHOW PROCESSLIST;Check current MySQL processes and identify issues
CHECK TABLE <table_name>;CHECK TABLE my_table;Verify the integrity of a table

Node Management #

Command/OptionExampleDescription
STOP SLAVE;STOP SLAVE;Stop the replication process on a node
START SLAVE;START SLAVE;Start the replication process on a node

This cheatsheet covers the key MySQL Galera Cluster commands and options, assisting you in configuring, managing, and troubleshooting your cluster effectively.

MySQL Galera Cluster

Explore our comprehensive cheatsheets to enhance your knowledge and efficiency. Each cheatsheet provides detailed command options, examples, and descriptions to help you master various tools and technologies.