Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

MariaDB 10.3 Master-Slave replication

2025-03-04 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

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:

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report