mysql 在线修改表结构工具 gh-ost
gh-ost使用测试:
gh-ost -host='192.168.65.136' -user=root -password='' -database='haha' -chunk-size=100000 -allow-on-master -execute -initially-drop-ghost-table -exact-rowcount --initially-drop-old-table -alter='modify AreaID varchar(10)' -table='t_policyarea'
- -allow-master-master
- 显式的允许在主主集群中运行
- -allow-on-master
- 允许直接运行在主机上,如果没有集群使用这个选项,推荐用在从机上
- -alter string
- (必须参数)alter 语句 例如 add column_name type , change column_name column_name type, modify column_name type; 等等 无需加alter table 字符串
- -assume-rbr
- 设置 'true' 当你确定使用 'ROW' binlog_format.
- -chunk-size int
- 每一次迭代处理的行数,默认是1000 ,允许范围(-)
- -concurrent-rowcount
- (with --exact-rowcount), when true: count rows after row-copy begins, concurrently, and adjust row estimate later on; defaults false: first count rows, then start row copy
- -conf string
- 配置文件
- -critical-load --max-load
- 最大负载,设置一个阈值,超过这个阈值应用程序会自动退出, --max-load 同意义
- -database string
- 数据库名称 必须字段
- -debug
- debug模式
- -default-retries int
- 在各种各样的意外之前的重试次数 (default )
- -exact-rowcount
- copy前对row的数目进行精确的估计,以方便对执行进度精确判断
- 注释:这个没什么太大必要,精确统计对大表来说也是很耗时的
- -execute
- 实际执行变更,如果不加这个选项默认都是测试然后退出,实际上并没有改变原表结构
- -host string
- mysql主机名称,最好是从机而不是主机 (default "127.0.0.1")
- -initially-drop-ghost-table
- 如果运行了多次对同一个表修改,就会存在ghost表,使用这个选项来删除存在的ghost表
- -initially-drop-old-table
- 效果同上,默认是中断停止
- -initially-drop-socket-file
- 强行删除现有的socket文件。小心:这可能会删除运行迁移的套接字文件!
- -max-load string
- 命令格式 e.g: 'Threads_running=100,Threads_connected=500'.当服务器达到这个负载那么就会减少修改使用资源
- -migrate-on-replica
- Have 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 float
- force being 'nice', imply sleep time per chunk time; range: [0.0..100.0]. Example values: is aggressive. : 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
- -ok-to-drop-table
- 结束后删除旧表,由于删除会有一个很长时间的锁,在线操作不建议,默认是false
- -panic-flag-file string
- when this file is created, gh-ost will immediately terminate, without cleanup
- -password string
- MYSQL服务器密码
- -port int
- mysql服务器端口,均建议在从机上操作
- -stack
- 在错误时添加堆栈跟踪
- -switch-to-rbr
- let 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
- -table string
- 必须参数,表名称
- -throttle-query string
- 每秒检测一次,确保是轻量级的查询,不对服务器产生大的影响
- -tungsten
- explicitly let gh-ost know that you are running on a tungsten-replication based topology (you are likely to also provide --assume-master-host)
- -user string
- mysql用户
- -verbose
- 冗余输出详细信息
- -version
- 版本号
- -test-on-replica
- Have 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-stop
- When --test-on-replica is enabled, do not issue commands stop replication (requires --test-on-replica)
- -throttle-additional-flag-file string
- operation pauses when this file exists; hint: keep default, use for throttling multiple gh-ost operations (default "/tmp/gh-ost.throttle")
- -throttle-control-replicas string
- List of replicas on which to check for lag; comma delimited. Example: myhost1.com:,myhost2.com,myhost3.com:
- -throttle-flag-file string
- operation pauses when this file exists; hint: use a file that is specific to the table being altered
- -postpone-cut-over-flag-file string
- while 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.
- -quiet
- quiet
- -replication-lag-query string
- Query that detects replication lag in seconds. Result can be a floating point (by default gh-ost issues SHOW SLAVE STATUS and reads Seconds_behind_master). If you're using pt-heartbeat, query would be something like: SELECT ROUND(UNIX_TIMESTAMP() - MAX(UNIX_TIMESTAMP(ts))) AS delay FROM my_schema.heartbeat
- -serve-socket-file string
- Unix socket file to serve on. Default: auto-determined and advertised upon startup
- -serve-tcp-port int
- TCP port to serve on. Default: disabled
- -skip-renamed-columns ALTER
- in 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
- -approve-renamed-columns ALTER
- in 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 approves that gh-ost's interpretation si correct
- -assume-master-host string
- (optional) explicitly tell gh-ost the identity of the master. Format: some.host.com[:port] This is useful in master-master setups where you wish to pick an explicit master, or in a tungsten-replicator where gh-ost is unabel to determine the master
- -cut-over string
- choose cut-over type (default|atomic, two-step) (default "atomic")
- -cut-over-lock-timeout-seconds int
- Max number of seconds to hold locks on tables while attempting to cut-over (retry attempted when lock exceeds timeout) (default )
- -heartbeat-interval-millis int
- how frequently would gh-ost inject a heartbeat value (default )
- -hooks-hint string
- arbitrary message to be injected to hooks via GH_OST_HOOKS_HINT, for your convenience
- -hooks-path string
- directory 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
- -max-lag-millis int
- replication lag at which to throttle operation (default )
mysql 在线修改表结构工具 gh-ost的更多相关文章
- mysql在线修改表结构大数据表的风险与解决办法归纳
整理这篇文章的缘由: 互联网应用会频繁加功能,修改需求.那么表结构也会经常修改,加字段,加索引.在线直接在生产环境的表中修改表结构,对用户使用网站是有影响. 以前我一直为这个问题头痛.当然那个时候不需 ...
- 数据库遇到的问题——mysql在线修改表结构大数据表的风险与解决办法归纳
互联网应用会频繁加功能,修改需求.那么表结构也会经常修改,加字段,加索引.在线直接在生产环境的表中修改表结构,对用户使用网站是有影响. 以前我一直为这个问题头痛.当然那个时候不需要我来考虑,虽然我们没 ...
- (转)pt-online-schema-change在线修改表结构
原文:http://www.ywnds.com/?p=4442 一.背景 MySQL大字段的DDL操作:加减字段.索引.修改字段属性等,在5.1之前都是非常耗时耗力的,特别是会对MySQL服务产生影响 ...
- pt-online-schema-change在线修改表结构
工具简介 pt-osc模仿MySQL内部的改表方式进行改表,但整个改表过程是通过对原始表的拷贝来完成的,即在改表过程中原始表不会被锁定,并不影响对该表的读写操作.首先,osc创建与原始表相同的不包含数 ...
- MYSQL的修改表结构SQL语句
更多java学习资料>>> 1.背景 使用sql语句对表结构进行修改 2.案例演示 案例:表结构 CREATE TABLE `login_user` ( `id` ) NOT NUL ...
- mysql在线改表结构 pt-online-schema-change
https://www.percona.com/doc/percona-toolkit/2.1/pt-online-schema-change.html 不锁表更改数据库表结构 pt-online-s ...
- [转载]github在线更改mysql表结构工具gh-ost
GitHub正式宣布以开源的方式发布gh-ost:GitHub的MySQL无触发器在线更改表定义工具! gh-ost是GitHub最近几个月开发出来的,目的是解决一个经常碰到的问题:不断变化的产品需求 ...
- MySQL OSC(在线更改表结构)原理
1 OSC介绍 在我们的数据库操作中,更改表结构是一个常见的操作,而当我们的表数据量非常大时,我们更改表结构的时间是非 常的长,并且在跟改期间,会生成一个互斥锁,阻塞对整个表的所有操作,这样,对于我们 ...
- mysql 表的增删改查 修改表结构
四.修改表结构 语法: . 修改表名 ALTER TABLE 表名 RENAME 新表名; . 增加字段 ALTER TABLE 表名 ADD 字段名 数据类型 [完整性约束条件…], ADD 字段名 ...
随机推荐
- P151、面试题27:二叉搜索树与双向链表
题目:输入一棵二叉搜索树,将该二叉搜索树转换成一个排序的双向链表.要求不能创建任何新的结点,只能调整树中结点指针的指向.(本质是中序遍历)二叉树结点的定义如下:struct BinaryTreeNod ...
- poj 1125 Stockbroker Grapevine(最短路 简单 floyd)
题目:http://poj.org/problem?id=1125 题意:给出一个社交网络,每个人有几个别人可以传播谣言,传播谣言需要时间.问要使得谣言传播的最快,应该从那个人开始传播谣言以及使得所有 ...
- vijosP1026毒药?解药?
hash. 怎么感觉叫状态压缩bfs比较合适呢? #include<cstdio> #include<algorithm> #include<cstring> us ...
- 20款最优秀的JavaScript编辑器
毫无疑问SublimeText,Notepad++,webstorm等,是市面上最主导的编辑器,但当然也有一些更多的JavaScript编辑器提供众多的特性和功能,方便和轻松自由的编码.本文整理了20 ...
- acdream 小晴天老师系列——苹果大丰收(DP)
小晴天老师系列——苹果大丰收 Problem Description 小晴天的后花园有好多好多的苹果树,某天,苹果大丰收~小晴天总共摘了M个苹果,我们假设苹果之间是不可分辨的. 为了保存苹果,小晴天买 ...
- LeetCode Binary Tree Level Order Traversal (按层收集元素)
题意:按层,将元素收集在一个二维数组中. 思路:广搜应该是普遍的方法了.还能避免栈溢出,多好用.搭配deque,因为要经常删除. /** * Definition for a binary tree ...
- Zen Coding support in WebStorm/PhpStorm
With the last WebStorm/PhpStorm EAP you can edit HTML and CSS code really fast usingZen Coding featu ...
- 【原】cocos2d-x开发笔记:多点触控
在项目开发中,我们做的大地图,一个手指头按下滑动可以拖动大地图,两个手指头按下张开或者闭合,可以放大和缩小地图 在实现这个功能的时候,需要使用到cocos2d-x的多点触控功能. 多点触控事件,并不是 ...
- 使用SharePoint 2010的母版页
转:http://tanyanbo2.blog.163.com/blog/static/97339159201111591458902/ SharePoint 2010母版页所用的还是ASP.NET ...
- 分布式数据库中间件TDDL、Amoeba、Cobar、MyCAT架构比较分
比较了业界流行的MySQL分布式数据库中间件,关于每个产品的介绍,网上的资料比较多,本文只是对几款产品的架构进行比较,从中可以看出中间件发展和演进路线 框架比较 TDDL Amoeba Cobar M ...