Last active
June 6, 2016 22:03
-
-
Save michaeldg/d6cddbc979d0ff127661dc9e4b7c7388 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# | |
# https://gist.github.com/michaeldg/d6cddbc979d0ff127661dc9e4b7c7388 | |
# | |
# This script extracts a MariaDB row based replication (RBR) binary log, passes it on to binlog-rbr-to-sbr.py and digests the output. | |
# Relies on https://gist.github.com/shlomi-noach/cc243fd690403e7617e3 and pt-query-digest being present in $PATH | |
# | |
# Author: Michaël de Groot <michael.degroot@mariadb.com> | |
if [ -z $1 ] | |
then | |
echo "Usage: $0 <path to binlog file.000123>" | |
exit 0 | |
fi | |
RBR_TO_SBR_PATH=`which binlog-rbr-to-sbr.py` | |
if [ -z $RBR_TO_SBR_PATH ] | |
then | |
echo "Install convert script first: https://gist.github.com/shlomi-noach/cc243fd690403e7617e3" | |
exit 0 | |
fi | |
DIGEST_PATH=`which pt-query-digest` | |
if [ -z $DIGEST_PATH ] | |
then | |
echo "Install percona-toolkit first" | |
exit 0 | |
fi | |
MYSQLBINLOG_PATH=`which mysqlbinlog` | |
if [ -z $MYSQLBINLOG_PATH ] | |
then | |
echo "Install MariaDB-server first" | |
exit 0 | |
fi | |
$MYSQLBINLOG_PATH --verbose --base64-output=DECODE-ROW $1 | $RBR_TO_SBR_PATH | $DIGEST_PATH --type=binlog --order-by Query_time:cnt --group-by fingerprint |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment