Book Image

MariaDB Cookbook

By : Daniel Bartholomew
Book Image

MariaDB Cookbook

By: Daniel Bartholomew

Overview of this book

Table of Contents (20 chapters)
MariaDB Cookbook
Credits
About the Author
About the Reviewers
www.PacktPub.com
Preface
Index

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...

  1. On db01, launch the mysql command-line client and run the following command to turn on replication skipping:

    SET @@skip_replication=1;
    
  2. On db01, create an empty database:

    CREATE DATABASE w;
    
  3. 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;
    
  4. On db01, create another empty database:

    CREATE DATABASE wx;
    
  5. On db03, switch to filtering on the slave:

    STOP SLAVE;
    SET GLOBAL REPLICATE_EVENTS_MARKED_FOR_SKIP...