MariaDB 10.5支持基于binlog为ROW行的复制,触发器在slave从库上工作

在传统认知下,基于binlog为statement语句的复制,触发器会在slave从库上工作;而如果基于binlog为ROW行的复制,触发器不会在slave从库上工作。


With statement-based replication, triggers executed on the master also execute on the slave. With row-based replication, triggers executed on 
the master do not execute on the slave.

参考文献:https://dev.mysql.com/doc/refman/8.0/en/replication-features-triggers.html


在MariaDB 10.5版本里,可以通过参数

set global slave_run_triggers_for_rbr = 'ENFORCE';

强制设置基于binlog为ROW行的复制,触发器在slave从库上工作。


这样的好处是:当你在从库上运行pt-online-schema-change修改表结构时,从库的数据和主库是一致的,可以参考我2016年写的文章《pt-online-schema-change你今天滥用了吗?》


注:MySQL 8.0不支持。


猜你喜欢

转载自blog.51cto.com/hcymysql/2516579