Skip to content

Instantly share code, notes, and snippets.

@bageljp
Created April 12, 2013 03:05
Show Gist options
  • Save bageljp/5369006 to your computer and use it in GitHub Desktop.
Save bageljp/5369006 to your computer and use it in GitHub Desktop.
MySQL Tools
#!/bin/bash
MYSQL_USER="mysql"
MYSQL_PASS="password"
MYSQL_HOST_MASTER[0]="192.168.0.1"
MYSQL_HOST_MASTER[1]="192.168.0.2"
MYSQL_HOST_SLAVE[0]="192.168.0.2"
MYSQL_HOST_SLAVE[1]="192.168.0.3"
echo "------------------"
echo "### MASTER HOST ###"
for host in ${MYSQL_HOST_MASTER[@]}; do
echo -n " ### $host : "
mysql -u "${MYSQL_USER}" -p"${MYSQL_PASS}" -h ${host} -e 'show master status\G' | grep "Pos" | awk '{print $NF}'
done
echo "------------------"
echo "### SLAVE HOST ###"
for host in ${MYSQL_HOST_SLAVE[@]}; do
echo -n " ### $host : "
mysql -u "${MYSQL_USER}" -p"${MYSQL_PASS}" -h ${host} -e 'show slave status\G' | grep "Exec_Master_Log_Pos" | awk '{print $NF}'
done
echo "------------------"
@bageljp
Copy link
Author

bageljp commented Apr 12, 2013

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment