Merge branch 'master' into json-57-tests
This commit is contained in:
commit
30ffe2b331
@ -1,11 +1,13 @@
|
||||
# Cheatsheet
|
||||
|
||||
### Operation modes
|
||||
|
||||
![operation modes](images/gh-ost-operation-modes.png)
|
||||
|
||||
|
||||
`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.
|
||||
|
||||
### a. Connect to replica, migrate on master
|
||||
#### a. Connect to replica, migrate on master
|
||||
|
||||
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:
|
||||
|
||||
@ -47,7 +49,7 @@ gh-ost \
|
||||
With `--execute`, migration actually copies data and flips tables. Without it this is a `noop` run.
|
||||
|
||||
|
||||
### b. Connect to master
|
||||
#### b. Connect to master
|
||||
|
||||
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.
|
||||
|
||||
@ -80,7 +82,7 @@ gh-ost \
|
||||
[--execute]
|
||||
```
|
||||
|
||||
### c. Migrate/test on replica
|
||||
#### c. Migrate/test on replica
|
||||
|
||||
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.
|
||||
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
|
||||
|
||||
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.
|
||||
|
||||
If you choose to migrate directly on master (see above), there's nothing special you need to do.
|
||||
If you choose to migrate directly on master (see above), there's nothing special you need to do.
|
||||
|
||||
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:
|
||||
|
||||
@ -155,3 +157,15 @@ gh-ost --tungsten --assume-master-host=the.topology.master.com
|
||||
```
|
||||
|
||||
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.
|
||||
|
||||
### Concurrent migrations
|
||||
|
||||
It is possible to run concurrent `gh-ost` migrations.
|
||||
|
||||
- Never on the exact same table.
|
||||
- If running on different replicas, (e.g. `table1` on `replica1` and `table2` on `replica2`) then no further configuration required.
|
||||
- If running from same server (binaries run on same server, regardless of which replica/replicas are used):
|
||||
- Make sure not to specify same `-serve-socket-file` (or let `gh-ost` pick one for you).
|
||||
- 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).
|
||||
- You may choose to use same `-panic-flag-file`. This all depends on your flow and how you'd like to control your migrations.
|
||||
- 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.
|
||||
|
@ -23,4 +23,8 @@ At this time there is no equivalent to `ALTER IGNORE`, where duplicates are impl
|
||||
|
||||
It is therefore unlikely that `gh-ost` will support this behavior.
|
||||
|
||||
### Run concurrent migrations?
|
||||
|
||||
Yes. TL;DR if running all on same replica/master, make sure to provide `--replica-server-id`. [Read more](cheatsheet.md#concurrent-migrations)
|
||||
|
||||
# Why
|
||||
|
@ -18,25 +18,28 @@ func init() {
|
||||
}
|
||||
|
||||
func TestGetTableNames(t *testing.T) {
|
||||
context = newMigrationContext()
|
||||
{
|
||||
context = newMigrationContext()
|
||||
context.OriginalTableName = "some_table"
|
||||
test.S(t).ExpectEquals(context.GetOldTableName(), "_some_table_del")
|
||||
test.S(t).ExpectEquals(context.GetGhostTableName(), "_some_table_gho")
|
||||
test.S(t).ExpectEquals(context.GetChangelogTableName(), "_some_table_ghc")
|
||||
}
|
||||
{
|
||||
context = newMigrationContext()
|
||||
context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890"
|
||||
test.S(t).ExpectEquals(context.GetOldTableName(), "_a1234567890123456789012345678901234567890123456789012345678_del")
|
||||
test.S(t).ExpectEquals(context.GetGhostTableName(), "_a1234567890123456789012345678901234567890123456789012345678_gho")
|
||||
test.S(t).ExpectEquals(context.GetChangelogTableName(), "_a1234567890123456789012345678901234567890123456789012345678_ghc")
|
||||
}
|
||||
{
|
||||
context = newMigrationContext()
|
||||
context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890123"
|
||||
oldTableName := context.GetOldTableName()
|
||||
test.S(t).ExpectEquals(oldTableName, "_a1234567890123456789012345678901234567890123456789012345678_del")
|
||||
}
|
||||
{
|
||||
context = newMigrationContext()
|
||||
context.OriginalTableName = "a123456789012345678901234567890123456789012345678901234567890123"
|
||||
context.TimestampOldTable = true
|
||||
longForm := "Jan 2, 2006 at 3:04pm (MST)"
|
||||
@ -45,9 +48,9 @@ func TestGetTableNames(t *testing.T) {
|
||||
test.S(t).ExpectEquals(oldTableName, "_a1234567890123456789012345678901234567890123_20130203195400_del")
|
||||
}
|
||||
{
|
||||
context = newMigrationContext()
|
||||
context.OriginalTableName = "foo_bar_baz"
|
||||
context.ForceTmpTableName = "tmp"
|
||||
context.TimestampOldTable = false
|
||||
test.S(t).ExpectEquals(context.GetOldTableName(), "_tmp_del")
|
||||
test.S(t).ExpectEquals(context.GetGhostTableName(), "_tmp_gho")
|
||||
test.S(t).ExpectEquals(context.GetChangelogTableName(), "_tmp_ghc")
|
||||
|
Loading…
Reference in New Issue
Block a user