常用GHOST模板

##================================================##
mysql_ip="127.0.0.1"
mysql_port=3358
ghost_user="root"
ghost_password="123.com"
ghost_database="test1"
ghost_table="tb002"
ghost_command="ADD C4 INT COMMENT '测试列'"./gh-ost \
--allow-on-master \
--max-load="Threads_running=256" \
--critical-load="Threads_running=512" \
--chunk-size=1000 \
--initially-drop-old-table \
--initially-drop-ghost-table \
--initially-drop-socket-file \
--timestamp-old-table \
--force-table-names="" \
--host="${mysql_ip}" \
--port="${mysql_port}" \
--user="${ghost_user}" \
--password="${ghost_password}" \
--database="${ghost_database}" \
--table="${ghost_table}" \
--alter="${ghost_command}" \
--verbose \
--execute 

GHOST常用参数:

1、如果希望直接读取主库BINLOG,需要指定allow-on-master参数
2、如果想避免上次操作失败产生的临时表导致新操作失败,建议使用initially-drop-ghost-table和initially-drop-socket-file参数
3、如果希望GHOST操作完成后删除源表,使用ok-to-drop-table参数
4、如果希望GHOST操作完成后保留源表,建议使用timestamp-old-table参数且不使用ok-to-drop-table参数
5、使用参数max-load来控制主库繁忙时暂停GHOST运行
6、使用参数critical-load来控制主库繁忙时终止GHOST运行
7、使用参数throttle-flag-file或throttle-query来控制GHOST暂停运行
8、使用参数panic-flag-file来控制GHOST停止运行
9、使用参数throttle-control-replicas来控制GHOST对从库复制延迟的影响

GHOST建议:

1、避免同一时间允许多个GHOST
2、请勿使用GHOST来创建唯一索引
3、建议从主库读取BINLOG,执行效率较高
4、建议设置critical-load和max-load时仅考虑Threads_running的值,使用Threads_connected容易因连接暴涨导致GHOST暂停或中止
5、在磁盘空间足够的条件下,使用timestamp-old-table来保存源表,一方面立即删除源表会造成IO压力,另一方面防止执行中出现BUG或误操作。

GHOST所有参数:

