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: он меняет структуру живых таблиц, копируя данные в «ghost-таблицу», при этом нагрузка на мастер остаётся небольшой и отделена от обычного трафика.
Чем он отличается от других инструментов онлайн-изменения схемы?Он копирует вашу таблицу в ghost-таблицу и в конце меняет их местами, но работает без триггеров: он читает поток binary log и применяет изменения асинхронно, что позволяет ему по-настоящему приостанавливаться и отсоединять свою нагрузку от мастера.
Как его получить и запустить миграцию?Скачайте готовый бинарник для Linux или macOS либо соберите из исходников на Go 1.15+ командой script/build. В cheatsheet описаны все режимы; рекомендуемый порядок: сначала тестовый прогон в режиме noop, затем настоящая миграция с --execute.
Какая настройка базы данных нужна, чтобы это работало?Настройка MySQL, изменения в которой он может отслеживать через binary log. Он предпочитает запускать миграции через реплику (сам определяет задействованные серверы), а для AWS RDS и Azure Database for MySQL есть официальные руководства.
Есть ли подводные камни, прежде чем направлять его на продакшен-мастер?Если на мастере используется Statement Based Replication, режим через реплику обязателен. Кроме того, для продакшена предназначены только релизы с тегами — ветка master в целом стабильна, но в прод её брать нельзя.
Он проверен на больших продакшен-базах?Да — он GA и стабилен, создан командой инфраструктуры баз данных GitHub, которая непрерывно мигрирует все свои продакшен-таблицы на репликах и сверяет результаты контрольными суммами, чтобы убедиться в корректности.
Чем я могу управлять во время миграции?Многим: троттлинг по-настоящему останавливает все записи на мастере, настройки можно менять интерактивно прямо во время работы, статус доступен через unix-сокет или TCP, финальную замену таблиц можно отложить до удобного момента, а сам процесс привязывается к вашему окружению через внешние хуки.
Можно проверить его, не трогая продакшен-данные?Да: --test-on-replica запускает ровно тот же процесс миграции на реплике, не заменяя исходную таблицу, и оставляет две таблицы, которые можно сравнить и сверить контрольными суммами. Для миграций на мастере сначала сделайте прогон в режиме noop, затем настоящий запуск с --execute.
Почему он называется gh-ost?Произносится как Ghost и расшифровывается как GitHub's Online Schema Transmogrifier/Translator/Transformer/Transfigurator. Изначально он назывался gh-osc (Online Schema Change) — по образцу Facebook's 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