mysql 主从 ddl_gh-ost在线主从同步MySQL下DDL生产表结构修改(初步研究)

参考

主从同步过程省略。

启动主从同步

show processlist;

show master status;

记录Position,执行

change master to master_host='192.168.10.60',

master_port=3306,

master_user='slave',

master_password='123456',

master_log_file='mysql-bin.000002',

master_log_pos=1407;

启动主从同步

start slave;

开始在线DDL

gh-ost因为不需要使用触发器,gh-ost 把修改表定义的负载和正常的业务负载解耦开了。它不需要考虑被修改的表上的并发操作和竞争等,这些在二进制日志中都被序列化了,gh-ost 只操作临时表,完全与原始表不相干。事实上,gh-ost 也把行拷贝的写操作与二进制日志的写操作序列化了,这样,对主库来说只是有一条连接在顺序的向临时表中不断写入数据。

添加1个字段,奇怪的可以不填数据库root用户的密码,无需 --password="yourpassword"

./gh-ost --user="root" --host=192.168.10.60 --database="test" --table="tab" --alter="ADD COLUMN oneColumn varchar(10)" --allow-on-master --execute

即使在主次同步时也是可以执行的。在执行ghost复制的时候暂停了主从同步。

[root@hadoop001 home]#./gh-ost --user="root" --host=192.168.10.60 --database="test" --switch-to-rbr --table="tab" --alter="ADD COLUMN oneColumn varchar(10)" --allow-on-master --execute

[2020/07/21 23:01:35] [info] binlogsyncer.go:133 create BinlogSyncer with config {99999 mysql 192.168.10.60 3306 root false false false UTC true 0 0s 0s 0 false}

[2020/07/21 23:01:35] [info] binlogsyncer.go:354 begin to sync binlog from position (mysql-bin.000003, 28925)

[2020/07/21 23:01:35] [info] binlogsyncer.go:203 register slave for master server 192.168.10.60:3306[2020/07/21 23:01:35] [info] binlogsyncer.go:723 rotate to (mysql-bin.000003, 28925)#Migrating `test`.`tab`; Ghost table is `test`.`_tab_gho`#Migrating hadoop001:3306; inspecting hadoop001:3306; executing on hadoop001#Migration started at Tue Jul 21 23:01:35 +0800 2020#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.tab.sock

Copy: 0/22 0.0%; Applied: 0; Backlog: 0/1000; Time: 0s(total), 0s(copy); streamer: mysql-bin

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值