Basic information
Server 1:mariadb01 192.168.10.178
Server 2:MARIADB02 192.168.10.179
Operating system: CentOS 6.4
Database version: MariaDB-10.3.7
Master-Slave Relationship: MariaDB01-based, MariaDB02 from
MariaDB01
1. Modify the configuration file
Vi/etc/my.cnf.d/server.cnf
Under [Mysqld], add the following
Server-id = 1
Log-bin = Mysql-bin
2. Restart the MySQL service
Service MySQL Restart
3. View Master Status
4. Create a master-slave connection account and authorization
CREATE USER ' repl ' @ ' 192.168.10.% ' identified by ' 123456 ';
GRANT REPLICATION SLAVE on * * to ' repl ' @ ' 192.168.10.% ';
5. Turn off the firewall
Service Iptables Stop
Chkconfig iptables off
MariaDB02
1. Modify the configuration file
Vi/etc/my.cnf.d/server.cnf
Under [Mysqld], add the following
Server-id = 2
Log-bin = Mysql-bin
2. Restart the MySQL service
Service MySQL Restart
3. Create a master-slave connection account and authorization
CREATE USER ' repl ' @ ' 192.168.10.% ' identified by ' 123456 ';
GRANT REPLICATION SLAVE on * * to ' repl ' @ ' 192.168.10.% ';
4. Turn off the firewall
Service Iptables Stop
Chkconfig iptables off
5. Establish a master-slave connection
Change MASTER to master_host= ' 192.168.10.178 ', master_user= ' repl ', master_password= ' 123456 ', master_log_file= ' Mysql-bin.000001 ', master_log_pos=328;
Start slave;
Test Master-slave replication
1. Master and slave service all normal, create database
MARIADB01, Main:
MariaDB02, from:
2. Main normal, from close, create table
MARIADB01, Master
After the master has finished creating the table, start from the library
MariaDB02, from:
MariaDB 10.3 Master-slave replication