Skip to main content

MariaDB replication demo

·261 words·2 mins
DevOps Databases
Alejandro Duarte
Author
Alejandro Duarte
Alejandro Duarte is a Software Engineer, published author, and award winner. He currently works for MariaDB plc as a Developer Relations Engineer. Starting his coding journey at 13 with BASIC on a rudimentary black screen, Alejandro quickly transitioned to C, C++, and Java during his academic years at the National University of Colombia. Relocating first to the UK and then to Finland, Alejandro deepened his involvement in the open-source community. He’s a recognized figure in Java circles, credited with articles and videos amassing millions of views, and presentations at international events.

Database replication is a process that copies data from one database (primary) to another (replica). This process can happen as data is inserted, modified, or deleted and also includes data definition modifications. With MariaDB, setting up replication requires activating the binary log in the primary database and configuring the replicas to automatically read the binary log from the primary.

Why do we replicate databases?
#

Imagine you have a web application that connects to a single-node database. The application is reading and writing data and, at some point, you realize that you need to scale. Maybe because you found that there are a lot of reads but just a few writes. Perhaps you want to load-balance reads to improve performance or availability. Maybe you want to run data analytics or backups in a separate node so you don’t impact production.

All these situations can be addressed by adding nodes that host the same data as the primary database. Keep in mind that there are other options. For example, multi-master replication allows your application to write to multiple nodes. Also Distributed SQLĀ enables unlimited scalability while keeping the strong consistency capabilities of relational databases.

How can I enable MariaDB replication?
#

If you just want to set up replication for a new fresh MariaDB server, you can just enable the binary log in the primary and configure the connection in the replica. However, if you are scaling an already deployed MariaDB database, you have to manually get a backup as well.

Here is a video that demonstrates how to enable MariaDB replication:

Related

Building a Kubernetes cluster on Raspberry Pi (with automation)
·652 words·4 mins
DevOps
Some months ago, I was lucky enough to get a bunch of Raspberry Pi minicomputers from MariaDB Corporation.
What is JPA?
·364 words·2 mins
Programming Databases
JPA stands for Jakarta Persistence API (previously, Java Persistence API). It’s an API specification for database connectivity in Java applications.
What is a database connection pool?
·258 words·2 mins
Programming Databases
A database connection pool stores ready-to-use database connections that threads can borrow when they need them, and return when they finish the work with the database.