Usage of gh-ost:-allow-master-master当运行MM双主模式时需要显示设置。-allow-nullable-unique-key设置是否运行唯一键列中使用NULL值,使用ghost创建唯一索引,存在数据丢失风险,慎用!-allow-on-master当使用主节点的BINLOG来操作时,需要设置该值为ON。-alter string修改命令,不包含ALTER TABLE部分。-approve-renamed-columns ALTER当使用ghost进行修改列名操作,需要设置该值-ask-pass提升输入密码-assume-master-host string在双主或多主复制场景下,设置以哪个主节点的BINLOG为主。-assume-rbr假定使用基于ROW格式的复制模式-check-flagCheck if another flag exists/supported. This allows for cross-version scripting. Exits with 0 when all additional provided flags exist, nonzero otherwise. You must provide (dummy) values for flags that require a value. Example: gh-ost --check-flag --cut-over-lock-timeout-seconds --nice-ratio 0-chunk-size int设置每个批次复制数据的行数,取值范围100至100000,默认为1000-concurrent-rowcount(with --exact-rowcount), when true (default): count rows after row-copy begins, concurrently, and adjust row estimate later on; when false: first count rows, then start row copy (default true)设置对拷贝记录的计数方式。-conf string配置文件的路径-critical-load stringComma delimited status-name=threshold, same format as --max-load. When status exceeds threshold, app panics and quits设置GHOST运行的最大阈值,当超过该阈值后,终止GHOST运行。-critical-load-hibernate-seconds intWhen nonzero, critical-load does not panic and bail out; instead, gh-ost goes into hibernate for the specified duration. It will not read/write anything to from/to any server当该值不为0时,如果达到critical-load设置的阈值,会休眠指定时间,然后再次检查。-critical-load-interval-millis intWhen 0, migration immediately bails out upon meeting critical-load. When non-zero, a second check is done after given interval, and migration only bails out if 2nd check still meets critical load设置达到critical-load设置的阈值后的检查间隔。-cut-over stringchoose cut-over type (default|atomic, two-step) (default "atomic")设置切换源表和新表表名的操作方式,默认为自动-cut-over-lock-timeout-seconds intMax number of seconds to hold locks on tables while attempting to cut-over (retry attempted when lock exceeds timeout) (default 3)设置在cut-over时获取表锁的超时时间。-database stringdatabase name (mandatory)数据库名-debugdebug mode (very verbose)DEBUG模式-default-retries intDefault number of retries for various operations before panicking (default 60)默认重试次数-discard-foreign-keysDANGER! This flag will migrate a table that has foreign keys and will NOT create foreign keys on the ghost table, thus your altered table will have NO foreign keys. This is useful for intentional dropping of foreign keys设置是否丢弃外键,谨慎设置。-dml-batch-size intbatch size for DML events to apply in a single transaction (range 1-100) (default 10)-exact-rowcountactually count table rows as opposed to estimate them (results in more accurate progress estimation)-executeactually execute the alter & migrate the table. Default is noop: do some tests and exit设置运行GHOST操作,默认不执行,仅检查并退出。-force-named-cut-overWhen true, the 'unpostpone|cut-over' interactive command must name the migrated table-force-table-names stringtable name prefix to be used on the temporary tables设置临时表的前缀-heartbeat-interval-millis inthow frequently would gh-ost inject a heartbeat value (default 100)设置检查心跳时间间隔-helpDisplay usage-hooks-hint stringarbitrary message to be injected to hooks via GH_OST_HOOKS_HINT, for your convenience-hooks-path stringdirectory where hook files are found (default: empty, ie. hooks disabled). Hook files found on this path, and conforming to hook naming conventions will be executed-host stringMySQL hostname (preferably a replica, not the master) (default "127.0.0.1")-initially-drop-ghost-tableDrop a possibly existing Ghost table (remains from a previous run?) before beginning operation. Default is to panic and abort if such table exists设置是否删除已存在的ghost表,默认不删除,如果ghost表存在,则立即退出。-initially-drop-old-tableDrop a possibly existing OLD table (remains from a previous run?) before beginning operation. Default is to panic and abort if such table exists设置是否删除已存在的OLD表,默认不删除,如果存在,则立即退出。-initially-drop-socket-fileShould gh-ost forcibly delete an existing socket file. Be careful: this might drop the socket file of a running migration!设置是否删除已有的socket文件-master-password stringMySQL password on master, if different from that on replica. Requires --assume-master-host-master-user stringMySQL user on master, if different from that on replica. Requires --assume-master-host-max-lag-millis intreplication lag at which to throttle operation (default 1500)设置复制延迟阈值,如果复制延迟超过该阈值,则暂停GHOST操作。-max-load stringComma delimited status-name=threshold. e.g: 'Threads_running=100,Threads_connected=500'. When status exceeds threshold, app throttles writes设置GHOST允许阈值,如果超过该值,则暂停GHOST操作。-migrate-on-replicaHave the migration run on a replica, not on the master. This will do the full migration on the replica including cut-over (as opposed to --test-on-replica)-nice-ratio floatforce being 'nice', imply sleep time per chunk time; range: [0.0..100.0]. Example values: 0 is aggressive. 1: for every 1ms spent copying rows, sleep additional 1ms (effectively doubling runtime); 0.7: for every 10ms spend in a rowcopy chunk, spend 7ms sleeping immediately after设置显示GHOST进度的格式-ok-to-drop-tableShall the tool drop the old table at end of operation. DROPping tables can be a long locking operation, which is why I'm not doing it by default. I'm an online tool, yes?设置GHOST完成后是否删除OLD表,对于超大表,删除表操作会持续很长时间,并且造成性能问题,建议将表删除操作放到业务低峰期操作。-panic-flag-file stringwhen this file is created, gh-ost will immediately terminate, without cleanup当GHOST检查到该文件存在时,会立即退出而不做任何清理。-password stringMySQL password-port intMySQL port (preferably a replica, not the master) (default 3306)-postpone-cut-over-flag-file stringwhile this file exists, migration will postpone the final stage of swapping tables, and will keep on syncing the ghost table. Cut-over/swapping would be ready to perform the moment the file is deleted.当GHOST检查到该文件存在时,会将切换表名操作延期,直到该文件被删除。-quietquiet-replica-server-id uintserver id used by gh-ost process. Default: 99999 (default 99999)指定GHOST操作实例的server-id-replication-lag-query stringDeprecated. gh-ost uses an internal, subsecond resolution query已弃用。-serve-socket-file stringUnix socket file to serve on. Default: auto-determined and advertised upon startup指定实例使用的socket文件路径-serve-tcp-port intTCP port to serve on. Default: disabled-skip-foreign-key-checksset to 'true' when you know for certain there are no foreign keys on your table, and wish to skip the time it takes for gh-ost to verify that忽略外键检查-skip-renamed-columns ALTERin case your ALTER statement renames columns, gh-ost will note that and offer its interpretation of the rename. By default gh-ost does not proceed to execute. This flag tells gh-ost to skip the renamed columns, i.e. to treat what gh-ost thinks are renamed columns as unrelated columns. NOTE: you may lose column data忽略列名修改操作-stackadd stack trace upon error-switch-to-rbrlet this tool automatically switch binary log format to 'ROW' on the replica, if needed. The format will NOT be switched back. I'm too scared to do that, and wish to protect you if you happen to execute another migration while this one is running
        使用GHOST工具修改复制格式为ROW模式-table stringtable name (mandatory)修改表的表名-test-on-replicaHave the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust在复制节点上进行测试-test-on-replica-skip-replica-stopWhen --test-on-replica is enabled, do not issue commands stop replication (requires --test-on-replica)-throttle-additional-flag-file stringoperation pauses when this file exists; hint: keep default, use for throttling multiple gh-ost operations (default "/tmp/gh-ost.throttle")当该文件存在时,GHOST操作会暂停,默认值为/tmp/gh-ost.throttle-throttle-control-replicas stringList of replicas on which to check for lag; comma delimited. Example: myhost1.com:3306,myhost2.com,myhost3.com:3307设置要复制延迟的从库-throttle-flag-file stringoperation pauses when this file exists; hint: use a file that is specific to the table being altered当该文件存在时,GHOST操作会暂停-throttle-http stringwhen given, gh-ost checks given URL via HEAD request; any response code other than 200 (OK) causes throttling; make sure it has low latency response基于HTTP方式来决定GHOST暂停-throttle-query stringwhen given, issued (every second) to check if operation should throttle. Expecting to return zero for no-throttle, >0 for throttle. Query is issued on the migrated server. Make sure this query is lightweight基于QUERY方式来决定GHOST暂停-timestamp-old-tableUse a timestamp in old table name. This makes old table names unique and non conflicting cross migrationsGHOST操作完成后,将老表设置带有时间戳-tungstenexplicitly let gh-ost know that you are running on a tungsten-replication based topology (you are likely to also provide --assume-master-host)tungsten-replication是一种异构复制技术,如MySQL到MongoDB的复制-user stringMySQL user-verboseverbose设置该参数会导致GHOST输出更多详细信息-versionPrint version & exit

