zoukankan      html  css  js  c++  java
  • 利用pt-online-schema-change为千万级别表在线添加索引报错

    添加索引

    ALTER TABLE `FUND_PAY_TRADE_RECORD`

         ADD INDEX `IDX_PAY_THIRD_ID` (`THIRD_ID`) USING BTREE ;

    统计表大小5.6G

    spacer.gifblob.png

    备份表:

    mysqldump -uroot -p --master-data=2 --single-transaction -t  xiaodai   FUND_PAY_TRADE_RECORD > TRADE_RECORD0621.sql

    用pt工具变更:

    pt-online-schema-change --user=root --password= --alter="ADD INDEX IDX_PAY_THIRD_ID (THIRD_ID) USING BTREE" D=xiaodai,t=FUND_PAY_TRADE_RECORD   --no-check-replication-filters  --execute

    报错

    blob.pngThreads_running=52 exceeds its critical threshold 50

    从提示上可以看出是Threads_running 超过了警告的阀值,查看官方文档,有两种方式来设置这个参数:

    --critical-load
    type: Array; default: Threads_running=50
    Examine SHOW GLOBAL STATUS after every chunk, 
    and abort if the load is too high. The option accepts a comma-separated list of MySQL status variables and thresholds. 
    An optional =MAX_VALUE (or :MAX_VALUE) can follow each variable. If not given, 
    the tool determines a threshold by examining the current value at startup and doubling it.
    See --max-load for further details. These options work similarly, 
    except that this option will abort the tool’s operation instead of pausing it,
     and the default value is computed differently if you specify no threshold. 
     The reason for this option is as a safety check in case the triggers on the
     original table add so much load to the server that it causes downtime. 
     There is probably no single value of Threads_running that is wrong for 
     every server, but a default of 50 seems likely to be unacceptably high
     for most servers, indicating that the operation should be canceled immediately.

    大致的意思如下:
    每次chunk操作前后,会根据show global status统计指定的状态量的变化,默认是统计Thread_running。
    目的是为了安全,防止原始表上的触发器引起负载过高。这也是为了防止在线DDL对线上的影响。
    超过设置的阀值,就会终止操作,在线DDL就会中断。提示的异常如上报错信息。


    --max-load
    type: Array; default: Threads_running=25
    Examine SHOW GLOBAL STATUS after every chunk, and pause if any status variables are higher than their thresholds. 
    The option accepts a comma-separated list of MySQL status variables. An optional =MAX_VALUE (or :MAX_VALUE) can 
    follow each variable. If not given, the tool determines a threshold by examining the current value and increasing it by 20%.

    For example, if you want the tool to pause when Threads_connected gets too high, you can specify “Threads_connected”,
     and the tool will check the current value when it starts working and add 20% to that value. If the current value is 100, 
     then the tool will pause when Threads_connected exceeds 120, and resume working when it is below 120 again. If you want to
     specify an explicit threshold, such as 110, you can use either “Threads_connected:110” or “Threads_connected=110”.

    The purpose of this option is to prevent the tool from adding too much load to the server. If the data-copy queries are 
    intrusive, or if they cause lock waits, then other queries on the server will tend to block and queue. This will typically 
    cause Threads_running to increase, and the tool can detect that by running SHOW GLOBAL STATUS immediately after each query finishes. 
    If you specify a threshold for this variable, then you can instruct the tool to wait until queries are running normally again. This will 
    not prevent queueing, however; it will only give the server a chance to recover from the queueing. If you notice queueing, it is best to decrease the chunk time.

    --max-load 选项定义一个阀值,在每次chunk操作后,查看show global status状态值是否高于指定的阀值。该参数接受一个mysql status状态变量以及一个阀值,
    如果没有给定阀值,则定义一个阀值为为高于当前值的20%。
    注意这个参数不会像--critical-load终止操作,而只是暂停操作。当status值低于阀值时,则继续往下操作。
    是暂停还是终止操作这是--max-load和--critical-load的差别。

    参数值为列表形式,可以指定show global status出现的状态值。比如,Thread_connect 等等。
    格式如下:--critical-load="Threads_running=200"  或者--critical-load="Threads_running:200"。




  • 相关阅读:
    windows下使用curl命令,以及常用curl命令
    使用 C# 下载文件的十八般武艺
    初闻不知曲中意,再听已是曲中人
    从线性回归走进机器学习
    自定义Vue&Element组件,实现用户选择和显示
    ARP协议原理——地址解析协议, 用于实现从 IP 地址到 MAC 地址的映射,即询问目标IP对应的MAC地址,ARP整个完整交互过程仅需要两个包,一问一答即可搞定
    SSH加密隧道流量攻击与检测技术——这玩意和思科加密流量检测没有本质区别啊,可借鉴CNN图像
    bt2——基于telegram的C2
    通过gmail进行C2控制——看了下源码,本质上和dropbox c2架构一样,都是去轮训邮件,将c2攻击的东西以邮件形式发送,结果也发到邮箱里
    DropboxC2 工具原理总结——就是通过dropbox文件来间接做c2控制和交互。
  • 原文地址:https://www.cnblogs.com/DBABlog/p/12926957.html
Copyright © 2011-2022 走看看