简而言之,您需要添加选项 b=true 和 --local
请注意,b=true 是一个 DSN 选项,需要在 --source 或 --dest 之后添加,具体取决于您的需要。我将在此答案的底部展示一个示例。
您可以轻松地尝试这个虚拟测试:
CREATE TABLE `dummyids` (
`ids` int(11) NOT NULL AUTO_INCREMENT,
PRIMARY KEY (`ids`)
) ENGINE=InnoDB ;
insert into dummyids
select @i := @i + 1 as id
from (select true union all select true) t0
join (select true union all select true) t1
join (select true union all select true) t2
join (select true union all select true) t3
join (select true union all select true) t4
join (select true union all select true) t5
join (select true union all select true) t6
join (select true union all select true) t7
join (select true union all select true) t8
join (select true union all select true) t9
join (select true union all select true) t10
join (select true union all select true) t11
join (select true union all select true) t12
join (select true union all select true) t13
join (select true union all select true) t14
join (select true union all select true) t15
join (select true union all select true) t16
join (select true union all select true) t17
join (select true union all select true) t18
join (select true union all select true) t19
;
现在您可以检查 binlog 的大小和最后位置(它将是最新的 binlog,请更改您的路径和 binlog 名称)
# ls -lh /path/to/mysql/data/
# sudo mysqlbinlog mysql-bin.000012 | tail -n 100
记录运行 pt archive 后 binlog 的位置和大小进行比较
pt-archiver --source h=localhost,D=bar,t=dummyids,b=true --local --where "1 = 1" --limit=10000 --progress=50000 --txn-size=50000 --statistics --purge --bulk-delete
现在再次运行命令检查 binlog 的大小和最新位置,您应该注意到它们没有改变。
希望这可以帮助更多有相同问题的人。
选项在percona工具手册pt-archiver options中有解释