View Code

转载于:https://www.cnblogs.com/TeyGao/p/9116539.html

MySQL DDL--ghost执行模板和参数相关推荐

  1. mysql ddl脚本_MySQL在线DDL gh-ost使用总结

    背景: 作为一个DBA,大表的DDL的变更大部分都是使用Percona的pt-online-schema-change,本文说明下另一种工具gh-ost的使用:不依赖于触发器,是因为他是通过模拟从库, ...

  2. MySQL在线DDL gh-ost 使用说明

    https://my.oschina.net/u/3765527/blog/3037243 https://www.cnblogs.com/zhoujinyi/p/9187421.html delet ...

  3. mysql gh 划线_MySQL在线DDL gh-ost 使用说明

    3)使用说明:条件是操作的MySQL上需要的binlog模式是ROW.如果在一个从上测试也必须是ROW模式,还要开启log_slave_updates.根据上面的参数说明按照需求进行调整. 环境:主库 ...

  4. gh ost mysql_MySQL在线DDL gh-ost 使用说明

    3)使用说明:条件是操作的MySQL上需要的binlog模式是ROW.如果在一个从上测试也必须是ROW模式,还要开启log_slave_updates.根据上面的参数说明按照需求进行调整. 环境:主库 ...

  5. mysql ddl 进度_MySQL DDL详情揭露

    MySQL中DDL语句,即数据定义语言,用于创建.删除.修改.库或表结构,对数据库或表的结构操作.常见的有create,alter,drop等.这类语句通常会耗费很大代价,特别是对于大表做表结构变更. ...

  6. mysql 查询语句执行顺序_MySQL 查询语句执行过程

    MySQL 查询语句执行过程 Mysql分为server层和存储引擎两部分,或许可以再加一层连接层 连接层(器) Mysql使用的是典型的C/S架构.连接器通过典型的TCP握手完成连接. 需要注的是, ...

  7. mysql 5.6参数_初识 MySQL 5.6 新功能、参数

    摘要: MySQL5.6 针对 MySQL5.5 各个方面又提升了很多,特别在性能和一些新参数上面,现在看看大致提升了哪些方面(后续不定时更新). 一:性能.功能上的提升. ① 在线DDL即 onli ...

  8. 一文搞懂select语句在MySQL中的执行流程!

    MySQL作为互联网行业使用最多的关系型数据库之一,与其免费.开源的特性是密不可分的.然而,很多小伙伴工作了很多年,只知道使用MySQL进行CRUD操作,这也导致很多小伙伴工作多年后,想跳槽进入大厂, ...

  9. 8核32g mysql性能_MySQL性能优化之参数配置

    1.目的: 通过根据服务器目前状况,修改Mysql的系统参数,达到合理利用服务器现有资源,最大合理的提高MySQL性能. 2.服务器参数: 32G内存.4个CPU,每个CPU 8核. 3.MySQL目 ...

