前言:前段时间对pt-osc工具进行了原理性分析,但是pt-osc在生产上还是有一些不足的地方,如从库有触发器等就无法使用pt-osc,今天我们使用的是另外一个在线表结构变更工具gh-osc,体验一把新科技
一、安装
gh-osc的安装基本上就是开包即用,到https://github.com/github/gh-ost/releases上下载最新版本的gh-osc的二进制包,解压即可使用。
二、使用参数
[root@localhost tmp]# ./gh-ost --help
Usage of gh-ost:
-aliyun-rds
当在阿里云RDS执行时设置为true
-allow-master-master
允许在双主架构中使用
-allow-nullable-unique-key
允许gh-ost基于带空列的唯一键进行迁移。只要不存在空值,这应该是可以的。如果在选定的键中存在空值,数据可能会被破坏
-allow-on-master
允许直接在主库上迁移。最好是在从库上运行。
-alter string
执行的具体命令
-ask-pass
询问输入密码
-chunk-size int
分批提交的最大值,默认1000
-conf string
指定配置文件名
-critical-load string
指定gh-osc退出的阈值,load超过这个值的话gh-osc自动退出
-cut-over-lock-timeout-seconds int
定义持有锁的最大时间,超时退出
-database string
dbname
-debug
debug模式
-default-retries int
重连次数
-discard-foreign-keys
去除外键
-dml-batch-size int
在单个事务中应用DML事件的批处理大小(范围为1-100)(默认为10)
-execute
如果需要直接执行,打开此参数
-master-password string
master的密码
-master-user string
master的用户名
-max-lag-millis int
监控主从延迟,超过该阈值后停止迁移,等待延迟正常
-max-load string
定义数据库最大负载阈值
-migrate-on-replica
在从库上迁移
-nice-ratio float
force being 'nice', imply sleep time per chunk time; range: [0.0..100.0]. Example values: 0 is aggressive. 1: for every 1ms spent copying rows, sleep additional 1ms (effectively doubling runtime); 0.7: for every 10ms spend in a rowcopy chunk, spend 7ms sleeping immediately after
-ok-to-drop-table
迁移完成后删除旧表
-password string
askMySQL的密码
-port int
mysql的端口,默认3306
-user string
用户名
实际上,gh-osc的使用模式一共有三种:
连接到主库,所有的操作都在主库上做变更,包括实时读取binlog,可能会造成主从复制延迟的问题
连接从库,在主库上读写,读取从库的binlog,然后将变更应用到主
在从库�迁移测试,即在迁移完成后,只在从库更改表结构,但是切换完成后,主库仍是旧表,从库是新表
三、测试
下面我们结合general log在主库上测试一把
[root@localhost tmp]# ./gh-ost -user="root" -password="xcl582388" -host="localhost" -port=3306 -allow-on-master -database="xucl" -table="t" -debug -alter "add column test varchar(10)" -assume-rbr --execute --initially-drop-old-table --ok-to-drop-table
2018-05-22 11:56:08 INFO starting gh-ost 1.0.45
2018-05-22 11:56:08 INFO Migrating `xucl`.`t`
2018-05-22 11:56:08 INFO connection validated on localhost:3306
2018-05-22 11:56:08 INFO User has ALL privileges
2018-05-22 11:56:08 INFO binary logs validated on localhost:3306
2018-05-22 11:56:08 INFO Inspector initiated on localhost.localdomain:3306, version 5.7.20-log
2018-05-22 11:56:08 INFO Table found. Engine=InnoDB
2018-05-22 11:56:08 DEBUG Estimated number of rows via STATUS: 0
2018-05-22 11:56:08 DEBUG Validated no foreign keys exist on table
2018-05-22 11:56:08 DEBUG Validated no triggers exist on table
2018-05-22 11:56:08 INFO Estimated number of rows via EXPLAIN: 1
2018-05-22 11:56:08 DEBUG Potential unique keys in t: [PRIMARY: [user flag id]; has nullable: false]
2018-05-22 11:56:08 INFO Recursively searching for replication master
2018-05-22 11:56:08 DEBUG Looking for master on localhost:3306
2018-05-22 11:56:08 INFO Master found to be localhost.localdomain:3306
2018-05-22 11:56:08 INFO log_slave_updates validated on localhost:3306
2018-05-22 11:56:08 INFO connection validated on localhost:3306
2018-05-22 11:56:08 DEBUG Streamer binlog coordinates: mysql-bin.000001:15862
2018/05/22 11:56:08 binlogsyncer.go:79: [info] create BinlogSyncer with config {99999 mysql localhost 3306 root false false <nil>}
2018-05-22 11:56:08 INFO Connecting binlog streamer at mysql-bin.000001:15862
2018/05/22 11:56:08 binlogsyncer.go:246: [info] begin to sync binlog from position (mysql-bin.000001, 15862)
2018/05/22 11:56:08 binlogsyncer.go:139: [info] register slave for master server localhost:3306
2018-05-22 11:56:08 DEBUG Beginning streaming
2018/05/22 11:56:08 binlogsyncer.go:573: [info] rotate to (mysql-bin.000001, 15862)
2018-05-22 11:56:08 INFO rotate to next log name: mysql-bin.000001
2018-05-22 11:56:08 INFO connection validated on localhost:3306
2018-05-22 11:56:08 INFO connection validated on localhost:3306
2018-05-22 11:56:08 INFO will use time_zone='SYSTEM' on applier
2018-05-22 11:56:08 INFO Examining table structure on applier
2018-05-22 11:56:08 INFO Applier initiated on localhost.localdomain:3306, version 5.7.20-log
2018-05-22 11:56:08 INFO Dropping table `xucl`.`_t_del`
2018-05-22 11:56:08 INFO Table dropped
2018-05-22 11:56:08 INFO Dropping table `xucl`.`_t_ghc`
2018-05-22 11:56:08 INFO Table dropped
2018-05-22 11:56:08 INFO Creating changelog table `xucl`.`_t_ghc`
2018-05-22 11:56:08 INFO Changelog table created
2018-05-22 11:56:08 INFO Creating ghost table `xucl`.`_t_gho`
2018-05-22 11:56:08 INFO Ghost table created
2018-05-22 11:56:08 INFO Altering ghost table `xucl`.`_t_gho`
2018-05-22 11:56:08 DEBUG ALTER statement: alter /* gh-ost */ table `xucl`.`_t_gho` add column test varchar(10)
2018-05-22 11:56:08 INFO Ghost table altered
2018-05-22 11:56:08 INFO Intercepted changelog state GhostTableMigrated
2018-05-22 11:56:08 INFO Waiting for ghost table to be migrated. Current lag is 0s
2018-05-22 11:56:08 DEBUG ghost table migrated
2018-05-22 11:56:08 INFO Handled changelog state GhostTableMigrated
2018-05-22 11:56:08 DEBUG Potential unique keys in _t_gho: [PRIMARY: [user flag id]; has nullable: false]
2018-05-22 11:56:08 INFO Chosen shared unique key is PRIMARY
2018-05-22 11:56:08 INFO Shared columns are user,flag,id,tttt
2018-05-22 11:56:08 INFO Listening on unix socket file: /tmp/gh-ost.xucl.t.sock
2018-05-22 11:56:08 DEBUG Reading migration range according to key: PRIMARY
2018-05-22 11:56:08 INFO Migration min values: [<nil>]
2018-05-22 11:56:08 DEBUG Reading migration range according to key: PRIMARY
2018-05-22 11:56:08 INFO Migration max values: [<nil>]
2018-05-22 11:56:08 INFO Waiting for first throttle metrics to be collected
2018-05-22 11:56:08 INFO First throttle metrics collected
2018-05-22 11:56:08 DEBUG Operating until row copy is complete
# Migrating `xucl`.`t`; Ghost table is `xucl`.`_t_gho`
# Migrating localhost.localdomain:3306; inspecting localhost.localdomain:3306; executing on localhost.localdomain
# Migration started at Tue May 22 11:56:08 +0200 2018
# chunk-size: 1000; max-lag-millis: 1500ms; dml-batch-size: 10; max-load: ; critical-load: ; nice-ratio: 0.000000
# throttle-additional-flag-file: /tmp/gh-ost.throttle
# Serving on unix socket: /tmp/gh-ost.xucl.t.sock
2018-05-22 11:56:08 DEBUG Getting nothing in the write queue. Sleeping...
2018-05-22 11:56:08 DEBUG No rows found in table. Rowcopy will be implicitly empty
2018-05-22 11:56:08 INFO Row copy complete
# Migrating `xucl`.`t`; Ghost table is `xucl`.`_t_gho`
# Migrating localhost.localdomain:3306; inspecting localhost.localdomain:3306; executing on localhost.localdomain
# Migration started at Tue May 22 11:56:08 +0200 2018
# chunk-size: 1000; max-lag-millis: 1500ms; dml-batch-size: 10; max-load: ; critical-load: ; nice-ratio: 0.000000
# throttle-additional-flag-file: /tmp/gh-ost.throttle
# Serving on unix socket: /tmp/gh-ost.xucl.t.sock
Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql-bin.000001:18076; State: migrating; ETA: due
2018-05-22 11:56:08 DEBUG checking for cut-over postpone
2018-05-22 11:56:08 DEBUG checking for cut-over postpone: complete
2018-05-22 11:56:08 INFO Grabbing voluntary lock: gh-ost.41.lock
Copy: 0/1 0.0%; Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql-bin.000001:18076; State: migrating; ETA: N/A
2018-05-22 11:56:08 INFO Setting LOCK timeout as 6 seconds
2018-05-22 11:56:08 INFO Looking for magic cut-over table
2018-05-22 11:56:08 INFO Creating magic cut-over table `xucl`.`_t_del`
2018-05-22 11:56:08 INFO Magic cut-over table created
2018-05-22 11:56:08 INFO Locking `xucl`.`t`, `xucl`.`_t_del`
2018-05-22 11:56:08 INFO Tables locked
2018-05-22 11:56:08 INFO Session locking original & magic tables is 41
2018-05-22 11:56:08 INFO Writing changelog state: AllEventsUpToLockProcessed:1526982968208522643
2018-05-22 11:56:08 INFO Intercepted changelog state AllEventsUpToLockProcessed
2018-05-22 11:56:08 INFO Handled changelog state AllEventsUpToLockProcessed
2018-05-22 11:56:08 INFO Waiting for events up to lock
2018-05-22 11:56:09 DEBUG Getting nothing in the write queue. Sleeping...
2018-05-22 11:56:09 INFO Waiting for events up to lock: got AllEventsUpToLockProcessed:1526982968208522643
2018-05-22 11:56:09 INFO Done waiting for events up to lock; duration=968.589035ms
# Migrating `xucl`.`t`; Ghost table is `xucl`.`_t_gho`
# Migrating localhost.localdomain:3306; inspecting localhost.localdomain:3306; executing on localhost.localdomain
# Migration started at Tue May 22 11:56:08 +0200 2018
# chunk-size: 1000; max-lag-millis: 1500ms; dml-batch-size: 10; max-load: ; critical-load: ; nice-ratio: 0.000000
# throttle-additional-flag-file: /tmp/gh-ost.throttle
# Serving on unix socket: /tmp/gh-ost.xucl.t.sock
Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 1s(total), 0s(copy); streamer: mysql-bin.000001:24040; State: migrating; ETA: due
2018-05-22 11:56:09 INFO Setting RENAME timeout as 3 seconds
2018-05-22 11:56:09 INFO Session renaming tables is 36
2018-05-22 11:56:09 INFO Issuing and expecting this to block: rename /* gh-ost */ table `xucl`.`t` to `xucl`.`_t_del`, `xucl`.`_t_gho` to `xucl`.`t`
Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 1s(total), 0s(copy); streamer: mysql-bin.000001:24488; State: migrating; ETA: due
2018-05-22 11:56:10 DEBUG Getting nothing in the write queue. Sleeping...
Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 2s(total), 0s(copy); streamer: mysql-bin.000001:29007; State: migrating; ETA: due
2018-05-22 11:56:10 INFO Found atomic RENAME to be blocking, as expected. Double checking the lock is still in place (though I don't strictly have to)
2018-05-22 11:56:10 INFO Checking session lock: gh-ost.41.lock
2018-05-22 11:56:10 INFO Connection holding lock on original table still exists
2018-05-22 11:56:10 INFO Will now proceed to drop magic table and unlock tables
2018-05-22 11:56:10 INFO Dropping magic cut-over table
2018-05-22 11:56:10 INFO Releasing lock from `xucl`.`t`, `xucl`.`_t_del`
2018-05-22 11:56:10 INFO Tables unlocked
2018-05-22 11:56:10 INFO Tables renamed
2018-05-22 11:56:10 INFO Lock & rename duration: 2.004491174s. During this time, queries on `t` were blocked
2018-05-22 11:56:10 INFO Looking for magic cut-over table
2018/05/22 11:56:10 binlogsyncer.go:107: [info] syncer is closing...
2018/05/22 11:56:10 binlogstreamer.go:47: [error] close sync with err: sync is been closing...
2018/05/22 11:56:10 binlogsyncer.go:122: [info] syncer is closed
2018-05-22 11:56:10 INFO Closed streamer connection. err=<nil>
2018-05-22 11:56:10 INFO Dropping table `xucl`.`_t_ghc`
2018-05-22 11:56:10 DEBUG done streaming events
2018-05-22 11:56:10 DEBUG Done streaming
2018-05-22 11:56:10 INFO Table dropped
2018-05-22 11:56:10 INFO Dropping table `xucl`.`_t_del`
2018-05-22 11:56:10 INFO Table dropped
2018-05-22 11:56:10 INFO Done migrating `xucl`.`t`
2018-05-22 11:56:10 INFO Removing socket file: /tmp/gh-ost.xucl.t.sock
2018-05-22 11:56:10 INFO Tearing down inspector
2018-05-22 11:56:10 INFO Tearing down applier
2018-05-22 11:56:10 DEBUG Tearing down...
2018-05-22 11:56:10 INFO Tearing down streamer
2018-05-22 11:56:10 INFO Tearing down throttler
2018-05-22 11:56:10 DEBUG Tearing down...
# Done
查看下general log如下:
2018-05-22T09:56:08.032569Z 36 Connect root@localhost on xucl using TCP/IP
2018-05-22T09:56:08.032680Z 36 Query SELECT @@max_allowed_packet
2018-05-22T09:56:08.032732Z 36 Query SET autocommit=true
2018-05-22T09:56:08.032768Z 36 Query SET NAMES utf8mb4
2018-05-22T09:56:08.032835Z 36 Query select @@global.version
2018-05-22T09:56:08.032947Z 36 Query select @@global.port
2018-05-22T09:56:08.033060Z 36 Query select @@global.hostname, @@global.port
2018-05-22T09:56:08.033136Z 36 Query show /* gh-ost */ grants for current_user()
2018-05-22T09:56:08.033853Z 36 Query select @@global.log_bin, @@global.binlog_format
2018-05-22T09:56:08.033991Z 36 Query select @@global.binlog_row_image
2018-05-22T09:56:08.034103Z 36 Query show /* gh-ost */ table status from `xucl` like 't'
2018-05-22T09:56:08.034859Z 36 Query SELECT
SUM(REFERENCED_TABLE_NAME IS NOT NULL AND TABLE_SCHEMA='xucl' AND TABLE_NAME='t') as num_child_side_fk,
SUM(REFERENCED_TABLE_NAME IS NOT NULL AND REFERENCED_TABLE_SCHEMA='xucl' AND REFERENCED_TABLE_NAME='t') as num_parent_side_fk
FROM INFORMATION_SCHEMA.KEY_COLUMN_USAGE
WHERE
REFERENCED_TABLE_NAME IS NOT NULL
AND ((TABLE_SCHEMA='xucl' AND TABLE_NAME='t')
OR (REFERENCED_TABLE_SCHEMA='xucl' AND REFERENCED_TABLE_NAME='t')
)
2018-05-22T09:56:08.044897Z 36 Query SELECT COUNT(*) AS num_triggers
FROM INFORMATION_SCHEMA.TRIGGERS
WHERE
TRIGGER_SCHEMA='xucl'
AND EVENT_OBJECT_TABLE='t'
2018-05-22T09:56:08.052367Z 36 Query explain select /* gh-ost */ * from `xucl`.`t` where 1=1
2018-05-22T09:56:08.052842Z 36 Query SELECT
COLUMNS.TABLE_SCHEMA,
COLUMNS.TABLE_NAME,
COLUMNS.COLUMN_NAME,
UNIQUES.INDEX_NAME,
UNIQUES.COLUMN_NAMES,
UNIQUES.COUNT_COLUMN_IN_INDEX,
COLUMNS.DATA_TYPE,
COLUMNS.CHARACTER_SET_NAME,
LOCATE('auto_increment', EXTRA) > 0 as is_auto_increment,
has_nullable
FROM INFORMATION_SCHEMA.COLUMNS INNER JOIN (
SELECT
TABLE_SCHEMA,
TABLE_NAME,
INDEX_NAME,
COUNT(*) AS COUNT_COLUMN_IN_INDEX,
GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX ASC) AS COLUMN_NAMES,
SUBSTRING_INDEX(GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX ASC), ',', 1) AS FIRST_COLUMN_NAME,
SUM(NULLABLE='YES') > 0 AS has_nullable
FROM INFORMATION_SCHEMA.STATISTICS
WHERE
NON_UNIQUE=0
AND TABLE_SCHEMA = 'xucl'
AND TABLE_NAME = 't'
GROUP BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME
) AS UNIQUES
ON (
COLUMNS.TABLE_SCHEMA = UNIQUES.TABLE_SCHEMA AND
COLUMNS.TABLE_NAME = UNIQUES.TABLE_NAME AND
COLUMNS.COLUMN_NAME = UNIQUES.FIRST_COLUMN_NAME
)
WHERE
COLUMNS.TABLE_SCHEMA = 'xucl'
AND COLUMNS.TABLE_NAME = 't'
ORDER BY
COLUMNS.TABLE_SCHEMA, COLUMNS.TABLE_NAME,
CASE UNIQUES.INDEX_NAME
WHEN 'PRIMARY' THEN 0
ELSE 1
END,
CASE has_nullable
WHEN 0 THEN 0
ELSE 1
END,
CASE IFNULL(CHARACTER_SET_NAME, '')
WHEN '' THEN 0
ELSE 1
END,
CASE DATA_TYPE
WHEN 'tinyint' THEN 0
WHEN 'smallint' THEN 1
WHEN 'int' THEN 2
WHEN 'bigint' THEN 3
ELSE 100
END,
COUNT_COLUMN_IN_INDEX
2018-05-22T09:56:08.053794Z 36 Query show columns from `xucl`.`t`
2018-05-22T09:56:08.054658Z 37 Connect root@localhost on information_schema using TCP/IP
2018-05-22T09:56:08.054753Z 37 Query SELECT @@max_allowed_packet
2018-05-22T09:56:08.054836Z 37 Query SET NAMES utf8mb4
2018-05-22T09:56:08.054862Z 37 Query SET autocommit=true
2018-05-22T09:56:08.054953Z 37 Query show slave status
2018-05-22T09:56:08.055113Z 37 Quit
2018-05-22T09:56:08.055181Z 36 Query select @@global.log_slave_updates
2018-05-22T09:56:08.055274Z 36 Query select @@global.version
2018-05-22T09:56:08.055973Z 36 Query select @@global.port
2018-05-22T09:56:08.056058Z 36 Query show /* gh-ost readCurrentBinlogCoordinates */ master status
2018-05-22T09:56:08.063389Z 38 Connect root@localhost on using TCP/IP
2018-05-22T09:56:08.064119Z 38 Query SHOW GLOBAL VARIABLES LIKE 'BINLOG_CHECKSUM'
2018-05-22T09:56:08.066197Z 38 Query SET @master_binlog_checksum='NONE'
2018-05-22T09:56:08.066478Z 36 Query select @@global.version
2018-05-22T09:56:08.067845Z 38 Binlog Dump Log: 'mysql-bin.000001' Pos: 15862
2018-05-22T09:56:08.072505Z 36 Query select @@global.port
2018-05-22T09:56:08.072916Z 39 Connect root@localhost on xucl using TCP/IP
2018-05-22T09:56:08.072999Z 39 Query SELECT @@max_allowed_packet
2018-05-22T09:56:08.073068Z 39 Query SET NAMES utf8mb4
2018-05-22T09:56:08.073116Z 39 Query SET autocommit=true
2018-05-22T09:56:08.073167Z 39 Query select @@global.version
2018-05-22T09:56:08.073272Z 39 Query select @@global.port
2018-05-22T09:56:08.073354Z 36 Query select @@global.time_zone
2018-05-22T09:56:08.073430Z 36 Query select @@global.hostname, @@global.port
2018-05-22T09:56:08.078324Z 36 Query show columns from `xucl`.`t`
2018-05-22T09:56:08.079002Z 36 Query show /* gh-ost */ table status from `xucl` like '_t_gho'
2018-05-22T09:56:08.086250Z 36 Query drop /* gh-ost */ table if exists `xucl`.`_t_del`
2018-05-22T09:56:08.086565Z 36 Query show /* gh-ost */ table status from `xucl` like '_t_del'
2018-05-22T09:56:08.091585Z 36 Query drop /* gh-ost */ table if exists `xucl`.`_t_ghc`
2018-05-22T09:56:08.091843Z 36 Query create /* gh-ost */ table `xucl`.`_t_ghc` (
id bigint auto_increment,
last_update timestamp not null DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
hint varchar(64) charset ascii not null,
value varchar(4096) charset ascii not null,
primary key(id),
unique key hint_uidx(hint)
) auto_increment=256
2018-05-22T09:56:08.105332Z 36 Query create /* gh-ost */ table `xucl`.`_t_gho` like `xucl`.`t`
2018-05-22T09:56:08.118897Z 36 Query alter /* gh-ost */ table `xucl`.`_t_gho` add column test varchar(10)
2018-05-22T09:56:08.136898Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.136973Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(2, 0), 'state', 'GhostTableMigrated')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.137162Z 36 Close stmt
2018-05-22T09:56:08.137316Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.137935Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(0, 0), 'state at 1526982968137068881', 'GhostTableMigrated')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.138853Z 40 Connect root@localhost on information_schema using TCP/IP
2018-05-22T09:56:08.138921Z 40 Query SELECT @@max_allowed_packet
2018-05-22T09:56:08.142418Z 40 Query SET NAMES utf8mb4
2018-05-22T09:56:08.147283Z 36 Close stmt
2018-05-22T09:56:08.147431Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.147507Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.13866344+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.147809Z 36 Close stmt
2018-05-22T09:56:08.147837Z 40 Query SET autocommit=true
2018-05-22T09:56:08.147901Z 40 Query show slave status
2018-05-22T09:56:08.154605Z 36 Query SELECT
COLUMNS.TABLE_SCHEMA,
COLUMNS.TABLE_NAME,
COLUMNS.COLUMN_NAME,
UNIQUES.INDEX_NAME,
UNIQUES.COLUMN_NAMES,
UNIQUES.COUNT_COLUMN_IN_INDEX,
COLUMNS.DATA_TYPE,
COLUMNS.CHARACTER_SET_NAME,
LOCATE('auto_increment', EXTRA) > 0 as is_auto_increment,
has_nullable
FROM INFORMATION_SCHEMA.COLUMNS INNER JOIN (
SELECT
TABLE_SCHEMA,
TABLE_NAME,
INDEX_NAME,
COUNT(*) AS COUNT_COLUMN_IN_INDEX,
GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX ASC) AS COLUMN_NAMES,
SUBSTRING_INDEX(GROUP_CONCAT(COLUMN_NAME ORDER BY SEQ_IN_INDEX ASC), ',', 1) AS FIRST_COLUMN_NAME,
SUM(NULLABLE='YES') > 0 AS has_nullable
FROM INFORMATION_SCHEMA.STATISTICS
WHERE
NON_UNIQUE=0
AND TABLE_SCHEMA = 'xucl'
AND TABLE_NAME = '_t_gho'
GROUP BY TABLE_SCHEMA, TABLE_NAME, INDEX_NAME
) AS UNIQUES
ON (
COLUMNS.TABLE_SCHEMA = UNIQUES.TABLE_SCHEMA AND
COLUMNS.TABLE_NAME = UNIQUES.TABLE_NAME AND
COLUMNS.COLUMN_NAME = UNIQUES.FIRST_COLUMN_NAME
)
WHERE
COLUMNS.TABLE_SCHEMA = 'xucl'
AND COLUMNS.TABLE_NAME = '_t_gho'
ORDER BY
COLUMNS.TABLE_SCHEMA, COLUMNS.TABLE_NAME,
CASE UNIQUES.INDEX_NAME
WHEN 'PRIMARY' THEN 0
ELSE 1
END,
CASE has_nullable
WHEN 0 THEN 0
ELSE 1
END,
CASE IFNULL(CHARACTER_SET_NAME, '')
WHEN '' THEN 0
ELSE 1
END,
CASE DATA_TYPE
WHEN 'tinyint' THEN 0
WHEN 'smallint' THEN 1
WHEN 'int' THEN 2
WHEN 'bigint' THEN 3
ELSE 100
END,
COUNT_COLUMN_IN_INDEX
2018-05-22T09:56:08.155931Z 36 Query show columns from `xucl`.`_t_gho`
2018-05-22T09:56:08.161827Z 36 Query select
*
from
information_schema.columns
where
table_schema='xucl'
and table_name='t'
2018-05-22T09:56:08.164528Z 36 Query select
*
from
information_schema.columns
where
table_schema='xucl'
and table_name='t'
2018-05-22T09:56:08.165032Z 36 Query select
*
from
information_schema.columns
where
table_schema='xucl'
and table_name='t'
2018-05-22T09:56:08.168654Z 36 Query select
*
from
information_schema.columns
where
table_schema='xucl'
and table_name='_t_gho'
2018-05-22T09:56:08.174110Z 36 Query select /* gh-ost `xucl`.`t` */ `user`, `flag`, `id`
from
`xucl`.`t`
order by
`user` asc, `flag` asc, `id` asc
limit 1
2018-05-22T09:56:08.174861Z 36 Query select /* gh-ost `xucl`.`t` */ `user`, `flag`, `id`
from
`xucl`.`t`
order by
`user` desc, `flag` desc, `id` desc
limit 1
2018-05-22T09:56:08.175660Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.177282Z 41 Connect root@localhost on xucl using TCP/IP
2018-05-22T09:56:08.177373Z 41 Query SELECT @@max_allowed_packet
2018-05-22T09:56:08.177445Z 41 Query SET autocommit=true
2018-05-22T09:56:08.177492Z 41 Query SET NAMES utf8mb4
2018-05-22T09:56:08.177598Z 41 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.177694Z 41 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(0, 0), 'copy iteration 0 at 1526982968', 'Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql-bin.000001:18076; State: migrating; ETA: due')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.182899Z 41 Close stmt
2018-05-22T09:56:08.182955Z 41 Query START TRANSACTION
2018-05-22T09:56:08.183200Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.188933Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(0, 0), 'copy iteration 0 at 1526982968', 'Copy: 0/1 0.0%; Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql-bin.000001:18076; State: migrating; ETA: N/A')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.189266Z 41 Query select connection_id()
2018-05-22T09:56:08.189618Z 41 Query select get_lock('gh-ost.41.lock', 0)
2018-05-22T09:56:08.189677Z 36 Close stmt
2018-05-22T09:56:08.195756Z 41 Query set session lock_wait_timeout:=6
2018-05-22T09:56:08.196910Z 36 Query show /* gh-ost */ table status from `xucl` like '_t_del'
2018-05-22T09:56:08.197392Z 36 Query create /* gh-ost */ table `xucl`.`_t_del` (
id int auto_increment primary key
) engine=InnoDB comment='ghost-cut-over-sentry'
2018-05-22T09:56:08.208183Z 41 Query lock /* gh-ost */ tables `xucl`.`t` write, `xucl`.`_t_del` write
2018-05-22T09:56:08.212669Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.213499Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(2, 0), 'state', 'AllEventsUpToLockProcessed:1526982968208522643')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.215217Z 36 Close stmt
2018-05-22T09:56:08.215437Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.215664Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(0, 0), 'state at 1526982968215071085', 'AllEventsUpToLockProcessed:1526982968208522643')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.216611Z 36 Close stmt
2018-05-22T09:56:08.248739Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.248821Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.248488653+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.249143Z 36 Close stmt
2018-05-22T09:56:08.277018Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.348104Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.348176Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.347919396+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.348452Z 36 Close stmt
2018-05-22T09:56:08.376954Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.448067Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.448141Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.447880905+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.448416Z 36 Close stmt
2018-05-22T09:56:08.478341Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.549633Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.549706Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.549450894+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.549982Z 36 Close stmt
2018-05-22T09:56:08.577941Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.648776Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.648848Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.648594596+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.649123Z 36 Close stmt
2018-05-22T09:56:08.677923Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.749249Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.749321Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.74906528+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.749610Z 36 Close stmt
2018-05-22T09:56:08.777033Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.849435Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.849550Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.849202925+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.849856Z 36 Close stmt
2018-05-22T09:56:08.877064Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:08.948094Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.948174Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:08.947907753+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:08.948446Z 36 Close stmt
2018-05-22T09:56:08.977623Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.049287Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.049373Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.049052703+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.049652Z 36 Close stmt
2018-05-22T09:56:09.078456Z 36 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.149183Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.149280Z 36 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.148887407+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.149589Z 36 Close stmt
2018-05-22T09:56:09.177707Z 42 Connect root@localhost on xucl using TCP/IP
2018-05-22T09:56:09.177800Z 42 Query SELECT @@max_allowed_packet
2018-05-22T09:56:09.178241Z 42 Query SET autocommit=true
2018-05-22T09:56:09.178702Z 42 Query SET NAMES utf8mb4
2018-05-22T09:56:09.178841Z 42 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.179146Z 36 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.179293Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.179377Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(0, 0), 'copy iteration 0 at 1526982969', 'Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 1s(total), 0s(copy); streamer: mysql-bin.000001:24040; State: migrating; ETA: due')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.183848Z 42 Close stmt
2018-05-22T09:56:09.183884Z 36 Close stmt
2018-05-22T09:56:09.183924Z 36 Query START TRANSACTION
2018-05-22T09:56:09.184149Z 36 Query select connection_id()
2018-05-22T09:56:09.189229Z 42 Query select id
from information_schema.processlist
where
id != connection_id()
and 36 in (0, id)
and state like concat('%', 'metadata lock', '%')
and info like concat('%', 'rename', '%')
2018-05-22T09:56:09.189557Z 36 Query set session lock_wait_timeout:=3
2018-05-22T09:56:09.191289Z 43 Connect root@localhost on xucl using TCP/IP
2018-05-22T09:56:09.191372Z 36 Query rename /* gh-ost */ table `xucl`.`t` to `xucl`.`_t_del`, `xucl`.`_t_gho` to `xucl`.`t`
2018-05-22T09:56:09.199314Z 43 Query SELECT @@max_allowed_packet
2018-05-22T09:56:09.200038Z 43 Query SET autocommit=true
2018-05-22T09:56:09.200105Z 43 Query SET NAMES utf8mb4
2018-05-22T09:56:09.200261Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.200404Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.200448Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(0, 0), 'copy iteration 0 at 1526982969', 'Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 1s(total), 0s(copy); streamer: mysql-bin.000001:24488; State: migrating; ETA: due')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.201584Z 42 Close stmt
2018-05-22T09:56:09.201644Z 43 Close stmt
2018-05-22T09:56:09.248258Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.248366Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.248411Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.248052978+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.248704Z 43 Close stmt
2018-05-22T09:56:09.248716Z 42 Close stmt
2018-05-22T09:56:09.277169Z 43 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.348123Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.348254Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.348304Z 43 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.347931458+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.348585Z 42 Close stmt
2018-05-22T09:56:09.348597Z 43 Close stmt
2018-05-22T09:56:09.376970Z 42 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.448083Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.448188Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.448233Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.447894653+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.448513Z 42 Close stmt
2018-05-22T09:56:09.448524Z 43 Close stmt
2018-05-22T09:56:09.477078Z 43 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.548943Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.549054Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.549102Z 43 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.548760771+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.549382Z 42 Close stmt
2018-05-22T09:56:09.549393Z 43 Close stmt
2018-05-22T09:56:09.578227Z 42 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.648137Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.648241Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.648286Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.647954397+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.648568Z 43 Close stmt
2018-05-22T09:56:09.648579Z 42 Close stmt
2018-05-22T09:56:09.677111Z 43 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.748068Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.748171Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.748216Z 43 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.747886726+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.748497Z 42 Close stmt
2018-05-22T09:56:09.748508Z 43 Close stmt
2018-05-22T09:56:09.777156Z 42 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.848840Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.850017Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.850104Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.848555183+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.850528Z 43 Close stmt
2018-05-22T09:56:09.850542Z 42 Close stmt
2018-05-22T09:56:09.877177Z 43 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:09.949419Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.949524Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.949569Z 43 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:09.949216417+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:09.949850Z 42 Close stmt
2018-05-22T09:56:09.949862Z 43 Close stmt
2018-05-22T09:56:09.977901Z 42 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:10.049520Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.049637Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.049684Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:10.049317922+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.049970Z 43 Close stmt
2018-05-22T09:56:10.049981Z 42 Close stmt
2018-05-22T09:56:10.077077Z 43 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:10.148090Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.148195Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.148240Z 43 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:10.147897501+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.148527Z 42 Close stmt
2018-05-22T09:56:10.148538Z 43 Close stmt
2018-05-22T09:56:10.177953Z 42 Query select hint, value from `xucl`.`_t_ghc` where hint = 'heartbeat' and id <= 255
2018-05-22T09:56:10.189863Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.189967Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.190014Z 42 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(0, 0), 'copy iteration 0 at 1526982970', 'Copy: 0/0 100.0%; Applied: 0; Backlog: 0/1000; Time: 2s(total), 0s(copy); streamer: mysql-bin.000001:29007; State: migrating; ETA: due')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.190280Z 43 Close stmt
2018-05-22T09:56:10.190292Z 42 Close stmt
2018-05-22T09:56:10.192997Z 43 Query select id
from information_schema.processlist
where
id != connection_id()
and 36 in (0, id)
and state like concat('%', 'metadata lock', '%')
and info like concat('%', 'rename', '%')
2018-05-22T09:56:10.194342Z 42 Query select is_used_lock('gh-ost.41.lock')
2018-05-22T09:56:10.194469Z 41 Query drop /* gh-ost */ table if exists `xucl`.`_t_del`
2018-05-22T09:56:10.204711Z 41 Query unlock tables
2018-05-22T09:56:10.205209Z 41 Query ROLLBACK
2018-05-22T09:56:10.205210Z 41 Quit
2018-05-22T09:56:10.212698Z 43 Query show /* gh-ost */ table status from `xucl` like '_t_del'
2018-05-22T09:56:10.214087Z 36 Query ROLLBACK
2018-05-22T09:56:10.214211Z 36 Quit
2018-05-22T09:56:10.249618Z 42 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.249924Z 43 Prepare insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(?, 0), ?, ?)
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.249992Z 43 Execute insert /* gh-ost */ into `xucl`.`_t_ghc`
(id, hint, value)
values
(NULLIF(1, 0), 'heartbeat', '2018-05-22T11:56:10.248964488+02:00')
on duplicate key update
last_update=NOW(),
value=VALUES(value)
2018-05-22T09:56:10.250372Z 42 Query drop /* gh-ost */ table if exists `xucl`.`_t_ghc`
2018-05-22T09:56:10.257636Z 42 Close stmt
2018-05-22T09:56:10.257674Z 43 Query drop /* gh-ost */ table if exists `xucl`.`_t_del`
2018-05-22T09:56:10.266537Z 40 Quit
2018-05-22T09:56:10.266589Z 39 Quit
2018-05-22T09:56:10.267238Z 42 Quit
2018-05-22T09:56:10.267326Z 43 Close stmt
2018-05-22T09:56:10.267333Z 43 Quit
以上log相对来说比较多,大致过程可以整理为以下几步:
直连主库
主库上创建ghost表
新表(ghost表)上直接alter修改表结构
迁移原表数据到新表
拉取解析binlog事件,应用到新表
cut-over阶段,用新表替换掉原表