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

Detailed steps of MySQL master-slave replication

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

Share

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

The following is about the detailed steps of master-slave copy of MySQL building. The secret of the text is that it is close to the topic. So, no gossip, let's go straight to the following, I believe you will benefit from reading the detailed steps of the MySQL builder.

To build MySQL master / slave replication, you need to prepare in advance:

Primary CVM IP:192.168.177.128

1IP:192.168.177.151 from CVM

2IP:192.168.177.152 from CVM

Set up MySQL master-slave synchronization:

Primary CVM:

1. Turn on time synchronization

Systemctl stop firewalld.service / / close the firewall setenforce 0 yum-y install ntp / / install ntp vim / etc/ntp.conf / / add the following 2 lines server 127.127.177.0 / / Local clock source / / fudge 127.127.177.0 stratum 8 / / set the time level to 8 (limited to 15) / / systemctl restart ntpd.service / / restart the ntpd service Here, I pretend to be mysql5.5. I have installed it before, so you can read my previous blog. Mysqladmin-u root password 'abc123' / / set the password for the root user after installation

Vim / etc/my.cnf / / enter the configuration file

Server-id = 11

Log-bin=master-bin / / Master CVM log file / /

Log-slave-updates=true / / Update binary logs from CVM / /

Systemctl restart mysqld.service / / restart the service

3. Enter mysql

Mysql-u root-p abc123

Slave CVM (the configuration of the two slave CVM is exactly the same):

1. Turn on time synchronization

Yum install ntp ntpdate-y / / install ntp

Systemctl start ntpd.service / / enable ntpd service

Systemctl stop firewalld.service / / turn off the firewall

Setenforce 0

/ usr/sbin/ntpdate 192.168.177.128 / / for time synchronization, enter the address of the primary CVM / /

two。 Install mysql

I installed mysql5.5 here, I have installed it before, you can read my previous blog. Mysqladmin-u root password 'abc123' / / set the password for the root user after installation

Vim / etc/my.cnf

Server-id = 22

Relay-log=relay-log-bin / / synchronize log files from the primary cloud server to the local / /

Relay-log-index=slave-relay-bin.index / / define the location and name of the relay-log / /

Systemctl restart mysqld.service / / restart the service

3. Enter mysql

Mysql-u root-p abc123

There is another CVM that I will not configure here, and the other one is exactly the same as this one.

Verify master-slave synchronization:

In the primary CVM (192.168.177.128): create a new database

In the slave CVM (192.168.177.151): see if there is a newly created database

Above, verify master-slave synchronization

Is there anything you don't understand about the detailed steps of MySQL master-slave replication above? Or if you want to know more about it, you can continue to follow our industry information section.

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