Verify MySQL Master/Slave Replication

  21 Aug 2014


This script could be handy to verify your MySQL Master/Slave Replication setup

It is highly recommended to use ~/.ssh/config (Rather than using Shell Aliases because it will widely work with many programs, for instance scp, mosh, ssh-copy-id and more) So, you would have:

Host data-server-master
    IdentityFile ~/.ssh/<yourprivatekey>
    User boo
    HostName <master host IP>

Host data-server-slave
    IdentityFile ~/.ssh/<yourprivatekey>
    User boo
    HostName <slave host IP>

And, on both servers in boo user home directory. Just create ~/.my.cnf file (if it does not exist yet), fill in this content and modify the user and password part:

[client]
user = DBUSERNAME
password = DBPASSWORD
host = localhost

Download curl -O https://gist.githubusercontent.com/zdk/2b76b84309221b2ade08/raw/d9ef0e1d8d3b13625b9539464a8186792ab836f5/verify_mysql_repl.sh And chmod +x verify_mysql_repl.sh Then, ./verify_mysql_repl.sh

Mine I got:

Master Position: 8253491 -> Slave Position: 8253491

You might see similar output as above but in different positions.

comments powered by Disqus