MariaDB 10.3 Master-Slave replication
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 is master, MariaDB02 is slave
MariaDB01
1. Modify the configuration file
Vi / etc/my.cnf.d/server.cnf
Add the following under [mysqld]
Server-id = 1
Log-bin = mysql-bin
two。 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
Add the following under [mysqld]
Server-id = 2
Log-bin = mysql-bin
two。 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. All master and slave services are normal. Create a database.
MariaDB01, main:
MariaDB02, from:
two。 Master is normal, slave is closed, create table
MariaDB01, Lord
After the master has created the table, start the slave library
MariaDB02, from: