Thursday, February 17, 2022

MariaDB 10 Replication on Rocky Linux 8.5

 in This Tutorial you wil Learn " How To Configure MariaDB Replication (General Primary-Replica settings. ) on Rocky Linux 8.5"
MariaDB is a fork of the MySQL database management system. Offcial site - https://mariadb.org/
_________________________________________________________________________________________
Master node (Rocky Linux 8.5 64 bit) : IP 192.168.1.60
Replica Hosts ( Slave node) - (Rocky Linux 8.5 bit) : IP 192.168.1.80
_________________________________________________________________________________________
cat /etc/system-release
dnf groupinstall "Development Tools" -y ; dnf module -y install mariadb:10.3
nano /etc/my.cnf.d/charset.cnf
[mysqld]
character-set-server = utf8mb4
[client]
default-character-set = utf8mb4
systemctl start mariadb ; systemctl enable --now mariadb ; mysql_secure_installation

nano /etc/my.cnf.d/mariadb-server.cnf
log-bin=mysql-bin
server-id=101
systemctl restart mariadb ; systemctl status mariadb
mysql -u root -p
grant replication slave on *.* to repl_user@'%' identified by 'password';
flush privileges;
exit

mkdir /home/mariadb_backup
mariabackup --backup --target-dir /home/mariadb_backup -u root -p password
firewall-cmd --add-service=mysql ; firewall-cmd --runtime-to-permanent
systemctl restart mariadb    
Transfer Dump-Data - Replica Hosts ( Slave node:)                      

+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Configure Replica Hosts ( Slave node:)
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
cat /etc/system-release
dnf groupinstall "Development Tools" -y ; dnf module -y install mariadb:10.3
nano /etc/my.cnf.d/charset.cnf
[mysqld]
character-set-server = utf8mb4
[client]
default-character-set = utf8mb4
systemctl start mariadb ; systemctl enable --now mariadb ; mysql_secure_installation
firewall-cmd --add-service=mysql ; firewall-cmd --runtime-to-permanent

nano /etc/my.cnf.d/mariadb-server.cnf
log-bin=mysql-bin
server-id=102
read_only=1
report-host=www.example.com
systemctl stop mariadb ; rm -rf /var/lib/mysql/*

mariabackup --prepare --target-dir /root/mariadb_backup
mariabackup --copy-back --target-dir /root/mariadb_backup
chown -R mysql. /var/lib/mysql
systemctl restart mariadb

cat /root/mariadb_backup/xtrabackup_binlog_info
mysql -u root -p
change master to
master_host='192.168.1.60',
master_user='repl_user',
master_password='password',
master_log_file='mysql-bin.000001',
master_log_pos=642;
start slave;
show slave status\G

stop slave;
start slave;
reset slave;
show slave status\G
_________________________________________________________________________________________

No comments:

Post a Comment