Thursday, February 17, 2022

MySQL 8 Master-Slave Replication - Step by Step

 in This Tutorial you will Learn " How To Configure MySQL 8 Master-Slave Replication ( General Master-Slave settings ) on Rocky Linux 8"

MySQL replication is a process that allows you to automatically copy data from one database server to one or more servers.
Homepage - https://dev.mysql.com/
________________________________________________________________________________________
Server - Os:  Rocky Linux 8.5  64Bit      | IP -192.168.1.60        |Hostname - server.yourdomain.com
_________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf module -y install mysql:8.0
systemctl start mysqld ; systemctl enable --now mysqld
mysql_secure_installation

gedit /etc/my.cnf.d/mysql-server.cnf &>/dev/null
log-bin=mysql-bin
server-id=101
plugin-load=mysql_clone.so
character-set-server=utf8mb4

mysql -u root -p
create user 'repl_user'@'%' identified by 'password';
grant replication slave on *.* to repl_user@'%';
create user 'clone_user'@'%' identified by 'password';
grant backup_admin on *.* to 'clone_user'@'%';
flush privileges;
exit

firewall-cmd --add-service=mysql --permanent ; firewall-cmd --reload
systemctl restart mysqld ; systemctl status mysqld
*************************************************************************************************************************************
Slave Host - IP 192.168.1.80/www.example.com
_________________________________________________________________________________________
cat /etc/system-release ; hostname ; hostname -I ; dnf groupinstall "Development Tools" -y
dnf module -y install mysql:8.0
systemctl start mysqld ; systemctl enable --now mysqld
mysql_secure_installation

gedit /etc/my.cnf.d/mysql-server.cnf &>/dev/null
log-bin=mysql-bin
server-id=102
read_only=1
plugin-load=mysql_clone.so
character-set-server=utf8mb4
report-host=www.example.com

mysql -u root -p
create user 'clone_user'@'%' identified by 'password';
grant clone_admin on *.* to 'clone_user'@'%';
flush privileges;
exit
firewall-cmd --add-service=mysql --permanent ; firewall-cmd --reload
systemctl restart mysqld ; systemctl status mysqld

mysql -u root -p
set global clone_valid_donor_list = '192.168.1.60:3306';
clone instance from clone_user@192.168.1.60:3306 identified by 'password';
select ID,STATE,SOURCE,DESTINATION,BINLOG_FILE,BINLOG_POSITION from performance_schema.clone_status;

change master to
master_host='192.168.1.60',
master_ssl=1,
master_log_file='mysql-bin.000001',
master_log_pos=1345;
start slave user='repl_user' password='password';
show slave status\G
_________________________________________________________________________________________

No comments:

Post a Comment