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

How to build mysql Master-Slave Server on centos7

2025-02-24 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Servers >

Share

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

This article will explain in detail how to build a mysql master-slave server on centos7. The editor thinks it is very practical, so I share it with you as a reference. I hope you can get something after reading this article.

one。 Install from the virtual machine:

1. Right-click-> manage-> Clone

two。 Select full Clone

3. Modify the location of the virtual machine, default under C disk.

4. When the cloning is completed, there will be two virtual machines. Since the cloned two servers, the ip is the same, you need to modify the slave service virtual machine ip

5. Modify the configuration of the slave service virtual machine and open the configuration file

If you don't know which configuration file is, you can find it in the following way

6. Find the following red line and change the ip address. Here, I change 150 to 151:

7. After the modification is completed, restart

8. Use xShell to connect to newly configured virtual machines

two。 Configure the mysql primary service:

No matter which project, 80% are mainly reading. Therefore, it is generally required that the configuration of the slave library is higher than that of the master library.

For the configuration of the main database, the main thing is to turn on the binlog log.

1. Enter the mysql view status:

As you can see, the execution result is empty, so you need to open the binlog log.

two。 Locate the configuration file for mysql:

Vi / etc/my.cnf

3. Add binlog logs to the configuration file

4. Save and restart after modification:

5. Go to mysql and execute the command just now. When you can see this information, it proves that the binlog log is opened successfully.

For master-slave replication, it is essentially a synchronization through redoing with the binlog log files copied from the slave database with the master database; but be sure to ensure that the same version of the database is installed on the master-slave server as far as possible, and set the ip address of the master-slave server to 192.168.189.150. The ip address of the slave server is 192.168.189.151.

Then set up an account for replication on the primary server and grant replication slave permission.

5. Create an account for replication:

The account and password I set up here are all repl_151.

6. The creation is successful and there is no permission yet, so the next step is to provide a copy permission.

At this point, our main library is configured; you can use show master status to see if the binlog log has changed. You can also use show binlog events in 'mysql-bin.000001'; to see what we just did.

three。 Configure the slave library:

The main operation for the slave library is to configure synchronous log files (relay logs).

1. Open the configuration file: vi / etc/my.cnf

You need to set the id of the service, where the relay log needs to be put, and define the index file of the relay log (but not write)

two。 Because it is a clone, it will cause the uuid of the service to be the same. Execute these lines of commands to empty the uuid in the auto.cnf

3. Next, you want to specify the information of the master library and the slave library.

4. Start start slave

5. When you see that the two red lines are framed with yes, it indicates that the configuration has been successfully completed.

This is the end of the article on "how to build a mysql master-slave server on centos7". I hope the above content can be of some help to you, so that you can learn more knowledge. if you think the article is good, please share it for more people to see.

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

Servers

Wechat

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

12
Report