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! You may also be interested in:
|
<<: Analyze how to automatically generate Vue component documentation
>>: Software Testing - MySQL (VI: Database Functions)
webkit scrollbar style reset 1. The scrollbar con...
This article shares with you how to import Excel ...
NAT In this way, the virtual machine's networ...
I recently took over a small program project, and...
Table of contents need: Main points: According to...
MySQL installation is relatively simple, usually ...
Volume Label, Property Name, Description 002 <...
Preface With the crazy speculation of virtual cur...
The configuration method of MySQL 5.5.56 free ins...
Effect picture: 1. Introduction Your own applet n...
This article uses examples to illustrate the basi...
Preface The original project was placed on the pu...
Preface: rm under Linux system is irreversible. T...
The future of CSS is so exciting: on the one hand,...
1. Components and implemented functions Keepalive...