当前位置:网站首页>Master-slave replication of MySQL

Master-slave replication of MySQL

2022-06-11 12:28:00 log. Info (Xiao Lu)

https://blog.csdn.net/bai_ye_/article/details/118851804

docker See here for details 
Mysql Master-slave architecture of   Can ease mysql Data storage and access pressure , Previous one mysql Nodes do both read and write operations 

 Now?   The master node performs write operations    Read from the node   This can improve the concurrency of the database and the pressure of the phase database 

 Insert picture description here

 If there are three MySQL, a mater Write only , Two sets of salve Only responsible for reading operations , Can't performance be greatly improved ?

 So master-slave replication 、 Read write separation is to support more concurrency in the database .

 Insert picture description here
 Insert picture description here

mysql  Of binlog  It's not just the master and the slave  , It can also be used to cache synchronization scenes ,
 such as canal   Can simulate a slave  node   towards mysql launch binlog Sync , Then drop the data into es  perhaps redis,
 Expansion of cluster construction   The master-slave synchronization we set up is aimed at the configuration of the whole database , In actual production , Sometimes we don't need training for the whole library , You only need to synchronize some particularly important libraries or tables 
 We need to do further configuration 

 Note that the flow direction of the configured read / write separation data is single   Only from m--->s,  That is, you can only synchronize from the master server to the slave server    The slave server cannot update to the master server ,mysql  It can only give us a master-slave architecture  
 But the specific read-write separation is implemented by our business   We can use  ShardingSphere

 Insert picture description here

 Cluster expansion   We are now 1 Lord 1 from , We now need to add from point , Achieve one master and many slaves  , We just need to add a node to 
binlog  Just copy 
 But our cluster has been running for some time   There will be a problem , Previous binlog There's no way to recover , Therefore, when we add a new node, we need to perform a data replication operation ,( Just synchronize the previous data to the new node )
 Semi-synchronous replication 
	 because mysql  Replication is asynchronous . It's in this Dump Thread send binlog The slave node is asynchronous 
 The master node feeds back the results to the client   I do not know!   At this time dump Whether the thread executes successfully ,  If the master node down Behind the machine  , The data has not been synchronized to the slave node ,  will   Data loss 

 Insert picture description here

 So there is a semi synchronous mechanism    The master node is written binlog After logging   Synchronize slave nodes  , Receive slave node ack  Respond to the client later 

 however   If from node 10s There's no response in   I will synchronize the client directly  ( Use asynchronous replication )

 Insert picture description here
 Insert picture description here

 The delay of master-slave replication 

 Insert picture description here

原网站

版权声明
本文为[log. Info (Xiao Lu)]所创,转载请带上原文链接,感谢
https://yzsam.com/2022/162/202206111208559478.html