pt-online-schema-change 语法
pt-online-schema-change \
--alter "MODIFY COLUMN buy_price decimal(10,2) NULL DEFAULT NULL COMMENT '进货价格' AFTER supplier_id, \
MODIFY COLUMN sell_price decimal(10,2) NULL DEFAULT NULL COMMENT '售货价格' AFTER buy_price" \
--dry-run \
h=localhost,u=root,p=Waglo127net.,S=/data/mysql/misc/mysql.sock,D=minipos,t=comm_inv_log
gh-os语法:当前版本是(1.1.7)不支持mysql8.4 执行的时候报错:
2025-10-17 19:45:38 INFO starting gh-ost 1.1.7 (git commit: d5ab048c1f046821f3c7384a386fc1c3ae399c92)
2025-10-17 19:45:38 INFO Migrating `minipos`.`comm_inv_log`
2025-10-17 19:45:38 INFO inspector connection validated on 127.0.0.1:3306
2025-10-17 19:45:38 INFO User has SUPER, REPLICATION SLAVE privileges, and has ALL privileges on `minipos`.*
2025-10-17 19:45:38 INFO binary logs validated on 127.0.0.1:3306
2025-10-17 19:45:38 INFO Inspector initiated on devops:3306, version 8.4.2
2025-10-17 19:45:38 INFO Table found. Engine=InnoDB
2025-10-17 19:45:38 DEBUG Estimated number of rows via STATUS: 25447962
2025-10-17 19:45:38 DEBUG Validated no foreign keys exist on table
2025-10-17 19:45:38 DEBUG Validated no triggers exist on table
2025-10-17 19:45:38 INFO Estimated number of rows via EXPLAIN: 25448007
2025-10-17 19:45:38 DEBUG Potential unique keys in comm_inv_log: [PRIMARY (auto_increment): [id]; has nullable: false]
2025-10-17 19:45:38 INFO Recursively searching for replication master
2025-10-17 19:45:38 DEBUG Looking for master on 127.0.0.1:3306
2025-10-17 19:45:38 ERROR Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'slave status' at line 1
2025-10-17 19:45:38 INFO Tearing down inspector
2025-10-17 19:45:38 FATAL Error 1064 (42000): You have an error in your SQL syntax; check the manual that corresponds to your MySQL server version for the right syntax to use near 'slave status' at line 1
MySQL 8.4+ 的语法变更:从 MySQL 8.4 LTS 开始,移除了 SHOW SLAVE STATUS、START SLAVE、STOP SLAVE 等命令,改用新的语法:
SHOW SLAVE STATUS → SHOW REPLICA STATUS
START SLAVE → START REPLICA
STOP SLAVE → STOP REPLICA
gh-ost 版本兼容性:你使用的 gh-ost 1.1.7 版本尚未适配 MySQL 8.4+ 的这些新语法
gh-ost --user="xiaozhang" --password="xxx" --host="127.0.0.1" --port=3306 --database="mis" --table="comm_inv_log" --alter="MODIFY COLUMN buy_price decimal(11,2) NULL DEFAULT NULL COMMENT '进货价格' AFTER supplier_id, MODIFY COLUMN sell_price decimal(11,2) NULL DEFAULT NULL COMMENT '售货价格' AFTER buy_price" --allow-on-master --assume-rbr --max-load=Threads_running=30 --critical-load=Threads_running=100 --chunk-size=1000 --max-lag-millis=1500 --cut-over=default --panic-flag-file=/tmp/ghost.panic.flag --postpone-cut-over-flag-file=/tmp/ghost.postpone.flag --execute --debug