#!/bin/bash # # $Id$ # # generic MariaDB Columnstore Slave Replication script. # # Notes: This script gets run by ProcMon during installs and upgrades: # check log for error checkForError() { grep ERROR ${tmpdir}/slave-rep-status.log > ${tmpdir}/error.check if [ `cat ${tmpdir}/error.check | wc -c` -ne 0 ]; then echo "ERROR: check log file: ${tmpdir}/slave-rep-status.log" rm -f ${tmpdir}/error.check exit 1 fi rm -f ${tmpdir}/error.check } pwprompt= for arg in "$@"; do if [ `expr -- "$arg" : '--masteripaddr='` -eq 15 ]; then masteripaddr="`echo $arg | awk -F= '{print $2}'`" elif [ `expr -- "$arg" : '--masterlogfile='` -eq 16 ]; then masterlogfile="`echo $arg | awk -F= '{print $2}'`" elif [ `expr -- "$arg" : '--masterlogpos='` -eq 15 ]; then masterlogpos="`echo $arg | awk -F= '{print $2}'`" elif [ `expr -- "$arg" : '--port='` -eq 7 ]; then port="`echo $arg | awk -F= '{print $2}'`" elif [ $(expr -- "$arg" : '--tmpdir=') -eq 9 ]; then tmpdir="$(echo $arg | awk -F= '{print $2}')" fi done . @ENGINE_SUPPORTDIR@/columnstore_functions repUser="idbrep" password="C0lumnStore!" >${tmpdir}/slave-rep-status.log # # Run stop slave command # echo "Run stop slave command" >>${tmpdir}/slave-rep-status.log cat >${tmpdir}/idb_slave-rep.sql <>${tmpdir}/slave-rep-status.log mysql \ --user=root \ calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1 checkForError # # Run Change Master Command # echo "Run Change Master Command" >>${tmpdir}/slave-rep-status.log cat >${tmpdir}/idb_slave-rep.sql <>${tmpdir}/slave-rep-status.log mysql \ --user=root \ calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1 checkForError # # Run start slave command # echo "Run start slave command" >>${tmpdir}/slave-rep-status.log cat >${tmpdir}/idb_slave-rep.sql <>${tmpdir}/slave-rep-status.log mysql \ --user=root \ calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1 checkForError # # Run SHOW SLAVE STATUS # echo "Run SHOW SLAVE STATUS to node log" >>${tmpdir}/slave-rep-status.log cat >${tmpdir}/idb_slave-rep.sql <>${tmpdir}/slave-rep-status.log mysql \ --user=root \ calpontsys <${tmpdir}/idb_slave-rep.sql >>${tmpdir}/slave-rep-status.log 2>&1 checkForError #alls good, 'OK' for success echo "OK" exit 0