How to build mysql master-slave server on centos7 (graphic tutorial)

How to build mysql master-slave server on centos7 (graphic tutorial)

This article mainly introduces how to build a MySQL master-slave server on centos. If you haven't built it before, you can check my previous blog, which contains detailed instructions for installing centos and installing mysql on centos.

1. Install from a virtual machine:

1. Right click -> Manage -> Clone

2. Select full clone

3. Change the location of the virtual machine, which is on the C drive by default.

4. After the cloning is completed, there will be two virtual machines. Since the IP addresses of the two cloned servers are the same, the IP address of the slave virtual machine needs to be modified;

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

If you don't know which configuration file it is, you can find it as follows:

6. Find the red line below and modify the IP address. I changed 150 to 151:

7. After the modification is completed, restart

8. Use xShell to connect to the newly configured virtual machine

2. Configure the mysql master service:

No matter which project, 80% of it is based on reading. Therefore, the configuration of the slave database is generally required to be higher than that of the master database.

For the configuration of the main database, the main thing is to enable binlog logging.

1. Enter mysql to view the status:

As you can see, the result of the execution is empty, so you need to turn on binlog logging;

2. Find the mysql configuration file:

vi /etc/my.cnf

3. Add binlog log in the configuration file

4. Save and restart after modification:

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

For master-slave replication, in essence, it is to copy the binlog log files of the master database with the slave database and achieve synchronization through redo; but you must pay attention to ensure that the same version of the database is installed on the master and slave servers, and set the server IP address of the master and slave to 192.168.189.150 and the IP address of the slave server to 192.168.189.151.

Then set up an account for replication on the master server and grant replication slave permissions.

5. Create an account for copying:

The account and password I set here are repl_151

6. Creation is successful, but there is no permission yet, so the next step is to provide a copy permission

At this point, our master database configuration is complete; you can use show master status to check whether the binlog log has changed. You can also use show binlog events in 'mysql-bin.000001'; to view the operations we just performed.

3. Configure the slave library:

The operation on the slave library is mainly to configure the synchronization log file (relay log).

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

You need to set the service ID, where the relay log needs to be placed, and define the index file of the relay log (optional).

2. Since it is cloned, the uuid of the service will be the same. Execute these commands to clear the uuid in auto.cnf;

3. Next, specify the information of the master and slave libraries


4. Start slave;

5. When you see the two red-lined areas are both "yes", it means the configuration has been successful;

Summarize

The above is what I introduced to you about building MySQL master-slave service on centos7. I hope it will be helpful to you. If you have any questions, please leave me a message and I will reply to you in time. I would also like to thank everyone for their support of the 123WORDPRESS.COM website!
If you find this article helpful, please feel free to reprint it and please indicate the source. Thank you!

You may also be interested in:
  • How to build MySQL master-slave replication and read-write separation on CentOS server platform
  • MySQL master-slave synchronization configuration method under CentOS server environment
  • Configuration example of specifying master-slave synchronization of MySQL database server under Linux
  • Detailed steps for implementing one-way master-slave backup of MySql database under Windows server
  • Special issues with mysql master-slave server configuration
  • Simple configuration of mysql master-slave server
  • My experience of MySQL master-slave server synchronization
  • MySQL configuration master-slave server (one master and multiple slaves)

<<:  Analyze how to automatically generate Vue component documentation

>>:  Software Testing - MySQL (VI: Database Functions)

Recommend

HTML Form Tag Tutorial (4):

Suppose now you want to add an item like this to ...

mysql5.7.19 zip detailed installation process and configuration

MySQL v5.7.19 official version (32/64 bit install...

Tutorial on how to install htop on CentOS 8

If you are looking to monitor your system interac...

How to implement on-demand import and global import in element-plus

Table of contents Import on demand: Global Import...

MySQL 8.0.21 installation tutorial with pictures and text

1. Download the download link Click download. You...

Detailed explanation of efficient MySQL paging

Preface Usually, a "paging" strategy is...

Introduction and use of Javascript generator

What is a generator? A generator is some code tha...

JavaScript deshaking and throttling examples

Table of contents Stabilization Throttling: Anti-...

How to control the proportion of Flex child elements on the main axis

background Flex layout achieves alignment and spa...

Native js drag and drop function to create a slider example code

Drag and drop is a common function in the front e...

Detailed tutorial on installing MySQL 8.0 from source code on CentOS 7.4

Table of contents 1. Environment 2. Preparation 3...

Continuous delivery using Jenkins and Docker under Docker

1. What is Continuous Delivery The software produ...