gh-ost 示例
gh-ost \
--host=127.0.0.1 --port=3306 \
--user=root --password=secret \
--database=app --table=items \
--alter="ADD COLUMN category VARCHAR(64) NULL" \
--execute
pt-online-schema-change 示例
pt-online-schema-change \
--alter "ADD INDEX idx_name(name)" \
D=app,t=items --execute
验证与注意
- 确认外键与触发器影响
- 在从库或影子表验证后再执行生产
- 观察复制延迟与回放情况
总结
在线 DDL 工具能在高可用场景下平滑变更,需严格演练与监控。

发表评论 取消回复