I set up a replication slave at our office to a MySQL server running at our colo and the master server is pretty busy. So busy that even with the compressed protocol option turned on the stream was taking a good 60-70 kbps out of the available bandwidth of our T1. Since it isn’t critical that this data be real-time slaved, I made a small shell script that can take parameters for starting and stopping either the sql or io threads: mysqlslavectl.sh
#!/bin/sh - # # USER=mysqladmin PASSWD=adminpwd SCRIPT="/usr/local/mysql/bin/mysql -u$USER -p$PASSWD -e " StartService () { case $1 in sql ) $SCRIPT "START SLAVE SQL_THREAD" ;; io ) $SCRIPT "START SLAVE IO_THREAD" ;; * ) echo "$0: unknown Start argument: $1";; esac } StopService () { case $1 in sql ) $SCRIPT "STOP SLAVE SQL_THREAD" ;; io ) $SCRIPT "STOP SLAVE IO_THREAD" ;; * ) echo "$0: unknown Stop argument: $1";; esac } CheckCommand () { case $1 in start ) StartService "$2" ;; stop ) StopService "$2" ;; * ) echo "$0: unknown argument: $1";; esac } CheckCommand "$1" "$2"
I can call this like so:
mysqlslavectl.sh start io
mysqlslavectl.sh stop sql
I setup a couple of crontab entries, one to start the io thread at 8pm and one to stop the io thread at 6AM.
The sql thread will always be running.