mysql - 如何在 pt-archiver 中禁用 binlog

标签 mysql database archive percona mysql-5.7

我正在使用 percona 的 pt-archive 实用程序归档大表。但它填满了我的二进制日志。

是否有任何选项可以在从此实用程序归档期间禁用二进制日志记录。

我已阅读其文档,我们可以在 --analyze 选项中执行某些操作,但尚未明确如何定义它。因为此选项还会优化/分析我不想要的表。

您能提供任何可行的示例吗?

最佳答案

简而言之,您需要添加选项 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

记录binlog的位置和大小,以便运行pt archive后进行比较

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

现在运行命令再次检查二进制日志的大小和最新位置,您应该注意到它们没有改变。

希望这可以帮助更多遇到同样问题的人。

percona 工具手册 pt-archiver options 上解释了这些选项

关于mysql - 如何在 pt-archiver 中禁用 binlog,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/46462233/

相关文章:

sql - 如何在大型数据库中找到从一个表到另一个表的连接路径

c - 重新排列文件的内容

php - 如何使用 php 和 MySQL 将表的整个数组数据插入到新表中

mysql - 如何通过另一个表的 id 从另一个表获取值?

database - Postgres维护的正确顺序

database - 代码优先迁移——真的有必要吗?

Java项目归档文件提交?

php - 文件生成器 PHP

php - 使用 Doctrine 仅从 ManyToMany 获取 ID 列表

php - SQLSTATE[23000] : Integrity constraint violation: 1452 Cannot add or update a child row: a foreign key constraint fails in Laravel 5