配置mysql sync_binlog 和innodb_flush_log_at_tx_commit导致主从数据不一致

有两种配置情况可能导致主从数据不一致

sync_binlog=1 innodb_flush_log_at_tx_commit=0

当commit时数据写到binlog当时并没有写到redolog 时 系统crash。此时从库已经拿到binglog进行数据重做,但是主库重启后会回滚该事务,此时导致主从数据不一致.


sync_binlog=1 innodb_flush_log_at_tx_commit=2

此时binglog刷盘并在从库重做,但是主库的redolog 只是写到log中,但是写没有刷盘,所以还是主库没有执行事务,但是从库执行了事务导致数据不一致。


你可能感兴趣的:(mysql,Crash)