How to configure MariaDB Active-Backup Replication in Linux (with Scenario-Based Example)



How to configure MariaDB Active-Backup Replication in Linux (with Scenario-Based Example)

How to configure MariaDB Active-Backup Replication in Linux (with Scenario-Based Example)

In this tutorial, you will learn how to configure MariaDB Active-Backup Replication in Enterprise Linux. It includes MariaDB Master Configuration, Slave Configuration and some database related SQLs has been also included in this video.

Configuration and Commands as follows 👇👇👇

#################
# MASTER SERVER #
#################
vi /etc/my.cnf.d/server.conf

[mariadb-10.5]
log-bin
server_id=1
log-basename=master1
binlog-format=mixed

systemctl restart mariadb

SHOW MASTER STATUS;

CREATE USER ‘replication_user’@’backup_hostname’ IDENTIFIED BY ‘password’;

GRANT REPLICATION SLAVE ON *.* TO ‘replication_user’@’backup_hostname’;

firewall-cmd –permanent –add-service=mysql
firewall-cmd –reload

#########################
# BACKUP (Slave) SERVER #
#########################

vi /etc/my.cnf.d/server.conf
[mariadb-10.5]
log-bin
server_id=2
log-basename=master2
binlog-format=mixed

SHOW SLAVE STATUS G;

CHANGE MASTER TO
MASTER_HOST=’active_hostname’,
MASTER_USER=’replication_user’,
MASTER_PASSWORD=’password’,
MASTER_PORT=3306,
MASTER_LOG_FILE=’bin-file’,
MASTER_LOG_POS=position,
MASTER_CONNECT_RETRY=10;

START SLAVE;

SHOW SLAVE STATUS G;

##################
# creating table #
##################
CREATE TABLE `tbl_users` (
`id` int ,
`txt_username` varchar(100) ,
`txt_password` varchar(255) ,
`fullname` varchar(100) ,
`is_active` boolean NOT NULL) ;

##########################
# insert data into table #
##########################
insert into tbl_users (id, txt_username, txt_password, fullname, is_active) VALUES
(1, ‘user1’, ‘password1’, ‘Test User 1’, TRUE),
(2, ‘user2’, ‘password2’, ‘Test User 2’, FALSE);