Galera Cluster (MySQL from Codership, Percona XtraDB Cluster, MariaDB Galera Cluster) generates a GRA log files if it fails to apply the writeset on the target node. This files exists in the MySQL data directory. You can get an overview of the file (if exist) by listing your MySQL data directory (in my case, the data directory is at /var/lib/mysql):
$ ls -1 /var/lib/mysql | grep GRA GRA_10_104865779.log GRA_13_104865781.log GRA_5_104865780.log |
MySQL Performance Blog has covered this topic in well-explained. I’m going to make this simple. Download the script here and copy it to your /usr/bin directory:
wget http://blog.secaserver.com/files/grareader -P /usr/bin/ chmod 755 /usr/bin/grareader |
Just run following command to simply convert the GRA log file to a human-readable output:
grareader [gra_log_file] |
Here is the example output:
/*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=1*/; /*!40019 SET @@session.max_insert_delayed_threads=0*/; /*!50003 SET @[email protected]@COMPLETION_TYPE,COMPLETION_TYPE=0*/; DELIMITER /*!*/; # at 4 #140114 3:12:42 server id 3 end_log_pos 120 Start: binlog v 4, server v 5.6.15-log created 140114 3:12:42 at startup ROLLBACK/*!*/; BINLOG ' qjrUUg8DAAAAdAAAAHgAAAAAAAQANS42LjE1LWxvZwAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAAA AAAAAAAAAAAAAAAAAACqOtRSEzgNAAgAEgAEBAQEEgAAXAAEGggAAAAICAgCAAAACgoKGRkAAf73 8eY= '/*!*/; # at 120 #140114 3:12:43 server id 3 end_log_pos 143 Stop # at 143 #140507 14:55:42 server id 4 end_log_pos 126 Query thread_id=3173489 exec_time=0 error_code=0 use `test_shop`/*!*/; SET TIMESTAMP=1399445742/*!*/; SET @@session.pseudo_thread_id=3173489/*!*/; SET @@session.foreign_key_checks=1, @@session.sql_auto_is_null=0, @@session.unique_checks=1, @@session.autocommit=1/*!*/; SET @@session.sql_mode=0/*!*/; SET @@session.auto_increment_increment=1, @@session.auto_increment_offset=1/*!*/; /*!\C utf8 *//*!*/; SET @@session.character_set_client=33,@@session.collation_connection=33,@@session.collation_server=8/*!*/; SET @@session.lc_time_names=0/*!*/; SET @@session.collation_database=DEFAULT/*!*/; ALTER TABLE `tblreshipment_header` DROP `ShipmentStatus` /*!*/; DELIMITER ; # End of log file ROLLBACK /* added by mysqlbinlog */; /*!50003 SET [email protected]_COMPLETION_TYPE*/; /*!50530 SET @@SESSION.PSEUDO_SLAVE_MODE=0*/; |
You can download the script here or copy and paste the code:
#!/bin/bash # Convert Galera GRA_* files to human readable output # Usage: grareader # Example: grareader /var/lib/mysql/GRA_1_1.log ## ## GRA header file path ## path=/tmp gra_header_path=$path/GRA-Header tmp_path=$path/grareader.tmp input=$1 [ ! -e $input ] && echo 'Error: File does not exist' && exit 1 get_gra_header() { download_url='http://blog.secaserver.com/files/GRA-Header' wget_bin=`command -v wget` [ -z "$wget_bin" ] && echo 'Error: Unable to locate wget. Please install it first' && exit 1 echo "Downloadling GRA-Header file into $path" $wget_bin --quiet $download_url -P $path [ $? -ne 0 ] && echo 'Error: Download failed' && exit 1 } locate_files() { mysqlbinlog_bin=`command -v mysqlbinlog` [ -z "$mysqlbinlog_bin" ] && echo 'Error: Unable to locate mysqlbinlog binary. Please install it first' && exit 1 [ ! -e $gra_header_path ] && echo 'Error: Unable to locate GRA header file' && get_gra_header } locate_files cat $gra_header_path >> $tmp_path cat $input >> $tmp_path echo '' clear $mysqlbinlog_bin -v -v -v $tmp_path echo '' rm -rf $tmp_path |
Hope this could help make your Galera administrative task simpler!