Skip to content

Instantly share code, notes, and snippets.

@michaeldg
Last active June 6, 2016 22:03
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save michaeldg/d6cddbc979d0ff127661dc9e4b7c7388 to your computer and use it in GitHub Desktop.
Save michaeldg/d6cddbc979d0ff127661dc9e4b7c7388 to your computer and use it in GitHub Desktop.
#!/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