Question

Trying to run pt-table-checksum to detect slave drift in MySQL replication. My slaves are not using the standard TCP listening port however, and so when I run the tool I get an error:

Cannot connect to P=3306,h=,p=...

It still checksums the master's tables, but without being able to connect to the slaves it's not very useful. I can't figure out how to specify alternate ports for the slaves when running the command. My current command looks like

pt-table-checksum -h  -P 3388 -p 
Was it helpful?

Solution

The issue is that the replicas don't report their ports to the master. By default pt-table-checksum tries to connect by filling unknowns with defaults; if the unknowns aren't using defaults, this will fail. In this case, there are two options:

1) Use the --recursion-method option to change from inspecting SHOW PROCESSLIST to inspecting SHOW SLAVE HOSTS, and configure slaves to report their host. I don't recommend this.

2) I recommend, instead, that you use --recursion-method=dsn and create a table full of DSN (data source name) instructions that tell the tool how to connect to each replica. If this table is foo.bar, then you will use --recursion-method=dsn=D=foo,t=bar.

This is only available in the 2.0 series of the toolkit, but you should be using that anyway, because pt-table-checksum is hugely improved in 2.0.

OTHER TIPS

The percona tools don't take the standard mysql client arguments. You need to specify a DSN in their format. See http://www.percona.com/doc/percona-toolkit/2.0/pt-table-checksum.html#dsn-options

You'll want something like

pt-table-checksum h=myhost,u=user,p=pass,P=port

Personally I don't like putting credentials in something that will show up in the processlist so you can do

pt-table-checksum --defaults-file=/path/to/my.cnf h=myhost,P=port

where the my.cnf looks like

[client]
user=usernameXYZ
password=asdf234JKL

If you want this to replicate through to your slaves you need to specify a --replicate option that tells it the table to place the checksums in (and consequently put the slave values into on each respective slave). If this is your first time you might want to have it create that table for you with --create-replicate-table.

It won't need to directly connect to the slaves unless you want it to monitor the slaves for falling behind. It basically issues queries like

replace into checksumsTables ... (masterV1, masterV2, (select blah...))

where the literal master values are written to the binlog along w/ the select portion of the replace. When that executes on the slaves the select does it's think to get the slaves checksums.

I've spent a lot of time with this tool recently so start out with that and reply with more specific problems you need help with so I don't just rewrite the entire manual and every possible thing that can go wrong.

Note: if you run

export PTDEBUG=1

Before any percona script it will give you TONS of debug info that can help point you in the direction of what's going wrong. Also remember these are all perl script so you can inspect the source yourself to (maybe) see what's going wrong.

Licensed under: CC-BY-SA with attribution
Not affiliated with dba.stackexchange
scroll top