gh-ost/README.md

112 lines
7.4 KiB
Markdown
Raw Normal View History

2016-05-23 10:33:28 +00:00
# gh-ost
2016-05-25 10:31:33 +00:00
2017-04-02 07:46:36 +00:00
[![build status](https://travis-ci.org/github/gh-ost.svg)](https://travis-ci.org/github/gh-ost) [![downloads](https://img.shields.io/github/downloads/github/gh-ost/total.svg)](https://github.com/github/gh-ost/releases) [![release](https://img.shields.io/github/release/github/gh-ost.svg)](https://github.com/github/gh-ost/releases)
2016-07-22 15:24:39 +00:00
#### GitHub's online schema migration for MySQL <img src="doc/images/gh-ost-logo-light-160.png" align="right">
2016-05-23 10:32:43 +00:00
2016-07-24 15:10:42 +00:00
`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.
2016-05-25 10:31:33 +00:00
2016-07-16 13:14:25 +00:00
`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.
2016-07-16 11:19:06 +00:00
2016-07-19 23:32:40 +00:00
2016-07-16 11:19:06 +00:00
2016-05-25 10:31:33 +00:00
## How?
2016-07-16 13:14:25 +00:00
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](doc/why-triggerless.md).
Instead, `gh-ost` [uses the binary log stream](doc/triggerless-design.md) 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.
2016-07-16 13:30:22 +00:00
In addition, it offers many [operational perks](doc/perks.md) that make it safer, trustworthy and fun to use.
2016-07-16 13:14:25 +00:00
2016-07-16 11:36:32 +00:00
![gh-ost general flow](doc/images/gh-ost-general-flow.png)
2016-07-16 13:30:22 +00:00
## Highlights
2016-07-16 13:14:25 +00:00
2016-07-16 13:30:22 +00:00
- Build your trust in `gh-ost` by testing it on replicas. `gh-ost` will issue same flow as it would have on the master, to migrate a table on a replica, without actually replacing the original table, leaving the replica with two tables you can then compare and satisfy yourself that the tool operates correctly. This is how we continuously test `gh-ost` in production.
- True pause: when `gh-ost` [throttles](doc/throttle.md), it truly ceases writes on master: no row copies and no ongoing events processing. By throttling, you return your master to its original workload
- Dynamic control: you can [interactively](doc/interactive-commands.md) reconfigure `gh-ost`, even as migration still runs. You may forcibly initiate throttling.
- Auditing: you may query `gh-ost` for status. `gh-ost` listens on unix socket or TCP.
- Control over cut-over phase: `gh-ost` can be instructed to postpone what is probably the most critical step: the swap of tables, until such time that you're comfortably available. No need to worry about ETA being outside office hours.
2016-08-25 12:46:43 +00:00
- External [hooks](doc/hooks.md) can couple `gh-ost` with your particular environment.
2016-05-23 10:32:43 +00:00
2016-07-31 14:07:59 +00:00
Please refer to the [docs](doc) for more information. No, really, read the [docs](doc).
2016-06-06 11:01:47 +00:00
## Usage
2016-07-16 13:30:22 +00:00
The [cheatsheet](doc/cheatsheet.md) has it all. You may be interested in invoking `gh-ost` in various modes:
2016-07-16 13:30:22 +00:00
- a _noop_ migration (merely testing that the migration is valid and good to go)
- a real migration, utilizing a replica (the migration runs on the master; `gh-ost` figures out identities of servers involved. Required mode if your master uses Statement Based Replication)
- a real migration, run directly on the master (but `gh-ost` prefers the former)
- a real migration on a replica (master untouched)
- a test migration on a replica, the way for you to build trust with `gh-ost`'s operation.
2016-07-16 13:30:22 +00:00
Our tips:
2016-07-22 15:26:33 +00:00
- [Testing above all](doc/testing-on-replica.md), try out `--test-on-replica` first few times. Better yet, make it continuous. We have multiple replicas where we iterate our entire fleet of production tables, migrating them one by one, checksumming the results, verifying migration is good.
2016-07-16 13:30:22 +00:00
- For each master migration, first issue a _noop_
- Then issue the real thing via `--execute`.
2016-07-16 13:30:22 +00:00
More tips:
2016-06-06 11:01:47 +00:00
2016-07-16 13:30:22 +00:00
- Use `--exact-rowcount` for accurate progress indication
- Use `--postpone-cut-over-flag-file` to gain control over cut-over timing
- Get familiar with the [interactive commands](doc/interactive-commands.md)
2016-06-07 12:18:55 +00:00
2016-07-31 07:46:15 +00:00
Also see:
- [requirements and limitations](doc/requirements-and-limitations.md)
2017-02-05 06:05:10 +00:00
- [common questions](doc/questions.md)
2016-07-31 07:46:15 +00:00
- [what if?](doc/what-if.md)
- [the fine print](doc/the-fine-print.md)
2017-02-05 06:05:10 +00:00
- [Community questions](https://github.com/github/gh-ost/issues?q=label%3Aquestion)
2017-04-10 03:58:35 +00:00
- [Using `gh-ost` on AWS RDS](doc/rds.md)
2016-05-23 10:32:43 +00:00
## What's in a name?
Originally this was named `gh-osc`: GitHub Online Schema Change, in the likes of [Facebook online schema change](https://www.facebook.com/notes/mysql-at-facebook/online-schema-change-for-mysql/430801045932/) and [pt-online-schema-change](https://www.percona.com/doc/percona-toolkit/2.2/pt-online-schema-change.html).
2016-08-01 22:20:42 +00:00
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
2016-07-16 12:57:22 +00:00
2016-07-16 13:37:33 +00:00
## License
2016-07-24 15:10:42 +00:00
`gh-ost` is licensed under the [MIT license](https://github.com/github/gh-ost/blob/master/LICENSE)
2016-07-16 13:37:33 +00:00
`gh-ost` uses 3rd party libraries, each with their own license. These are found [here](https://github.com/github/gh-ost/tree/master/vendor).
## Community
`gh-ost` is released at a stable state, but with mileage to go. We are [open to pull requests](https://github.com/github/gh-ost/blob/master/.github/CONTRIBUTING.md). Please first discuss your intentions via [Issues](https://github.com/github/gh-ost/issues).
2016-07-16 16:59:43 +00:00
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](doc/coding-ghost.md) for a guide to getting started developing with gh-ost.
2016-07-16 16:59:43 +00:00
## 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](https://github.com/github/gh-ost/releases/latest)
`gh-ost` is a Go project; it is built with Go `1.12` and above. To build on your own, use either:
2017-06-21 05:44:26 +00:00
- [script/build](https://github.com/github/gh-ost/blob/master/script/build) - this is the same build script used by CI hence the authoritative; artifact is `./bin/gh-ost` binary.
- [build.sh](https://github.com/github/gh-ost/blob/master/build.sh) for building `tar.gz` artifacts in `/tmp/gh-ost`
2016-07-16 16:59:43 +00:00
Generally speaking, `master` branch is stable, but only [releases](https://github.com/github/gh-ost/releases) are to be used in production.
2016-07-16 13:37:33 +00:00
2016-05-23 10:32:43 +00:00
## Authors
2016-05-25 10:34:37 +00:00
`gh-ost` is designed, authored, reviewed and tested by the database infrastructure team at GitHub:
2016-05-25 10:31:33 +00:00
- [@jonahberquist](https://github.com/jonahberquist)
- [@ggunson](https://github.com/ggunson)
- [@tomkrouper](https://github.com/tomkrouper)
- [@shlomi-noach](https://github.com/shlomi-noach)
2018-02-16 21:51:20 +00:00
- [@jessbreckenridge](https://github.com/jessbreckenridge)
- [@gtowey](https://github.com/gtowey)