I’ve been meaning to check out Maatkit for a while now. Today I had a reason to as one of our MySQL slaves got out of sync with the master. I’d heard about mk-table-sync, a tool that synchronizes tables, so I thought I’d give it a shot.
As it turns out it’s this easy;
mk-table-sync --execute h=slave_server,u=username,p=secret,D=database,t=table_to_sync --sync-to-master
I was a little worried about how this would pan out as I assumed it would change data on the slave. Cleverly, the Maatkit developers have thought of this;
“When synchronizing a server that is a replication slave with the –replicate or –sync-to-master methods, it always makes the changes on the replication master, never the replication slave directly.” ref
So in theory this should alleviate some of those replication pains. Happy days!