pt-archiver
2017-08-10 12:37
134 查看
pt-archiver 是 pt-toolkit 中的一个工具,用于归档,传送数据至下线数据库,或者其他数据库
Examples
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)'
示例:
root@python-develpment:~# pt-archiver --source h=192.168.134.186,P=3306,u=pt-archive,p=123456,D=pcik_log_dep,t=t_user_login --where='logintime<"2017-05-05"' --file='a.txt' --statistics --charset=utf8 --no-delete --progress=500 --limit=2000 --optimize=ture --txn-size=20000
--source 源数据库,后面的参数用‘,’隔开
--where 过滤数据
-statistics 执行完成后显示统计信息
Started at 2017-08-10T12:14:36, ended at 2017-08-10T12:14:39 Source: A=utf8,D=pcik_log_dep,P=3306,h=192.168.134.186,p=...,t=t_user_login,u=pt- archive SELECT 50281 INSERT 0 DELETE 0 Action Count Time Pct select 27 0.8560 24.15 print_file 50281 0.3907 11.02 commit 3 0.0014 0.04 other 0 2.2968 64.79--file 归档到本地(文件格式和select into outfile 一样,导入时使用load data infile 默认即可)
--no-delete 默认是会删除源数据库数据的,加上此参数后将不删除源数据库数据,
--progress 每完成多少行数据就会给出提示
TIME ELAPSED COUNT
2017-08-10T12:14:36 0 0
2017-08-10T12:14:36 0 500
2017-08-10T12:14:36 0 1000
2017-08-10T12:14:36 0 1500
2017-08-10T12:14:36 0 2000
--limit 指定select 每次查询的数量(改变此值可优化速度)
--txn-size=20000 当 --file时 不能用 --commit-each ,可设置此值加快速度
归档并传送至其他服务器
pt-archiver --source h=192.168.134.186,P=3306,u=pt-archive,p=123456,D=pcik_log_dep,t=t_user_login --where='logintime<"2017-05-05"' --file='a.txt' --statistics --charset=utf8 --no-delete --progress=500 --limit=20000 --optimize=ture --txn-size=20000 --dest h=192.168.134.186,P=3308,u=root,p=123456 --bulk-insert
--bulk-insert 加快dest 服务器插入数据速度
Examples
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)'
示例:
root@python-develpment:~# pt-archiver --source h=192.168.134.186,P=3306,u=pt-archive,p=123456,D=pcik_log_dep,t=t_user_login --where='logintime<"2017-05-05"' --file='a.txt' --statistics --charset=utf8 --no-delete --progress=500 --limit=2000 --optimize=ture --txn-size=20000
--source 源数据库,后面的参数用‘,’隔开
--where 过滤数据
-statistics 执行完成后显示统计信息
Started at 2017-08-10T12:14:36, ended at 2017-08-10T12:14:39 Source: A=utf8,D=pcik_log_dep,P=3306,h=192.168.134.186,p=...,t=t_user_login,u=pt- archive SELECT 50281 INSERT 0 DELETE 0 Action Count Time Pct select 27 0.8560 24.15 print_file 50281 0.3907 11.02 commit 3 0.0014 0.04 other 0 2.2968 64.79--file 归档到本地(文件格式和select into outfile 一样,导入时使用load data infile 默认即可)
--no-delete 默认是会删除源数据库数据的,加上此参数后将不删除源数据库数据,
--progress 每完成多少行数据就会给出提示
TIME ELAPSED COUNT
2017-08-10T12:14:36 0 0
2017-08-10T12:14:36 0 500
2017-08-10T12:14:36 0 1000
2017-08-10T12:14:36 0 1500
2017-08-10T12:14:36 0 2000
--limit 指定select 每次查询的数量(改变此值可优化速度)
--txn-size=20000 当 --file时 不能用 --commit-each ,可设置此值加快速度
归档并传送至其他服务器
pt-archiver --source h=192.168.134.186,P=3306,u=pt-archive,p=123456,D=pcik_log_dep,t=t_user_login --where='logintime<"2017-05-05"' --file='a.txt' --statistics --charset=utf8 --no-delete --progress=500 --limit=20000 --optimize=ture --txn-size=20000 --dest h=192.168.134.186,P=3308,u=root,p=123456 --bulk-insert
--bulk-insert 加快dest 服务器插入数据速度
相关文章推荐
- pt-archiver(数据导入导出工具)
- dba+工具:pt-archiver重构版,轻松搞定大表数据归档 - 大数据
- 如何利用pt-archiver工具归档和清理数据
- pt-archiver Bug不会迁移max(id)那条数据的解决方法
- percona-toolkit工具包pt-archiver的简单使用
- pt-archiver 数据归档bug
- MySQL数据归档实战-Python和pt-archiver的强强结合
- Want to archive tables? Use Percona Toolkit’s pt-archiver--转载
- pt-archiver使用
- 优雅地使用pt-archiver进行数据归档
- MySQL数据归档实战-Python和pt-archiver的强强结合
- percona-toolkit 之 【pt-archiver】
- 【percona-toolkit手册】pt-archiver数据归档
- pt-archiver
- pt-archiver归档工具的使用详解
- dba+工具:pt-archiver重构版,轻松搞定大表数据归档 - 大数据
- pt-archiver 数据删除、迁移工具使用
- 整理的最完整的OFPT_STATS_REQUEST && REPLY消息-部分转载(含有1.0与1.3的对比)
- pt-online-change-ddl(在线ddl)
- py-faster-rcnn详解(5)——stage1_rpn_train.pt说明