最新文章

  1. [转载]静态构造函数
  2. pytorch 学习: STGCN
  3. document.forms用法
  4. smartforms不输出0
  5. word 论文排版 —— 按指定格式章节的自动编号
  6. Ignite中的机器学习介绍
  7. Qt工作笔记-QGraphicsProxyWidget放自定义界面实现拖动
  8. OpenCV 4.x 中请别再用HAAR级联检测器检测人脸!有更好更准的方法
  9. 简述tcp协议三报文握手过程_TCP协议的3次握手与4次挥手过程详解
  10. cmd-ssh使用说明
  11. ob测试过程问题记录
  12. 多媒体网路multimedianetworkingCDN的全称是Content Delivery NetworkSIP(Session Initiation Protocol)是一个应用层的信
  13. 移动100m宽带慢的要死_为什么同样是100M的宽带, 中国移动就是比中国电信卡慢...
  14. 负载均衡(负载平衡)
  15. Linux内核详解与内核优化方案
  16. Windows 10 无法设置代理
  17. System.Net.WebException: 基础连接已经关闭: 未能为 SSL/TLS 安全通道建立信任关系。 ---> System.Security.Authentication.Authe
  18. 给中国学生的第二封信:从优秀到卓越
  19. 如何给MySQL 数据瘦身
  20. Python fitter包:拟合数据样本的分布

热门文章

  1. 嵌入式linux的驱动程序
  2. WEB框架研究笔记七(Spring2+struts2)
  3. 《菜菜的机器学习sklearn课堂》学习笔记 + 课件
  4. Linux下解压rar格式文件
  5. 同事用Excel花了半小时做甘特图,我用一工具只用10分钟
  6. 数据分析究竟有没有价值?看完这个案例你就明白了
  7. 利用BI搭建零售业数据信息平台
  8. 论各类BI工具的“大数据”特性!
  9. 数据分析学习笔记—python函数、异常与处理
  10. mysql 关联数组_在PHP / MySQL查询中创建关联数组