gh-ost/README.md

108 строки
7.1 KiB
Markdown
Исходник Обычный вид История

2016-05-23 13:33:28 +03:00
# gh-ost
2016-05-25 13:31:33 +03:00
2017-04-02 10:46:36 +03: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 18:24:39 +03:00
#### GitHub's online schema migration for MySQL <img src="doc/images/gh-ost-logo-light-160.png" align="right">
2016-05-23 13:32:43 +03:00
2016-07-24 18:10:42 +03: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 13:31:33 +03:00
2016-07-16 16:14:25 +03: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 14:19:06 +03:00
2016-07-20 02:32:40 +03:00
2016-07-16 14:19:06 +03:00
2016-05-25 13:31:33 +03:00
## How?
2016-07-16 16:14:25 +03: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 16:30:22 +03:00
In addition, it offers many [operational perks](doc/perks.md) that make it safer, trustworthy and fun to use.
2016-07-16 16:14:25 +03:00
2016-07-16 14:36:32 +03:00
![gh-ost general flow](doc/images/gh-ost-general-flow.png)
2016-07-16 16:30:22 +03:00
## Highlights
2016-07-16 16:14:25 +03:00
2016-07-16 16:30:22 +03: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 15:46:43 +03:00
- External [hooks](doc/hooks.md) can couple `gh-ost` with your particular environment.
2016-05-23 13:32:43 +03:00
2016-07-31 17:07:59 +03:00
Please refer to the [docs](doc) for more information. No, really, read the [docs](doc).
2016-06-06 14:01:47 +03:00
## Usage
2016-07-16 16:30:22 +03:00
The [cheatsheet](doc/cheatsheet.md) has it all. You may be interested in invoking `gh-ost` in various modes:
2016-07-16 16:30:22 +03: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 16:30:22 +03:00
Our tips:
2016-07-22 18:26:33 +03: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 16:30:22 +03:00
- For each master migration, first issue a _noop_
- Then issue the real thing via `--execute`.
2016-07-16 16:30:22 +03:00
More tips:
2016-06-06 14:01:47 +03:00
2016-07-16 16:30:22 +03: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 15:18:55 +03:00
2016-07-31 10:46:15 +03:00
Also see:
- [requirements and limitations](doc/requirements-and-limitations.md)
2017-02-05 09:05:10 +03:00
- [common questions](doc/questions.md)
2016-07-31 10:46:15 +03:00
- [what if?](doc/what-if.md)
- [the fine print](doc/the-fine-print.md)
2017-02-05 09:05:10 +03:00
- [Community questions](https://github.com/github/gh-ost/issues?q=label%3Aquestion)
2017-04-10 06:58:35 +03:00
- [Using `gh-ost` on AWS RDS](doc/rds.md)
2016-05-23 13:32:43 +03: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-02 01:20:42 +03: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 15:57:22 +03:00
2016-07-16 16:37:33 +03:00
## License
2016-07-24 18:10:42 +03:00
`gh-ost` is licensed under the [MIT license](https://github.com/github/gh-ost/blob/master/LICENSE)
2016-07-16 16:37:33 +03: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 19:59:43 +03: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](https://github.com/github/gh-ost/blob/develdocs/doc/coding-ghost.md) for a guide to getting started developing with gh-ost.
2016-07-16 19:59:43 +03: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.5 with "experimental vendor". Soon to migrate to Go 1.6. See and use [build file](https://github.com/github/gh-ost/blob/master/build.sh) for compiling it on your own.
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 16:37:33 +03:00
2016-05-23 13:32:43 +03:00
## Authors
2016-05-25 13:34:37 +03:00
`gh-ost` is designed, authored, reviewed and tested by the database infrastructure team at GitHub:
2016-05-25 13:31:33 +03:00
- [@jonahberquist](https://github.com/jonahberquist)
- [@ggunson](https://github.com/ggunson)
- [@tomkrouper](https://github.com/tomkrouper)
- [@shlomi-noach](https://github.com/shlomi-noach)