3

I know to check the Galera cluster status, the command that should be used after login to the mysql client is:

SHOW STATUS LIKE 'wsrep%';

but, how to get the output directly from the command line?

The command below result in error:

[root@mariadb01 ~]# mysql -u root -p "SHOW STATUS LIKE 'wsrep%';"
Enter password:
ERROR 1049 (42000): Unknown database 'SHOW STATUS LIKE 'wsrep%';'

I plan to create a simple monitoring using cron and bash, thus the requirement to get the output using command line

2 Answers2

7

After browsing the website http://www.fromdual.com/making-haproxy-high-available-for-mysql-galera-cluster , I found my own answer.

The answer to monitor Galera cluster status from command line is this command:

# mysql -u root -p<your_password> --exec="SHOW STATUS LIKE 'wsrep%';"

Example:

[root@mariadb01 ~]# mysql -u root -p<your_password> --exec="SHOW STATUS LIKE 'wsrep%';" |grep wsrep_local_state_comment
wsrep_local_state_comment       Synced
0

SHOW GLOBAL STATUS LIKE 'wsrep_local_state_comment';

it should Synced

SHOW STATUS LIKE 'wsrep_local_send_queue_avg';

A value greater than 0 indicates replication throttling or network throughput issues. It could be the physical network cards and cables, or the operating system’s configuration

SHOW GLOBAL STATUS LIKE 'wsrep_%';

check node and cluster states, as well as replication health.

SHOW GLOBAL STATUS LIKE 'wsrep_cluster_conf_id';

Each node in the cluster should provide the same value. Otherwise, it indicates that the cluster is partitioned.

Vishe
  • 101