背景
gh-ost 是 Git Hub 开放源码的 My SQL 在线 DDL 工具,使用创建幽灵表(ghost table)并使用 binlog 回放增量改动,实现低锁、低负载的表结构变更。
其 My SQL 兼容方式虽具有大部分 gh-ost 功能,不过官方原生 gh-ost 无法直接运转,Ocean Base当作分布式数据库。
基础环境:
操作系统:Alibaba Cloud Linux release 3 (Open Anolis Edition)
数据库版本:Ocean Base_CE 4.3.5.3
代理版本:Ob Proxy-Ocean Base 4.3.6.1-2.el 7
Binlog 组件:obbinlog-ce-4.3.5-100000262026010516
gh-ost 适配迭代:
基础配置:
sys租户修改ODP设定 proxy_id、client_session_id_version、enable_single_leader_node_routing
proxy_id
是给proxy设置id,不同proxy应当设置不同,用来识别proxy链接的和产出唯一client session id。
client_session_id_version
修改为2,具有全局session id的能力,这就需要唯一的proxy_id
enable_single_leader_node_routing
设置为false以后,p B会绕过OB 2.0协议。表锁功能依赖My SQL协议,所以需要关闭该功能。
需要
开启OB binlog
alter proxyconfig set proxy_id=1;-- 确保每个proxy不同即可 alter proxyconfig set client_session_id_version=2; alter proxyconfig set enable_single_leader_node_routing = false;
租户需要开启一下设定:
enable_lock_priority
关于 DDL 表现或许有左右,细节参考 ,采用完毕建议准时关闭。
alter system set enable_lock_priority ='true';
工具安装配置
下载并部署适配 oceanbase 的 fork 迭代
CGO_ENABLED=0 GOOS=linux GOARCH=amd 64 go build \
-o gh-ost go/cmd/gh-ost/main.go
sudo mv gh-ost /usr/local/bin/
sudo chmod +x /usr/local/bin/gh-ost
测试验证:
gh-ost –version
输出示例(无迭代号属正常)
测试参数情况:
参数
说明
--assume-rbr
跳过 binlog 格式检查和 STOP/START SLAVE
--aliyun-rds
跳过不兼容的体系查询
--skip-foreign-key-checks
跳过外键检查
--allow-on-master
Ocean Base 无从库概念时务必
--initially-drop-ghost-table
清理或许残留的 ghost 表
--initially-drop-old-table
清理或许残留的 old 表
实验
obclient -h 127.0.0.1 -P 2883 -uroot@my_test -p
实验前准备:
测试表
-- ============================================================ -- 验证表1:基础场景表(员工表) -- ============================================================ CREATE TABLE t_employee (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
name VARCHAR(100) NOT NULL,
email VARCHAR(200) NOT NULL,
department VARCHAR(50) DEFAULT ‘Engineering’,
salary DECIMAL(10,2) DEFAULT 0.00,
status TINYINT NOT NULL DEFAULT 1,
phone VARCHAR(20) DEFAULT NULL COMMENT ‘手机号
,
created_at DATETIME DEFAULT CURRENT_TIMESTAMP, updated_at DATETIME DEFAULT CURRENT_TIMESTAMP ON UPDATE CURRENT_TIMESTAMP,
INDEX idx_department (department),
INDEX idx_email (email),
INDEX idx_status (status)
) ENGINE=Inno DB DEFAULT CHARSET=utf 8mb 4;
-- ============================================================ -- 验证表2:订单表(含好几类资料类型) -- ============================================================ CREATE TABLE t_order (
order_id BIGINT AUTO_INCREMENT PRIMARY KEY,
user_id INT NOT NULL,
order_no VARCHAR(64) NOT NULL,
amount DECIMAL(12,2) NOT NULL DEFAULT 0.00,
status ENUM(‘pending’,’paid’,’shipped’,’completed’,’cancelled’) DEFAULT ‘pending’,
pay_time DATETIME DEFAULT NULL,
remark TEXT DEFAULT NULL,
extra JSON DEFAULT NULL,
created_at TIMESTAMP DEFAULT CURRENT_TIMESTAMP,
UNIQUE KEY uk_order_no (order_no),
INDEX idx_user_id (user_id),
INDEX idx_status (status),
INDEX idx_created_at (created_at)
) ENGINE=Inno DB DEFAULT CHARSET=utf 8mb 4;
-- ============================================================ -- 验证表3:记录表(大文本字段) -- ============================================================ CREATE TABLE t_log (
id BIGINT AUTO_INCREMENT PRIMARY KEY,
log_level VARCHAR(10) NOT NULL DEFAULT ‘INFO’,
module VARCHAR(50) NOT NULL,
message TEXT NOT NULL,
trace_id VARCHAR(64) DEFAULT NULL,
created_at DATETIME(3) DEFAULT CURRENT_TIMESTAMP(3),
INDEX idx_level (log_level),
INDEX idx_module (module),
INDEX idx_trace (trace_id)
) ENGINE=Inno DB DEFAULT CHARSET=utf 8mb 4;
测试1:
删除普通列
gh-ost \
--host=127.0.0.1 --port=2883 \ --user="root@my_test" --password="aa AA 11__ob" \ --database="lx" --table="t_employee" \ --alter="drop COLUMN phone " \ --assume-rbr --aliyun-rds --skip-foreign-key-checks \ --cut-over=default \ --allow-on-master \ --initially-drop-ghost-table --initially-drop-old-table --ok-to-drop-table \ --chunk-size=1000 --verbose \ --execute
结果:
2026-08-10 09:38:34 INFO starting gh-ost unversioned (git commit: unknown)
2026-08-10 09:38:34 INFO Migrating P0.P1
2026-08-10 09:38:34 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
2026-08-10 09:38:34 INFO inspector connection validated on 127.0.0.1:2883
2026-08-10 09:38:34 INFO User has ALL privileges
2026-08-10 09:38:34 INFO binary logs validated on 127.0.0.1:2883
2026-08-10 09:38:34 INFO Inspector initiated on 127.0.0.1:2883, version 5.7.25-Ocean Base_CE-v 4.3.5.3
2026-08-10 09:38:34 INFO Table found. Engine=oceanbase
2026-08-10 09:38:34 WARNING –skip-foreign-key-checks provided: will not check for foreign keys []
2026-08-10 09:38:34 INFO Estimated number of rows via EXPLAIN: 0
2026-08-10 09:38:34 INFO Recursively searching for replication master
2026-08-10 09:38:34 INFO Master found to be 127.0.0.1:2883
2026-08-10 09:38:34 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
2026-08-10 09:38:34 INFO streamer connection validated on 127.0.0.1:2883
[2026/08/10 09:38:34] [info] binlogsyncer.go:173 create Binlog Syncer with config {Server ID:99999 Flavor:my Host:127.0.0.1 Port:2883 User:root@my_test Password: Localhost: Charset: Semi Sync Enabled:false Raw Mode Enabled:false TLSConfig: Parse Time:false Timestamp String Location:UTC Use Decimal:true Recv Buffer Size:0 Heartbeat Period:0s Read Timeout:0s Max Reconnect Attempts:0 Disable Retry Sync:false Verify Checksum:false Dump Command Flag:0 Option: Logger:0xc 000076420 Dialer:0x 68f 940 Rows Event Decode Func: Discard GTIDSet:false}
2026-08-10 09:38:34 INFO Connecting binlog streamer at my-bin.000001:6824315
[2026/08/10 09:38:34] [info] binlogsyncer.go:410 begin to sync binlog from position (my-bin.000001, 6824315)
[2026/08/10 09:38:35] [info] binlogsyncer.go:813 rotate to (my-bin.000001, 6824315)
2026-08-10 09:38:35 INFO rotate to next log from my-bin.000001:0 to my-bin.000001
2026-08-10 09:38:35 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
2026-08-10 09:38:35 INFO applier connection validated on 127.0.0.1:2883
2026-08-10 09:38:35 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
2026-08-10 09:38:35 INFO applier connection validated on 127.0.0.1:2883
2026-08-10 09:38:35 INFO will use time_zone=’+08:00′ on applier
2026-08-10 09:38:35 INFO Examining table structure on applier
2026-08-10 09:38:35 INFO Applier initiated on 127.0.0.1:2883, version 5.7.25-Ocean Base_CE-v 4.3.5.3
2026-08-10 09:38:35 INFO Dropping table P0.P1
2026-08-10 09:38:35 INFO Table dropped
2026-08-10 09:38:35 INFO Dropping table P0.P1
2026-08-10 09:38:35 INFO Table dropped
2026-08-10 09:38:35 INFO Dropping table P0.P1
2026-08-10 09:38:35 INFO Table dropped
2026-08-10 09:38:35 INFO Creating changelog table P0.P1
2026-08-10 09:38:35 INFO Changelog table created
2026-08-10 09:38:35 INFO Creating ghost table P0.P1
2026-08-10 09:38:35 INFO Ghost table created
2026-08-10 09:38:35 INFO Altering ghost table P0.P1
2026-08-10 09:38:35 INFO Ghost table altered
2026-08-10 09:38:35 INFO Waiting for ghost table to be migrated. Current lag is 0s
2026-08-10 09:38:36 INFO Intercepted changelog state Ghost Table Migrated
2026-08-10 09:38:36 INFO Handled changelog state Ghost Table Migrated
2026-08-10 09:38:36 INFO Chosen shared unique key is PRIMARY
2026-08-10 09:38:36 INFO Shared columns are id,name,email,department,salary,status,created_at,updated_at
2026-08-10 09:38:36 INFO Listening on unix socket file: /tmp/gh-ost.test.t_employee.sock
2026-08-10 09:38:36 INFO Migration min values: []
2026-08-10 09:38:36 INFO Migration max values: []
2026-08-10 09:38:36 INFO Waiting for first throttle metrics to be collected
2026-08-10 09:38:36 INFO First throttle metrics collected
Migrating P0.P1; Ghost table is P2.P3
Migrating 127.0.0.1:2883; inspecting 127.0.0.1:2883; executing on i Zbp 1dolvurzctg 3ubygce Z
Migration started at Mon Aug 10 09:38:34 +0800 2026
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.test.t_employee.sock
2026-08-10 09:38:36 INFO Row copy complete
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 2s(total), 0s(copy);streamer: my-bin.000001:6826508;Lag: 0.07s, Heartbeat Lag: 0.38s, State: migrating;ETA: due
2026-08-10 09:38:36 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 2s(total), 0s(copy);streamer: my-bin.000001:6826508;Lag: 0.07s, Heartbeat Lag: 0.38s, State: migrating;ETA: due []
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 2s(total), 0s(copy);streamer: my-bin.000001:6826508;Lag: 0.07s, Heartbeat Lag: 0.38s, State: migrating;ETA: due
2026-08-10 09:38:36 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 2s(total), 0s(copy);streamer: my-bin.000001:6826508;Lag: 0.07s, Heartbeat Lag: 0.38s, State: migrating;ETA: due []
2026-08-10 09:38:36 INFO Locking test.t_employee
2026-08-10 09:38:36 INFO Table test.t_employee locked
2026-08-10 09:38:36 INFO Writing changelog state: All Events Up To Lock Processed:1786325916621967439
2026-08-10 09:38:36 INFO Waiting for events up to lock
2026-08-10 09:38:36 INFO Intercepted changelog state Read Migration Range Values
2026-08-10 09:38:36 INFO Handled changelog state Read Migration Range Values
2026-08-10 09:38:36 INFO Intercepted changelog state All Events Up To Lock Processed
2026-08-10 09:38:36 INFO Handled changelog state All Events Up To Lock Processed
2026-08-10 09:38:37 INFO Waiting for events up to lock: got All Events Up To Lock Processed:1786325916621967439
2026-08-10 09:38:37 INFO Done waiting for events up to lock;duration=868.107724ms
Migrating P0.P1; Ghost table is P2.P3
Migrating 127.0.0.1:2883; inspecting 127.0.0.1:2883; executing on i Zbp 1dolvurzctg 3ubygce Z
Migration started at Mon Aug 10 09:38:34 +0800 2026
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.test.t_employee.sock
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 3s(total), 0s(copy);streamer: my-bin.000001:6833094;Lag: 0.08s, Heartbeat Lag: 0.38s, State: migrating;ETA: due
2026-08-10 09:38:37 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 3s(total), 0s(copy);streamer: my-bin.000001:6833094;Lag: 0.08s, Heartbeat Lag: 0.38s, State: migrating;ETA: due []
2026-08-10 09:38:37 INFO Locking test._t_employee_gho
2026-08-10 09:38:37 INFO Table test._t_employee_gho locked
2026-08-10 09:38:37 INFO Setting RENAME timeout as 3 seconds
2026-08-10 09:38:37 INFO Issuing and expecting this to block: rename / gh-ost / table P0.P1 to P2.P3, P4.P5 to P6.P7
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 3s(total), 0s(copy);streamer: my-bin.000001:6833566;Lag: 0.08s, Heartbeat Lag: 0.30s, State: migrating;ETA: due
2026-08-10 09:38:37 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 3s(total), 0s(copy);streamer: my-bin.000001:6833566;Lag: 0.08s, Heartbeat Lag: 0.30s, State: migrating;ETA: due []
2026-08-10 09:38:37 INFO Tables renamed
2026-08-10 09:38:37 INFO Unlocking tables
2026-08-10 09:38:37 INFO Tables unlocked
2026-08-10 09:38:37 INFO Writing changelog state: Migrated
[2026/08/10 09:38:37] [info] binlogsyncer.go:206 syncer is closing…
[2026/08/10 09:38:37] [info] binlogsyncer.go:906 kill last connection id 311801
[2026/08/10 09:38:37] [info] binlogsyncer.go:236 syncer is closed
2026-08-10 09:38:37 INFO Closed streamer connection. err=
2026-08-10 09:38:37 INFO Dropping table P0.P1
2026-08-10 09:38:37 INFO Table dropped
2026-08-10 09:38:37 INFO Dropping table P0.P1
2026-08-10 09:38:37 ERROR Error 1146 (42S 02): Table ‘test._t_employee_ghc’ doesn’t exist
2026-08-10 09:38:38 ERROR Error 1146 (42S 02): Table ‘test._t_employee_ghc’ doesn’t exist
2026-08-10 09:38:38 ERROR Error 1146 (42S 02): Table ‘test._t_employee_ghc’ doesn’t exist
2026-08-10 09:38:38 INFO Table dropped
2026-08-10 09:38:38 INFO Done migrating P0.P1
2026-08-10 09:38:38 INFO Removing socket file: /tmp/gh-ost.test.t_employee.sock
2026-08-10 09:38:38 INFO Tearing down inspector
2026-08-10 09:38:38 INFO Tearing down applier
2026-08-10 09:38:38 INFO Tearing down streamer
2026-08-10 09:38:38 INFO Tearing down throttler
测试2:
修改列类型
gh-ost \
--host=127.0.0.1 --port=2883 \ --user="root@my_test" --password="aa AA 11__ob" \ --database="lx" --table="t_order" \ --alter="MODIFY COLUMN user_id int UNSIGNED NOT NULL COMMENT '用户ID-改为无符号'" \ --assume-rbr --aliyun-rds --skip-foreign-key-checks \ --allow-on-master \ --cut-over=default \ --initially-drop-ghost-table --initially-drop-old-table --ok-to-drop-table \ --chunk-size=1000 --verbose \ --execute
结果:
2026-08-10 09:42:47 INFO starting gh-ost unversioned (git commit: unknown)
2026-08-10 09:42:47 INFO Migrating P0.P1
2026-08-10 09:42:47 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
2026-08-10 09:42:47 INFO inspector connection validated on 127.0.0.1:2883
2026-08-10 09:42:47 INFO User has ALL privileges
2026-08-10 09:42:47 INFO binary logs validated on 127.0.0.1:2883
2026-08-10 09:42:47 INFO Inspector initiated on 127.0.0.1:2883, version 5.7.25-Ocean Base_CE-v 4.3.5.3
2026-08-10 09:42:48 INFO Table found. Engine=oceanbase
2026-08-10 09:42:48 WARNING –skip-foreign-key-checks provided: will not check for foreign keys []
2026-08-10 09:42:48 INFO Estimated number of rows via EXPLAIN: 0
2026-08-10 09:42:48 INFO Recursively searching for replication master
2026-08-10 09:42:48 INFO Master found to be 127.0.0.1:2883
2026-08-10 09:42:48 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
2026-08-10 09:42:48 INFO streamer connection validated on 127.0.0.1:2883
[2026/08/10 09:42:48] [info] binlogsyncer.go:173 create Binlog Syncer with config {Server ID:99999 Flavor:my Host:127.0.0.1 Port:2883 User:root@my_test Password: Localhost: Charset: Semi Sync Enabled:false Raw Mode Enabled:false TLSConfig: Parse Time:false Timestamp String Location:UTC Use Decimal:true Recv Buffer Size:0 Heartbeat Period:0s Read Timeout:0s Max Reconnect Attempts:0 Disable Retry Sync:false Verify Checksum:false Dump Command Flag:0 Option: Logger:0xc 0000b 8900 Dialer:0x 68f 940 Rows Event Decode Func: Discard GTIDSet:false}
2026-08-10 09:42:48 INFO Connecting binlog streamer at my-bin.000001:6838078
[2026/08/10 09:42:48] [info] binlogsyncer.go:410 begin to sync binlog from position (my-bin.000001, 6838078)
2026-08-10 09:42:48 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
[2026/08/10 09:42:48] [info] binlogsyncer.go:813 rotate to (my-bin.000001, 6838078)
2026-08-10 09:42:48 INFO rotate to next log from my-bin.000001:0 to my-bin.000001
2026-08-10 09:42:48 INFO applier connection validated on 127.0.0.1:2883
2026-08-10 09:42:48 INFO Ocean Base connection identified, version_comment: Ocean Base_CE 4.3.5.3 (r 103020012025120120-de 5425fc 0077d 196353e 20b 011045b 8c 2d 7d 5514) (Built Dec 1 2025 20:46:46)
2026-08-10 09:42:48 INFO applier connection validated on 127.0.0.1:2883
2026-08-10 09:42:48 INFO will use time_zone=’+08:00′ on applier
2026-08-10 09:42:48 INFO Examining table structure on applier
2026-08-10 09:42:48 INFO Applier initiated on 127.0.0.1:2883, version 5.7.25-Ocean Base_CE-v 4.3.5.3
2026-08-10 09:42:48 INFO Dropping table P0.P1
2026-08-10 09:42:48 INFO Table dropped
2026-08-10 09:42:48 INFO Dropping table P0.P1
2026-08-10 09:42:48 INFO Table dropped
2026-08-10 09:42:48 INFO Dropping table P0.P1
2026-08-10 09:42:48 INFO Table dropped
2026-08-10 09:42:48 INFO Creating changelog table P0.P1
2026-08-10 09:42:49 INFO Changelog table created
2026-08-10 09:42:49 INFO Creating ghost table P0.P1
2026-08-10 09:42:49 INFO Ghost table created
2026-08-10 09:42:49 INFO Altering ghost table P0.P1
2026-08-10 09:42:56 INFO Ghost table altered
2026-08-10 09:42:56 INFO Waiting for ghost table to be migrated. Current lag is 0s
2026-08-10 09:42:56 INFO Intercepted changelog state Ghost Table Migrated
2026-08-10 09:42:56 INFO Handled changelog state Ghost Table Migrated
2026-08-10 09:42:56 INFO Chosen shared unique key is PRIMARY
2026-08-10 09:42:56 INFO Shared columns are order_id,user_id,order_no,amount,status,pay_time,remark,extra,created_at
2026-08-10 09:42:56 INFO Listening on unix socket file: /tmp/gh-ost.test.t_order.sock
2026-08-10 09:42:56 INFO Migration min values: []
2026-08-10 09:42:56 INFO Migration max values: []
2026-08-10 09:42:56 INFO Waiting for first throttle metrics to be collected
2026-08-10 09:42:56 INFO First throttle metrics collected
Migrating P0.P1; Ghost table is P2.P3
Migrating 127.0.0.1:2883; inspecting 127.0.0.1:2883; executing on i Zbp 1dolvurzctg 3ubygce Z
Migration started at Mon Aug 10 09:42:47 +0800 2026
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.test.t_order.sock
2026-08-10 09:42:56 INFO Row copy complete
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 8s(total), 0s(copy);streamer: my-bin.000001:6838750;Lag: 0.14s, Heartbeat Lag: 9223372036.85s, State: migrating;ETA: due
2026-08-10 09:42:56 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 8s(total), 0s(copy);streamer: my-bin.000001:6838750;Lag: 0.14s, Heartbeat Lag: 9223372036.85s, State: migrating;ETA: due []
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 8s(total), 0s(copy);streamer: my-bin.000001:6838750;Lag: 0.14s, Heartbeat Lag: 9223372036.85s, State: migrating;ETA: due
2026-08-10 09:42:56 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 8s(total), 0s(copy);streamer: my-bin.000001:6838750;Lag: 0.14s, Heartbeat Lag: 9223372036.85s, State: migrating;ETA: due []
2026-08-10 09:42:56 INFO Locking test.t_order
2026-08-10 09:42:56 INFO Table test.t_order locked
2026-08-10 09:42:56 INFO Writing changelog state: All Events Up To Lock Processed:1786326176679732974
2026-08-10 09:42:56 INFO Waiting for events up to lock
2026-08-10 09:42:56 INFO Intercepted changelog state Read Migration Range Values
2026-08-10 09:42:56 INFO Handled changelog state Read Migration Range Values
2026-08-10 09:42:57 INFO Intercepted changelog state All Events Up To Lock Processed
2026-08-10 09:42:57 INFO Handled changelog state All Events Up To Lock Processed
2026-08-10 09:42:57 INFO Waiting for events up to lock: got All Events Up To Lock Processed:1786326176679732974
2026-08-10 09:42:57 INFO Done waiting for events up to lock;duration=900.42462ms
Migrating P0.P1; Ghost table is P2.P3
Migrating 127.0.0.1:2883; inspecting 127.0.0.1:2883; executing on i Zbp 1dolvurzctg 3ubygce Z
Migration started at Mon Aug 10 09:42:47 +0800 2026
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.test.t_order.sock
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 9s(total), 0s(copy);streamer: my-bin.000001:6845871;Lag: 0.04s, Heartbeat Lag: 0.34s, State: migrating;ETA: due
2026-08-10 09:42:57 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 9s(total), 0s(copy);streamer: my-bin.000001:6845871;Lag: 0.04s, Heartbeat Lag: 0.34s, State: migrating;ETA: due []
2026-08-10 09:42:57 INFO Locking test._t_order_gho
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 9s(total), 0s(copy);streamer: my-bin.000001:6845871;Lag: 0.04s, Heartbeat Lag: 0.34s, State: migrating;ETA: due
2026-08-10 09:42:57 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 9s(total), 0s(copy);streamer: my-bin.000001:6845871;Lag: 0.04s, Heartbeat Lag: 0.34s, State: migrating;ETA: due []
2026-08-10 09:42:57 INFO Table test._t_order_gho locked
2026-08-10 09:42:57 INFO Setting RENAME timeout as 3 seconds
2026-08-10 09:42:57 INFO Issuing and expecting this to block: rename / gh-ost / table P0.P1 to P2.P3, P4.P5 to P6.P7
2026-08-10 09:42:58 INFO Tables renamed
2026-08-10 09:42:58 INFO Unlocking tables
2026-08-10 09:42:58 INFO Tables unlocked
2026-08-10 09:42:58 INFO Writing changelog state: Migrated
[2026/08/10 09:42:58] [info] binlogsyncer.go:206 syncer is closing…
[2026/08/10 09:42:58] [info] binlogsyncer.go:906 kill last connection id 311808
[2026/08/10 09:42:58] [info] binlogsyncer.go:236 syncer is closed
2026-08-10 09:42:58 INFO Closed streamer connection. err=
2026-08-10 09:42:58 INFO Dropping table P0.P1
2026-08-10 09:42:58 INFO Table dropped
2026-08-10 09:42:58 INFO Dropping table P0.P1
2026-08-10 09:42:58 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 10s(total), 0s(copy);streamer: my-bin.000001:6849436;Lag: 0.04s, Heartbeat Lag: 0.64s, State: migrating;ETA: due
2026-08-10 09:42:58 INFO Copy: 0/0 100.0%;Applied: 0;Backlog: 0/1000;Time: 10s(total), 0s(copy);streamer: my-bin.000001:6849436;Lag: 0.04s, Heartbeat Lag: 0.64s, State: migrating;ETA: due []
2026-08-10 09:42:58 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
2026-08-10 09:42:58 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
2026-08-10 09:42:58 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
2026-08-10 09:42:58 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
2026-08-10 09:42:58 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
2026-08-10 09:42:58 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
2026-08-10 09:42:59 ERROR Error 1146 (42S 02): Table ‘test._t_order_ghc’ doesn’t exist
2026-08-10 09:42:59 INFO Table dropped
2026-08-10 09:42:59 INFO Done migrating P0.P1
2026-08-10 09:42:59 INFO Removing socket file: /tmp/gh-ost.test.t_order.sock
2026-08-10 09:42:59 INFO Tearing down inspector
2026-08-10 09:42:59 INFO Tearing down applier
2026-08-10 09:42:59 INFO Tearing down streamer
2026-08-10 09:42:59 INFO Tearing down throttler
迁移完成后注意事项
1.复原租户参数 :
ALTER SYSTEM SET enable_lock_priority = 'false';
2.确认新表结构对路,场景无异常。
3.检查可否残留临时表:
SHOW
TABLES
LIKE
‘%_gho’
;
SHOW
TABLES
LIKE
‘%_ghc’
;
SHOW
TABLES
LIKE
‘%_del’
;
若有残留可手动 DROP。
欢迎在评论区留言交流,后续我们会延续分享更多实操运营维护干货,假如在运维流程中遇到难题。
ID:1836