Verify integrity of MySQL slaves

Using this tool http://www.maatkit.org/doc/mk-table-checksum.html

Download the program to the master db server:
wget http://www.maatkit.org/get/mk-table-checksum

Create the needed table in your DB;
CREATE TABLE checksum (
db char(64) NOT NULL,
tbl char(64) NOT NULL,
chunk int NOT NULL,
boundaries char(100) NOT NULL,
this_crc char(40) NOT NULL,
this_cnt int NOT NULL,
master_crc char(40) NULL,
master_cnt int NULL,
ts timestamp NOT NULL,
PRIMARY KEY (db, tbl, chunk)
);

Make the program executable and run it;
chmod +x mk-table-checksum
./mk-table-checksum --replicate=MY_DATABASE.checksum h=localhost,u=USER,p=PASS --replicate-database=MY_DATABASE --databases=MY_DATABASE

On the slaves, look at any inconsistencies:
SELECT * FROM checksum WHERE this_crc != master_crc;

This entry was posted in Uncategorized. Bookmark the permalink.

Leave a Reply

Your email address will not be published. Required fields are marked *