zoukankan      html  css  js  c++  java
  • 使用pt-online-schema-change pt-osc 更改mysql大表

    安装

    centos

    -- 安装 yum 仓库
    yum install https://repo.percona.com/yum/percona-release-latest.noarch.rpm
    -- 安装 percona toolkit
    yum install percona-toolkit -y

    ubuntu

    apt-get install percona-toolkit -y

    语法

    pt-online-schema-change [OPTIONS] DSN

    其中 DSN 是指 Data Source Name,是连接数据库的变量信息。格式为key=value。

    DSN 的 key 有:

    • A:默认字符集
    • D:数据库
    • F:只从给定的文件中读取默认值
    • P:端口号
    • S:socket 文件
    • h:主机 IP 或主机名
    • p:密码
    • t:要更新的表
    • u:用户名

    运行前测试

    # pt-online-schema-change --print --statistics 
        --progress time,30 --preserve-triggers --user=ptosc 
        --password=ptosc --alter 'modify c varchar(200) not null default ""' 
        h=127.0.1.1,P=3306,D=testdb,t=sbtest1 
        --pause-file=/tmp/aa.txt --max-load=threads_running=100,threads_connected=200 
        --critical-load=threads_running=1000  --chunk-size=1000 
        --alter-foreign-keys-method auto --dry-run
    • --print:打印工具执行的SQL语句。
    • --statistics:打印统计信息。
    • --pause-file:当指定的文件存在时,终止执行。
    • --max-load:超过指定负载时,暂定执行
    • --critical-load:超过指定负载时,终止执行
    • --chunck-size:指定每次复制的行数
    • --alter-foreign-keys-method:指定外键更新方式
    • --progress:copy进度打印的频率

    执行

    --dry-run 修改为 --execute

    # pt-online-schema-change --print --statistics 
        --progress time,30 --preserve-triggers --user=ptosc 
        --password=ptosc --alter 'modify c varchar(200) not null default ""' 
        h=127.0.1.1,P=3306,D=testdb,t=sbtest1 
        --pause-file=/tmp/aa.txt --max-load=threads_running=100,threads_connected=200 
        --critical-load=threads_running=1000  --chunk-size=1000 
        --alter-foreign-keys-method auto  --execute
  • 相关阅读:
    C++builder 系统时间
    oracle 备份某张表
    Pascal 中对于常量的初始化
    Delphi 正则表达式
    Lazarus 中的字符串 String,AnsiString,UnicodeString,UTF8String,WideString
    Lazarus 指针,数组,字符串
    准备使用PostgreSQL
    Freepascal 中的泛型使用
    如何生成密钥文件Snk
    挖掘经典:几乎被人遗忘的HTML七种用法
  • 原文地址:https://www.cnblogs.com/timseng/p/14924032.html
Copyright © 2011-2022 走看看