MySQL BLACKHOLE Engine as Replication Filter



Today, I am going to tell very interesting use-case where we have used Blackhole engine as replication filter.

We have an Aurora Cluster(let's call it C1) where multiple db's are hosted and multiple applications are writing data into it. While in another project one application wanted to read the data from one of the db's hosted on aurora cluster C1 & this new project is hosted into another account.

Now the challenge is we don't want self hosted db which supports replication filters(replicate-do-db) and bring only one db while wanted to use aurora only to in the new project as per the company standards, But problem is Aurora DB doesn't support native replication filters So we were not able to setup replication.
To solve this problem we tried multiple approaches:

Approach 1: Introducing intermediate Slave with replication filters, But using this approach we were introducing more infra and node management and that too self hosted will DB.

Approach 2: Use AWS DMS service which is able to solve our problem easily, But it became quite costly.

Approach 3: Use Blackhole engine and replicate only desired DB. The BLACKHOLE storage engine acts as a “black hole” that accepts data but throws it away and does not store it. Retrievals always return an empty result. This approach is quite cool which is using MySQL native replication and not introducing any new tool in between so less management of infra and nodes.
We followed below steps to setup:

Step 1: Create a new aurora cluster(let's call it C2) from C1 cluster snapshots while don't setup replication from C1.

Step 2: Take full DB dump of DB we want to restore and schema dump for rest of the DB's from C2 and restore on the cluster where new project has to be pointed.

Step 3: alter all the tables and set engine to blackhole except DB we want to replicate.

Step 4: Start replication from co-ordinates found during aurora creation.

And we are done.

Comments

Post a Comment

Popular posts from this blog

Shell/Bash Commands Execution from MySQL Client or Stored Procedure/function

How to remove/deregister an instance from PMM?

Azure VM Application Consistent MySQL DB Disk Snapshots