当前位置:网站首页>MySQL master-slave replication, detailed configuration, create unable to connect processing prompt
MySQL master-slave replication, detailed configuration, create unable to connect processing prompt
2022-06-28 06:59:00 【Xiaobinbin &】
One 、 Implementation conditions :
Here is a demonstration of one-to-one master-slave replication , It is a master server , A slave server
Readers are required to install two virtual machines
Two 、 Master slave replication principle :
As shown in the figure below
1、 The data in the master server is added, deleted and modified , This operation will be saved in the log (Baniry log)
2、 The slave server will utilize IOThread The thread reads the log of the master server
3、IOThread Save the read information to the log in the slave server Relay log
4、SQLThread Read log SQL Statement to execute , This will change the data from the server

3、 ... and 、 The law of master-slave replication
1、 Addition, deletion and modification of data by the master server , Can affect the slave server The data on the
2、 The addition, deletion and modification of data from the server , It will not affect the primary server
3、 Simply speaking , The slave server in the form of master-slave replication only performs the query function
Four 、 Server settings
Master server setting
1、 Create a database for master-slave replication
create database abb;
2、 Open share permissions
grant replication slave on *.* to 'root'@'%' identified by 'ok'; / / Set the permissions
flush privileges; // Refresh the permissions
3、 To configure my.cnf file
1、 stay dos Interface input cd /etc/my.cnf
2、 Add configuration file
( Press a edit , Press ESC Exit the editor , Press : wq Exit the configuration file interface )
[mysqld]
server-id = 1 // Indicates the server number , Each server has a unique number , Can't repeat
log-bin = mysql-bin // Log name
binlog-do-db =abb // Database for sharing , Not writing means that all databases are shared
binlog-ignore-db = information_schema,mysql,performance_schema// Indicates that the synchronized database is not shared
3、 Restart the server
service mysql restart
4、 Check the status
Up reading lock flush tables with read lock;
Check the status show master status\G
Unlock unlock tables;
The view status is as follows ( remember Position Value , From the server )

Slaver Server configuration
1、 Create a database synchronized with the main service
create database abb;
2、 To configure my.cnf file
1、 stay dos Interface input cd /etc/my.cnf
2、 Add configuration file
( Press a edit , Press ESC Exit the editor , Press : wq Exit the configuration file interface )
[mysqld]
server-id = 2 // Cannot be the same as the main service
log-bin =mysql-bin // Log name
binlog-do-db =abb // Database for sharing , Not writing means that all databases are shared
binlog-ignore-db = information_schema,mysql,performance_schema// Indicates that the synchronized database is not shared
3、 Restart the server
service mysql restart
3、 Change the parameters of the primary server to which this server is connected
stop slave;
change master to
master_host='192.168.234.100',master_user='root',master_password='ok',
master_log_file='mysql-bin.000007',master_log_pos=120;// The parameters in turn are : Host number ( Of the main server IP)+ user name + password + The log of + Based on the same (position)
start slave;
4、 Check the status
Up reading lock flush tables with read lock;
Check the status show slave status\G
Unlock unlock tables;
The results of checking the status are as follows :
Slave_IO_Running and Slave_SQL_Running Must indicate open status

5、 ... and 、 How to handle the error report
1、 Check Slave_IO_Running and Slave_SQL_Running Is it in yes state
2、 In the main server Read_Master_Log_Pos And from the server position The value must be the same
3、 After the configuration file is changed , You have to restart the server service mysql restart
4、 Detect settings from the server Master Is the parameter correct
边栏推荐
猜你喜欢
随机推荐
《微信小程序-基础篇》带你了解小程序中的生命周期(一)
Interpretation of Blog
A small code editor can also run programs -- a summary of sublime Text3 running programs in various languages
手把手教你用Ucos
三极管驱动无刷电机
Yolov5 adds a small target detection layer
【星海出品】 运维巡检合集
最后的二十九天
剑指offer II 091.粉刷房子
语音增强-频谱映射
My MVVM open source project "travel epidemic prevention app" has been released
Eyebeam advanced settings
Puge -- understanding of getordefault() method
微信小程序编译页面空白bug的原因
The code is correct, and the rendering page does not display the reason
服务器正文18:UDP可靠传输的理解和思考(读云凤博客有感)
JS of learning notes -- split(), replace(), join()
KMP string
Will Internet talents be scarce in the future? Which technology directions are popular?
ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map








