当前位置:网站首页>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
边栏推荐
- 力扣515.在每棵树行中找最大值
- This keyword details
- extern “C“概述
- What is a consistent hash? What scenarios can it be applied to?
- 炒股开户在手机上安全吗?
- ROS rviz_ Satellite function package visualizes GNSS track and uses satellite map
- 强化学习——格子世界
- Linux MySQL implements root user login without password
- Exception handling (I) -- null pointer and array index out of bounds
- 文件头信息对照表
猜你喜欢
Boost the rising point | yolov5 combined with alpha IOU
Overview, implementation and use of CRC32
The code is correct, and the rendering page does not display the reason
JS regular expression system explanation (comprehensive summary)
fpm工具安装
How bacnet/ip gateway collects data of building centralized control system
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
编译配置in文件
FPGA - 7系列 FPGA SelectIO -09- 高级逻辑资源之IO_FIFO
金山云团队分享 | 5000字读懂Presto如何与Alluxio搭配
随机推荐
[online tutorial] official iptables tutorial -- learning notes 1
【星海出品】 运维巡检合集
KMP string
Freeswitch uses origin to dialplan
Trie string statistics
选拔赛题目代码
Students who do not understand the code can also send their own token. The current universal dividend model can be divided into BSC and any generation B
CRC32概述以及实现和使用
Note that JPA uses a custom VO to receive jpql query results
文件头信息对照表
@RequestParam
微信小程序分页功能,下拉刷新功能,直接干货拿来就用
创建格式化时间,格式化时区的gson对象。json解析时间格式化 ZonedDateTime
freeswitch设置最大呼叫时长
Tryout title code
Voice network VQA: make the user's subjective experience of unknown video quality in real-time interaction known
整型提升和大小端字节序
Rust FFI programming - libc crate
普歌 -- getOrDefault()方法理解
freeswitch使用mod_shout模块播放mp3