gh-ost README

The project's README from github.com/github/gh-ost. As one markdown file: README.md.

gh-ost

ci replica-tests downloads release

GitHub's online schema migration for MySQL

gh-ost is a triggerless online schema migration solution for MySQL. It is testable and provides pausability, dynamic control/reconfiguration, auditing, and many operational perks.

gh-ost produces a light workload on the master throughout the migration, decoupled from the existing workload on the migrated table.

It has been designed based on years of experience with existing solutions, and changes the paradigm of table migrations.

How?

All existing online-schema-change tools operate in similar manner: they create a ghost table in the likeness of your original table, migrate that table while empty, slowly and incrementally copy data from your original table to the ghost table, meanwhile propagating ongoing changes (any INSERT, DELETE, UPDATE applied to your table) to the ghost table. Finally, at the right time, they replace your original table with the ghost table.

gh-ost uses the same pattern. However it differs from all existing tools by not using triggers. We have recognized the triggers to be the source of many limitations and risks.

Instead, gh-ost uses the binary log stream to capture table changes, and asynchronously applies them onto the ghost table. gh-ost takes upon itself some tasks that other tools leave for the database to perform. As result, gh-ost has greater control over the migration process; can truly suspend it; can truly decouple the migration's write load from the master's workload.

In addition, it offers many operational perks that make it safer, trustworthy and fun to use.

gh-ost general flow

Highlights

Please refer to the docs for more information. No, really, read the docs.

Usage

The cheatsheet has it all. You may be interested in invoking gh-ost in various modes:

Our tips:

More tips:

Also see:

What's in a name?

Originally this was named gh-osc: GitHub Online Schema Change, in the likes of Facebook online schema change and pt-online-schema-change.

But then a rare genetic mutation happened, and the c transformed into t. And that sent us down the path of trying to figure out a new acronym. gh-ost (pronounce: Ghost), stands for GitHub's Online Schema Transmogrifier/Translator/Transformer/Transfigurator

License

gh-ost is licensed under the MIT license

gh-ost uses 3rd party libraries, each with their own license. These are found here.

Community

gh-ost is released at a stable state, but with mileage to go. We are open to pull requests. Please first discuss your intentions via Issues.

We develop gh-ost at GitHub and for the community. We may have different priorities than others. From time to time we may suggest a contribution that is not on our immediate roadmap but which may appeal to others.

Please see Coding gh-ost for a guide to getting started developing with gh-ost.

Download/binaries/source

gh-ost is now GA and stable.

gh-ost is available in binary format for Linux and Mac OS/X

Download latest release here

gh-ost is a Go project; it is built with Go 1.15 and above. To build on your own, use either:

Generally speaking, master branch is stable, but only releases are to be used in production.

Authors

gh-ost is designed, authored, reviewed and tested by the database infrastructure team at GitHub:

gh-ost (github/gh-ost)

Searching Database…

13.6K ·GitHub
这是什么?gh-ost 是 GitHub 开源的 MySQL 在线表结构变更(online schema migration)工具:它把数据复制到一张影子表(ghost table)来完成对在线表的修改,让主库上的负载保持轻量,并与正常业务流量解耦。
它和其他在线改表工具有什么不同?它把你的表复制成一张影子表,最后再交换两张表,但整个过程不使用触发器(triggerless):它通过读取二进制日志(binary log)流并异步应用变更,因此能真正暂停操作,让自己的负载与主库解耦。
怎么获取它并执行一次迁移?下载适用于 Linux 或 macOS 的预编译二进制文件,或者安装 Go 1.15+ 后用 script/build 从源码构建。速查表(cheatsheet)涵盖了所有模式;推荐流程是先用 noop 做一次测试,再用 --execute 执行真正的迁移。
我的数据库环境需要满足什么条件才能用它?需要一个能通过二进制日志(binary log)跟踪其变更的 MySQL 环境。它倾向于通过从库(replica)来执行迁移(它会自动识别所涉及的服务器),并且针对 AWS RDS 和 Azure Database for MySQL 有官方指南。
把它指向我的生产主库之前,有什么要注意的坑?如果你的主库使用的是基于语句的复制(Statement Based Replication),就必须使用基于从库的模式。另外,只有打了标签的正式版本才适用于生产环境——master 分支总体上是稳定的,但不要用于生产。
它在大规模生产数据库上经过验证吗?是的——它已经 GA 且稳定,由 GitHub 的数据库基础设施团队打造,该团队持续在从库上迁移自己的整批生产表,并用校验和(checksum)比对结果来验证正确性。
迁移运行期间我能控制哪些东西?很多:限流(throttling)会真正停止主库上的所有写入;你可以在运行中交互式地重新配置;可以通过 unix socket 或 TCP 查询状态;可以推迟最终的表交换,等你方便时再执行;还能通过外部钩子(hooks)与你的环境联动。
能不能不碰生产数据就先测试一下?可以:--test-on-replica 会在从库上运行完全相同的迁移流程,不替换原始表,最后留下两张表供你对比和校验。对于主库迁移,先用 noop 试运行一次,再用 --execute 执行真正的迁移。
为什么叫 gh-ost?它读作 Ghost,是 GitHub's Online Schema Transmogrifier/Translator/Transformer/Transfigurator 的缩写。它最初叫 gh-osc(Online Schema Change),与 Facebook 的 OSC 和 pt-online-schema-change 属于同类工具,直到一次“罕见的基因突变”把 c 变成了 t。
What are similar projects?flyway, goose, usql, migrate, bytebase, chartdb, miller, dolt
Creator
github
Size
18.5 MB
Stars
13.6K
Age
10y
Commits · 90 Days