In addition to Weibo, there is also WeChat
Please pay attention
WeChat public account
Shulou
2025-01-16 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >
Share
Shulou(Shulou.com)06/01 Report--
The editor in this issue will bring you the steps of building mysql master and slave services in the cnetos7 system, and analyze and describe them from a professional point of view. I hope you can get something after reading this article.
one。 Install from the virtual machine:
1. Right-> manage-> Clone
2. Select a complete clone
3. Modify the location of the virtual machine, which is under C disk by default.
4. When the cloning is completed, there will be two virtual machines. Since the ip of the cloned two servers is the same, you need to modify the slave virtual machine ip.
5. Modify the configuration of the slave service virtual machine and open the configuration file
Vi / etc/sysconfig/network-scripts/ifcfg-ens33
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, change the address from 150to 151:
7. Restart after the modification is completed
Systemctl restart network
8. Use xShell to connect the newly configured virtual machine
2. Configure the mysql master 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:
Show master status
As you can see, the execution result is empty, so you need to open the binlog log.
2. Find the configuration file of mysql:
Vi / etc/my.cnf
3. Add binlog logs to the configuration file
Log-bin= mysql-binServer-id = 1
4. Save and restart after modification:
Service mysql restart
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:
Create user 'username'@'localhost' identified by' password'
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.
Grant replication slave on *. * to 'repl_151'@'%' identified by' repl_151'
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)
2. Because it is a clone, it will cause the uuid of the service to be the same. Execute these commands to empty the uuid in the auto.cnf.
3. Specify the information of the master library and the slave library
Change master to master_host= "192.168.189.150", master_port=3306, master_user= "repl_151", master_password= "repl_151", master_log_file= "mysql-bin.000001", master_log_pos=0
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.
These are the steps for building a mysql master-slave service in the cnetos7 system shared by the editor. If you have similar doubts, it will not hinder your understanding with reference to the above analysis. If you want to know more about it, please follow the industry information.
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.
Continue with the installation of the previous hadoop.First, install zookooper1. Decompress zookoope
"Every 5-10 years, there's a rare product, a really special, very unusual product that's the most un
© 2024 shulou.com SLNews company. All rights reserved.