• ADADADADAD

    pt-archiver[ mysql数据库 ]

    mysql数据库 时间:2024-12-24 19:13:22

    作者:文/会员上传

    简介:

    pt-archiver 是 pt-toolkit 中的一个工具,用于归档,传送数据至下线数据库,或者其他数据库
    ExamplesArchive all rows from oltp_server to olap_server and to a file:pt-archi

    以下为本文的正文内容,内容仅供参考!本站为公益性网站,复制本文以及下载DOC文档全部免费。

    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 CountTimePct

    select 27 0.8560 24.15

    print_file 50281 0.3907 11.02

    commit 3 0.00140.04

    other0 2.2968 64.79

    --file 归档到本地(文件格式和select into outfile 一样,导入时使用load data infile 默认即可)

    --no-delete 默认是会删除源数据库数据的,加上此参数后将不删除源数据库数据,

    --progress 每完成多少行数据就会给出提示

    TIMEELAPSEDCOUNT

    2017-08-10T12:14:3600

    2017-08-10T12:14:360 500

    2017-08-10T12:14:3601000

    2017-08-10T12:14:3601500

    2017-08-10T12:14:3602000

    --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.docx

    将本文的Word文档下载到电脑

    推荐度:

    下载
    热门标签: toolkitptarchiver