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/Option | Example | Description |
---|
mysql -u <user> -p -h <host> | mysql -u root -p -h 127.0.0.1 | Connect to a MySQL server in the cluster |
SHOW STATUS LIKE 'wsrep%'; | SHOW STATUS LIKE 'wsrep%'; | Display Galera cluster status variables |
Cluster Configuration
#
Command/Option | Example | Description |
---|
wsrep_cluster_address | wsrep_cluster_address=gcomm://node1,node2,node3 | Specify the cluster address for initial node bootstrapping |
wsrep_node_address | wsrep_node_address=127.0.0.1 | Set the address of the current node |
wsrep_node_name | wsrep_node_name=node1 | Assign a name to the current node |
wsrep_sst_method | wsrep_sst_method=xtrabackup-v2 | Define the state snapshot transfer method (SST) |
Cluster Operations
#
Command/Option | Example | Description |
---|
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/Option | Example | Description |
---|
wsrep_sst_auth | wsrep_sst_auth=user:password | Provide authentication credentials for SST |
wsrep_sst_receive_address | wsrep_sst_receive_address=127.0.0.1 | Specify the address to receive SST |
Galera Cluster Status
#
Command/Option | Example | Description |
---|
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/Option | Example | Description |
---|
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/Option | Example | Description |
---|
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.