Skip to content

Commit ed5c804

Browse files
author
Shlomi Noach
authored
Merge pull request #462 from github/concurrent-migrations-doc
documenting concurrent migrations
2 parents 6e51068 + 479c228 commit ed5c804

2 files changed

Lines changed: 22 additions & 4 deletions

File tree

doc/cheatsheet.md

Lines changed: 18 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,11 +1,13 @@
11
# Cheatsheet
22

3+
### Operation modes
4+
35
![operation modes](images/gh-ost-operation-modes.png)
46

57

68
`gh-ost` operates by connecting to potentially multiple servers, as well as imposing itself as a replica in order to streamline binary log events directly from one of those servers. There are various operation modes, which depend on your setup, configuration, and where you want to run the migration.
79

8-
### a. Connect to replica, migrate on master
10+
#### a. Connect to replica, migrate on master
911

1012
This is the mode `gh-ost` expects by default. `gh-ost` will investigate the replica, crawl up to find the topology's master, and will hook onto it as well. Migration will:
1113

@@ -47,7 +49,7 @@ gh-ost \
4749
With `--execute`, migration actually copies data and flips tables. Without it this is a `noop` run.
4850

4951

50-
### b. Connect to master
52+
#### b. Connect to master
5153

5254
If you don't have replicas, or do not wish to use them, you are still able to operate directly on the master. `gh-ost` will do all operations directly on the master. You may still ask it to be considerate of replication lag.
5355

@@ -80,7 +82,7 @@ gh-ost \
8082
[--execute]
8183
```
8284

83-
### c. Migrate/test on replica
85+
#### c. Migrate/test on replica
8486

8587
This will perform a migration on the replica. `gh-ost` will briefly connect to the master but will thereafter perform all operations on the replica without modifying anything on the master.
8688
Throughout the operation, `gh-ost` will throttle such that the replica is up to date.
@@ -146,7 +148,7 @@ gh-ost --allow-master-master --assume-master-host=a.specific.master.com
146148

147149
Topologies using _tungsten replicator_ are peculiar in that the participating servers are not actually aware they are replicating. The _tungsten replicator_ looks just like another app issuing queries on those hosts. `gh-ost` is unable to identify that a server participates in a _tungsten_ topology.
148150

149-
If you choose to migrate directly on master (see above), there's nothing special you need to do.
151+
If you choose to migrate directly on master (see above), there's nothing special you need to do.
150152

151153
If you choose to migrate via replica, then you need to make sure Tungsten is configured with log-slave-updates parameter (note this is different from MySQL's own log-slave-updates parameter), otherwise changes will not be in the replica's binlog, causing data to be corrupted after table swap. You must also supply the identity of the master, and indicate this is a tungsten setup, as follows:
152154

@@ -155,3 +157,15 @@ gh-ost --tungsten --assume-master-host=the.topology.master.com
155157
```
156158

157159
Also note that `--switch-to-rbr` does not work for a Tungsten setup as the replication process is external, so you need to make sure `binlog_format` is set to ROW before Tungsten Replicator connects to the server and starts applying events from the master.
160+
161+
### Concurrent migrations
162+
163+
It is possible to run concurrent `gh-ost` migrations.
164+
165+
- Never on the exact same table.
166+
- If running on different replicas, (e.g. `table1` on `replica1` and `table2` on `replica2`) then no further configuration required.
167+
- If running from same server (binaries run on same server, regardless of which replica/replicas are used):
168+
- Make sure not to specify same `-serve-socket-file` (or let `gh-ost` pick one for you).
169+
- You may choose to use same `-throttle-flag-file` (preferably use `-throttle-additional-flag-file`, this is exactly the reason there's two, this latter file is for sharing).
170+
- You may choose to use same `-panic-flag-file`. This all depends on your flow and how you'd like to control your migrations.
171+
- If using same inspected box (either master or replica, `--host=everyone.uses.this.host`) then for each `gh-ost` process you must also provide a different, unique `--replica-server-id`. Optionally use process ID (`$$` in shell) ; but it's on you to choose a number that does not collide with another `gh-ost` or another running replica.

doc/questions.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,4 +23,8 @@ At this time there is no equivalent to `ALTER IGNORE`, where duplicates are impl
2323
2424
It is therefore unlikely that `gh-ost` will support this behavior.
2525

26+
### Run concurrent migrations?
27+
28+
Yes. TL;DR if running all on same replica/master, make sure to provide `--replica-server-id`. [Read more](cheatsheet.md#concurrent-migrations)
29+
2630
# Why

0 commit comments

Comments
 (0)