Skip to content

Commit 8ae02ef

Browse files
Merge pull request #905 from github/azure-support
Support Azure Database for MySQL (merge PR)
2 parents e99b915 + bf408b0 commit 8ae02ef

File tree

9 files changed

+38
-3
lines changed

9 files changed

+38
-3
lines changed

README.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ Also see:
6565
- [the fine print](doc/the-fine-print.md)
6666
- [Community questions](https://github.com/github/gh-ost/issues?q=label%3Aquestion)
6767
- [Using `gh-ost` on AWS RDS](doc/rds.md)
68+
- [Using `gh-ost` on Azure Database for MySQL](doc/azure.md)
6869

6970
## What's in a name?
7071

doc/azure.md

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,26 @@
1+
`gh-ost` has been updated to work with Azure Database for MySQL however due to GitHub does not use it, this documentation is community driven so if you find a bug please [open an issue][new_issue]!
2+
3+
# Azure Database for MySQL
4+
5+
## Limitations
6+
7+
- `gh-ost` runs should be setup use [`--assume-rbr`][assume_rbr_docs] and use `binlog_row_image=FULL`.
8+
- Azure Database for MySQL does not use same user name suffix for master and replica, so master host, user and password need to be pointed out.
9+
10+
## Step
11+
1. Change the replica server's `binlog_row_image` from `MINIMAL` to `FULL`. See [guide](https://docs.microsoft.com/en-us/azure/mysql/howto-server-parameters) on Azure document.
12+
2. Use your `gh-ost` always with additional 5 parameter
13+
```{bash}
14+
gh-ost \
15+
--azure \
16+
--assume-master-host=master-server-dns-name \
17+
--master-user="master-user-name" \
18+
--master-password="master-password" \
19+
--assume-rbr \
20+
[-- other paramters you need]
21+
```
22+
23+
24+
[new_issue]: https://github.com/github/gh-ost/issues/new
25+
[assume_rbr_docs]: https://github.com/github/gh-ost/blob/master/doc/command-line-flags.md#assume-rbr
26+
[migrate_test_on_replica_docs]: https://github.com/github/gh-ost/blob/master/doc/cheatsheet.md#c-migratetest-on-replica

doc/command-line-flags.md

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,10 @@ A more in-depth discussion of various `gh-ost` command line flags: implementatio
66

77
Add this flag when executing on Aliyun RDS.
88

9+
### azure
10+
11+
Add this flag when executing on Azure Database for MySQL.
12+
913
### allow-master-master
1014

1115
See [`--assume-master-host`](#assume-master-host).

doc/requirements-and-limitations.md

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,7 @@ The `SUPER` privilege is required for `STOP SLAVE`, `START SLAVE` operations. Th
4141
- Amazon RDS works, but has its own [limitations](rds.md).
4242
- Google Cloud SQL works, `--gcp` flag required.
4343
- Aliyun RDS works, `--aliyun-rds` flag required.
44+
- Azure Database for MySQL works, `--azure` flag required, and have detailed document about it. (azure.md)
4445

4546
- Multisource is not supported when migrating via replica. It _should_ work (but never tested) when connecting directly to master (`--allow-on-master`)
4647

go/base/context.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -97,6 +97,7 @@ type MigrationContext struct {
9797
DiscardForeignKeys bool
9898
AliyunRDS bool
9999
GoogleCloudPlatform bool
100+
AzureMySQL bool
100101

101102
config ContextConfig
102103
configMutex *sync.Mutex

go/base/utils.go

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -75,7 +75,8 @@ func ValidateConnection(db *gosql.DB, connectionConfig *mysql.ConnectionConfig,
7575
}
7676
// AliyunRDS set users port to "NULL", replace it by gh-ost param
7777
// GCP set users port to "NULL", replace it by gh-ost param
78-
if migrationContext.AliyunRDS || migrationContext.GoogleCloudPlatform {
78+
// Azure MySQL set users port to a different value by design, replace it by gh-ost para
79+
if migrationContext.AliyunRDS || migrationContext.GoogleCloudPlatform || migrationContext.AzureMySQL {
7980
port = connectionConfig.Key.Port
8081
} else {
8182
portQuery := `select @@global.port`

go/cmd/gh-ost/main.go

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -79,6 +79,7 @@ func main() {
7979
flag.BoolVar(&migrationContext.SkipStrictMode, "skip-strict-mode", false, "explicitly tell gh-ost binlog applier not to enforce strict sql mode")
8080
flag.BoolVar(&migrationContext.AliyunRDS, "aliyun-rds", false, "set to 'true' when you execute on Aliyun RDS.")
8181
flag.BoolVar(&migrationContext.GoogleCloudPlatform, "gcp", false, "set to 'true' when you execute on a 1st generation Google Cloud Platform (GCP).")
82+
flag.BoolVar(&migrationContext.AzureMySQL, "azure", false, "set to 'true' when you execute on Azure Database on MySQL.")
8283

8384
executeFlag := flag.Bool("execute", false, "actually execute the alter & migrate the table. Default is noop: do some tests and exit")
8485
flag.BoolVar(&migrationContext.TestOnReplica, "test-on-replica", false, "Have the migration run on a replica, not on the master. At the end of migration replication is stopped, and tables are swapped and immediately swap-revert. Replication remains stopped and you can compare the two tables for building trust")

go/logic/applier.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -89,7 +89,7 @@ func (this *Applier) InitDBConnections() (err error) {
8989
if err := this.validateAndReadTimeZone(); err != nil {
9090
return err
9191
}
92-
if !this.migrationContext.AliyunRDS && !this.migrationContext.GoogleCloudPlatform {
92+
if !this.migrationContext.AliyunRDS && !this.migrationContext.GoogleCloudPlatform && !this.migrationContext.AzureMySQL {
9393
if impliedKey, err := mysql.GetInstanceKey(this.db); err != nil {
9494
return err
9595
} else {

go/logic/inspect.go

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -52,7 +52,7 @@ func (this *Inspector) InitDBConnections() (err error) {
5252
if err := this.validateConnection(); err != nil {
5353
return err
5454
}
55-
if !this.migrationContext.AliyunRDS && !this.migrationContext.GoogleCloudPlatform {
55+
if !this.migrationContext.AliyunRDS && !this.migrationContext.GoogleCloudPlatform && !this.migrationContext.AzureMySQL {
5656
if impliedKey, err := mysql.GetInstanceKey(this.db); err != nil {
5757
return err
5858
} else {

0 commit comments

Comments
 (0)