mysql归档文件命令_MySQL归档 pt-archiver 工具

# tar -zxvf percona-toolkit-2.2.17.tar.gz

# yum -y install perl perl-IO-Socket-SSL perl-DBD-MySQL perl-Time-HiRes perl-TermReadKey

# yum -y install perl-Digest-MD5

[root@linuxidc bin]# pwd

/data/soft/percona-toolkit-2.2.17/bin

pt-archiver--将表数据归档到另一个表或文件中

删除或归档一张大表,导出文件等,可以进行主从同步数据

[mysql@mysqlt1 bin]$ ./pt-archiver --help

Archive all rows from oltp_server to olap_server and to a file:

pt-archiver --source h=oltp_server,D=test,t=tbl --dest h=olap_server \

--file '/var/log/archive/%Y-%m-%d-%D.%t' \

--where "1=1" --limit 1000 --commit-each

Purge (delete) orphan rows from child table:

pt-archiver --source h=host,D=db,t=child --purge \

--where 'NOT EXISTS(SELECT * FROM parent WHERE col=child.col)'

参数说明:注意:至少需要指定--dest,--file,--purge 其中的一个

--ignore and --replace are mutually exclusive.

--txn-size and --commit-each are mutually exclusive.

--low-priority-insert and --delayed-insert are mutually exclusive.

--share-lock and --for-update are mutually exclusive.

--analyze and --optimize are mutually exclusive.

--no-ascend and --no-delete are mutually exclusive.

--source :指定要归档表的信息,兼容DSN选项

--source h=my_server,D=my_database,t=my_tbl

b:如果为true,则使用SQL_LOG_BIN禁用binlog--If true, disable binlog with SQL_LOG_BIN.

i:进行操作时,被指定使用的索引 --Index to use.

h=host,D=database,t=table,u=user,p=password,P=port,S=socket

A:Default character set

L:Explicitly enable LOAD DATA LOCAL INFILE.

m:Plugin module name

--source D=test,t=test1,m=My::Module1 --dest m=My::Module2,t=test2

--analyze:Run ANALYZE TABLE afterwards on --source and/or --dest ###--analyze=ds

--ascend-first:Ascend only first column of index ###升序索引优化,提供最左索引(多列主键)的升序。

--no-ascend:Do not use ascending index optimization.

--ask-pass:Prompt for a password when connecting to MySQL. ##连接mysql时输入密码

--buffer:缓冲区输出到--file并在提交时刷新,每次事务提交禁止刷写到磁盘,有操作系统决定刷写。该参数可以提高刷写到文件的性能,但崩溃可能会有数据丢失。

--commit-each:Commit each set of fetched and archived rows (disables --txn-size).##控制事务大小,每次提取、归档就提交。禁用--txn-size

--config:以逗号分隔的配置文件列表; 如果指定,则必须是命令行上的第一个选项

--delayed-insert:Add the DELAYED modifier to INSERT statements##在insert后面添加delayed,延迟写入

--dry-run: Print queries and exit without doing anything##打印查询并退出而不做任何事情

--file:File to archive to,

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值