You say you are using pt-table-checksum 2.0.1. I would recommend updating to 2.1, as there are many improvements in the tool.
Next, let me address your test. You say the slave was not updated after the first or second commands that you ran. The second command looks to be trying to connect directly to the slave. pt-table-checksum won't report any differences unless the server you're connecting to has slaves.
Also, the --replicate-check-only
option will not do any checksumming. (from the docs):
If specified, pt-table-checksum doesn’t checksum any tables. It checks replicas for differences found by previous checksumming, and then exits.
Your first command doesn't seem to be able to connect to the slave host, which is why it doesn't report any differences. Make sure the user/pass that is connecting to the master can also connect to the slave.
Now, as for your complex setup, you are right to worry about breaking replication. With some slaves replicating only certain tables, you should heed the warning here:
If the replicas are configured with any filtering options, you should be careful not to checksum any databases or tables that exist on the master and not the replicas.
You can specify which databases you want to checksum with the --databases
option, and give a specific list of tables with the --tables
option. Alternatively you can use the --ignore-databases
and --ignore-tables
options to provide a list of databases/tables to not checksum.
This will probably mean you will want separate pt-table-checksum commands based on which slaves you are trying to checksum. You will probably have to use the 'dsn' --recursion-method
to accomplish this (I've never done it, personally)
As for load, pt-table-checksum comes with some options to throttle itself. Namely --max-load
and --max-lag
.
The tool keeps track of how quickly the server is able to execute the queries, and adjusts the chunks as it learns more about the server’s performance. It uses an exponentially decaying weighted average to keep the chunk size stable, yet remain responsive if the server’s performance changes during checksumming for any reason. This means that the tool will quickly throttle itself if your server becomes heavily loaded during a traffic spike or a background task, for example.
Here's a method that does not interrupt service on the master, though it does lock the slave temporarily.
Stop the slave.
mysql> STOP SLAVE;
Dump the offending table on the master with mysqldump in a repeatable-read transaction. Include the binary log coordinates in the output (--master-data
). Output one INSERT per row (--skip-extended-insert
).
$ mysqldump --single-transaction --master-data=2 --skip-extended-insert
mydatabase myoffendingtable > master-dump.sql
Note the binlog coordinates in the dump file, and start slave until the coordinate shown in the master's dump file.
mysql> START SLAVE UNTIL MASTER_LOG_FILE='xxxx' MASTER_LOG_POS=yyyy;
Wait until the slave thread catches up to that position and stops itself. This shouldn't take long.
mysql> SELECT MASTER_POS_WAIT('xxxx', yyyy);
Dump the table on the slave, also with one row per INSERT.
$ mysqldump --skip-extended-insert mydatabase myoffendingtable > slave-dump.sql
Resume replication.
mysql> START SLAVE;
Now you can diff the dump files, and be assured they represent exactly the same logical point in the stream of changes. This allows you to find data discrepancies.
Best Answer
You need to use a mysql user that has permissions from the host your executing the script from.
Run
select user, host from mysql.user
on the database to see if your user has an entry for the IP you're connecting from. If not, you will have to grant permissions to the user for that host.