Selectively skipping the replication of binlog events
Sometimes, we want to skip replicating certain events to our replication slave servers. MariaDB lets us do this dynamically.
Getting ready
For this recipe, we'll assume that we've set up replication as described in either the Setting up replication or Using multisource replication recipes earlier in this chapter. Pick a master server and a slave server to use. In this recipe, we'll call db01
as the master server and db03
as the slave server.
How to do it...
On
db01
, launch themysql
command-line client and run the following command to turn on replication skipping:SET @@skip_replication=1;
On
db01
, create an empty database:CREATE DATABASE w;
On
db03
, run the following commands to turn off replication of skipped events:STOP SLAVE; SET GLOBAL REPLICATE_EVENTS_MARKED_FOR_SKIP = FILTER_ON_MASTER; START SLAVE;
On
db01
, create another empty database:CREATE DATABASE wx;
On
db03
, switch to filtering on the slave:STOP SLAVE; SET GLOBAL REPLICATE_EVENTS_MARKED_FOR_SKIP...