github / github/gh-ost

How do you run this on a simple, single database instance?

Open
#815 9 comments 1 reaction 0 assignees View on GitHub
question
Dominant language
Go
Stars
13.6k
Forks
1.4k
Avg merge
2h 31m
Merged PRs (30d)
4

Description

I'm trying to put together documentation on using this for a single database instance (no cluster, master-master, etc..). What I have so far is still not working.

1. Make sure it's an https://github.com/github/gh-ost/blob/master/doc/shared-key.md#examples-allowed-and-not-allowed alter statement

2. Make sure you have a MySQL config file with a `[client]` block: https://github.com/github/gh-ost/blob/master/doc/cheatsheet.md#cnf-file

3. Enable MySQL binary log

Check to see if the binary log is on, and set to `ROW`.

```
MariaDB [(none)]> SHOW VARIABLES LIKE 'log_bin%';
+---------------------------------+--------------------------------+
| Variable_name | Value |
+---------------------------------+--------------------------------+
| log_bin | ON |
| log_bin_basename | /var/lib/mysql/mysql-bin |
| log_bin_index | /var/lib/mysql/mysql-bin.index |
| log_bin_trust_function_creators | OFF |
+---------------------------------+--------------------------------+
```

```
MariaDB [(none)]> SHOW VARIABLES LIKE 'binlog%';
+-----------------------------------------+--------+
| Variable_name | Value |
+-----------------------------------------+--------+
| binlog_annotate_row_events | OFF |
| binlog_cache_size | 32768 |
| binlog_checksum | NONE |
| binlog_commit_wait_count | 0 |
| binlog_commit_wait_usec | 100000 |
| binlog_direct_non_transactional_updates | OFF |
| binlog_format | ROW |
| binlog_optimize_thread_scheduling | ON |
| binlog_row_image | FULL |
| binlog_stmt_cache_size | 32768 |
+-----------------------------------------+--------+
```

If not, (or wrong format) add the following config to `/etc/mysql/[conf.d]/10-gh-ost.cnf`

You can read more here: https://dev.mysql.com/doc/refman/8.0/en/binary-log.html

```
[mysqld]
log-bin=mysql-bin
binlog-format=ROW
; 24hrs: https://dev.mysql.com/doc/refman/8.0/en/replication-options-binary-log.html#sysvar_binlog_expire_logs_seconds
;binlog_expire_logs_seconds=86400
```

4. Check the config is valid

The following will validate the configs without starting MySQL

$ mysqld --help

5. Test changes

You can see the flags here: https://github.com/github/gh-ost/blob/master/doc/command-line-flags.md

```

gh-ost \
--max-load=Threads_running=25 \
--critical-load=Threads_running=1000 \
--chunk-size=1000 \
--max-lag-millis=1500 \
--conf=my.cnf \
--host=127.0.0.1 \
--allow-on-master \
--database="foo" \
--table="bar" \
--verbose \
--alter="ADD COLUMN ip_address VARBINARY(16) NULL DEFAULT NULL" \
--assume-rbr \
--cut-over=default \
--exact-rowcount \
--discard-foreign-keys \
--concurrent-rowcount \
--default-retries=120 \
--panic-flag-file=/tmp/ghost.panic.flag \
--postpone-cut-over-flag-file=/tmp/ghost.postpone.flag \
```

6. LIVE: Run changes

add the following

-- execute

7. Disable binary logs

They take up a lot of space. Alternatively purge old logs manually instead of waiting until `binlog_expire_logs_seconds`.

```
PURGE BINARY LOGS BEFORE '2019-04-02 22:46:26';
```

## Issues

Still unable to run this though.

```
2020-02-04 15:25:25 INFO Connecting binlog streamer at mysql-bin.000009:4
[2020/02/04 15:25:25] [info] binlogsyncer.go:133 create BinlogSyncer with config {99999 mysql 127.0.0.1 3306 root false false false UTC true 0 0s 0s 0 false}
[2020/02/04 15:25:25] [info] binlogsyncer.go:354 begin to sync binlog from position (mysql-bin.000009, 4)
[2020/02/04 15:25:25] [info] binlogsyncer.go:203 register slave for master server 127.0.0.1:3306
2020-02-04 15:25:25 INFO StreamEvents encountered unexpected error: ERROR 1236 (HY000): Misconfigured master - server id was not set
[2020/02/04 15:25:25] [error] binlogstreamer.go:77 close sync with err: ERROR 1236 (HY000): Misconfigured master - server id was not set
```

I checked the [docs and the default server_id is 1](https://dev.mysql.com/doc/refman/8.0/en/replication-options.html#option_mysqld_server-id) already.

```
MariaDB [(none)]> SHOW GLOBAL VARIABLES like 'server\_id';
+---------------+-------+
| Variable_name | Value |
+---------------+-------+
| server_id | 1 |
+---------------+-------+
```

I don't see any commands though that let you specify "1" though and gh-ost doesn't seem to be detecting it.

Could we flush this out more into a guide on using gh-ost for a single master server?

Contributor guide

Open the contributing guide

Assessment

This issue has not been assessed yet.

Get new issues in your inbox

A short digest of beginner-friendly GitHub issues.