当前位置:网站首页>MySQL master-slave replication
MySQL master-slave replication
2022-07-23 10:28:00 【amateur12】
Data can be obtained from a MySQL The database server master node is replicated to one or more slave nodes .
The master server is only responsible for writing , The slave server is only responsible for reading
species :
Master slave synchronization : When the user writes data, the master server must synchronize with the slave server to tell the user that the writing is successful , The waiting time is long .
Master slave asynchrony : As long as the user accesses the master server for writing data , Return to the user immediately .
Master slave semi synchronous : When the user accesses and writes data, the master server writes and synchronizes one of the slave servers, and then returns success to the user .
principle :
Data modification and writing master Database binlog in .
slave Of IO Threads copy these changes binlog To your own relay log in .
slave Of SQL The thread reads and reapplies relay log To your own database , Let it go together master Database consistency .
Log files :
Error log (error log): Record mysql Right and wrong information when starting and stopping the service , It also records the start of 、 stop it 、 Error messages during operation .
Query log (general log): Record established client connections and executed statements .
Binary log (bin log): Record all statements that change data , Can be used for Data replication .
Slow query log (slow log): Record all execution times over long_query_time All queries of or queries without index .
relay logs (relay log): Master slave copy Log used when .
advantage :
Provides the ability to separate reading and writing , send MySQL The database supports high concurrent read and write
It can improve the security of data , Effectively protect the data backup of physical server downtime
Insufficient :
Master-slave delay , Damage disaster tolerance , Because the data is out of sync
The reason for the master-slave delay
1、TPS When high , Produced DDL The quantity exceeds Slave One SQL Thread processing capability
2、Slave Medium and large Query Lock waiting occurs
How to judge whether there is a master-slave delay
show slave status -> Seconds_Behind_Master
How to avoid master-slave delay
1、 close Slave Of sync_binlog
2、 close Slave Of innodb_flushlog
3、 Performance ratio Master Better machines as Slave
4、 Set up one that does not provide query service Slave
5、 increase Slave The number of , Lower the unit Slave Reading pressure on
Interview answer :
MySQL It is a small and medium-sized relational database , It's based on Multithreading .
There are some bottlenecks in data storage and query speed , Read write separation is one of the solutions .
Main library write , Read from library .
Hang up the main warehouse , From the library, you can go up , Avoid the loss of downtime .
The principle of data synchronization is ,
Data modification and writing master Database binlog in .
slave Of IO Threads copy these changes binlog To your own relay log in .
slave Of SQL The thread reads and reapplies relay log To your own database , Let it go together master Database consistency .
There are also shortcomings. , There are delays and increased hardware purchase costs
The forms are ,
A master from
One master, many followers
Load Balancer ,
According to the algorithm , Which one to test MySQL Low pressure , Distribute the request to this station MySQL
Be similar to nginx Proxy service for
It can only relieve certain pressure , But it can't be cured .
Better than that redis, Memory based operations , Single threaded , Fast query speed .
边栏推荐
- [Internet of vehicles prototype system II] database + application layer protocol design
- 【代码案例】网页版表白墙 & 待办事项 (包含完整源码)
- 数仓:工作流的设计以及优化实践
- mysql通过sql查询数据库所有表名称及列信息
- SSH supermarket inventory management system
- 2022/7/22
- C language -- several classic exercises of C language
- Android development learning diary - content provider (cross application database modification)
- 你离个人信息泄漏的安全距离,或许一台笔记本电脑就可以决定!
- EasyCVR平台CGO回放回调参数缺失导致设备录像无法播放,该如何解决?
猜你喜欢

【车联网原型系统|二】数据库+应用层协议设计

无套路、无陷阱、无广告 | 这个免费的即时通讯软件确定不用吗?

Customer first | domestic Bi leader, smart software completes round C financing

Deeply understand mvcc and bufferpool caching mechanism

SSH supermarket inventory management system

宇视NVR设备接入EasyCVR平台,离线后无法上线该如何解决?
![[c#] IEnumerable可枚举类型接口分析yield](/img/08/8c346ce257b4adc0bea80bf05b6f52.png)
[c#] IEnumerable可枚举类型接口分析yield

Anaconda source change and opencv installation

22、wpf之Combobox使用小记

32.< tag-数组和位运算>补充: lt.剑指 Offer 56 - I. 数组中数字出现的次数
随机推荐
比你老师详细系列————结构体
redis的事务、锁机制、秒杀
百度沈抖:聚焦场景深耕行业,为企业数字化带来实际成效
Richview textbox items textbox
Special training - linked list
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(一))
7.< tag-动态规划和买卖股票合集>lt.121. 买卖股票的最佳时机 + lt.122.买卖股票的最佳时机 II+ lt.123. 买卖股票的最佳时机 III dbc
CS5266+MA8621做TYPEC转HDMI+PD+U3+2U+SD/TF七合一拓展坞方案设计|CS5266多口拓展坞PCB+原理图参考
SeekTiger的Okaleido有大动作,生态通证STI会借此爆发?
32-spark的分区算子介绍、广播变量和累加器
Android development learning diary - content provider (cross application database modification)
ArcGIS calculates the correlation between two grid layers
[azure event center] try new functions of azure event hub -- geo disaster recovery
Jeecgboot import document
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(九))
金仓数据库 KingbaseES SQL 语言参考手册 (8. 函数(六))
Rapid SQL All-Platforms高性能 SQL 代码
Bosch Bosch EDI project case
[circular statement]
Redis安装