mysql (5): sub-table from the master copy and the sub-library

Master-slave replication cluster

Concept : copying means from the main data can be copied from a master node to a MySQL database server from one or more nodes.

Usage scenarios :

  1. Separate read and write: use master-slave replication, so that the main library is responsible for writing, reading from the library responsible, so that even if the main library scene appeared lock table by reading from the library can guarantee the normal operation of the business.
  2. Real-time data backup: When a node fails the system can be easily failover.
  3. High Availability High Availability
  4. Extended Architecture: increasing the plurality of data storage nodes, the load distribution from the plurality of nodes to reduce the frequency of single disk I / O access, to improve I / O performance of a single machine.

From the main form :

  1. A master-slave
  2. A master multi-slave: improve reading performance
  3. From a multi-master: mysql database backup into a plurality of relatively good performance of the storage server
  4. Dual-master replication: interaction from copying shots, each server is both a master, and a slave in another server. Changes made by either party, the other party will be applied to the database through replication.
  5. Cascading replication: synchronous data portion of the slave master node is not connected, but are connected from the node. Not only can ease the pressure of the master node, and no negative impact on data consistency.

Copy the master-slave principle

Relates to the master copy from three threads running in a master node (log dump thread), the remaining two (I / O thread, SQL thread) running from the node.

Copy the master-slave principle

When connecting the master node from the master node creates a log dump thread for bin-log of content transmission. In a read operation of bin-log, bin-log on this thread will lock the master node. Once the event is finished reading the thread, the lock will be released and sent to the event completely from the library before, the lock will be released even in.

When executed from the node start slaveafter the command, the node creates an I / O thread is used to connect the master node, the request to update the master library bin-log. After the update I / O thread receives the master node sent the log dump process, stored in the local relay-log.

SQL thread is responsible for reading the content relay log in, resolve into concrete action and execution, and ultimately ensure the consistency of data from the master.

For each master-slave connection, it requires three processes to complete. When there are multiple nodes master node from the master node to a binary log dump process from each node to build a current connection, and from each node has its own I / O processes, SQL processes.

Sub-library sub-table strategy

Data segmentation scheme

Data segmentation rules

Data Segmentation Principle

Sub-library sub-table to solve the problem

Distributed Transaction issues
Distributed primary key ID issue
Cross-database join issue
Cross-database count, order by, group by problems

Mycat cluster

Architecture Introduction

Core Concepts

10 common fragmentation rules

https://blog.csdn.net/kingice1014/article/details/76136337

Mycat cluster structures and sub-library sub-table application

Mycat provided separate read and write

Guess you like

Origin www.cnblogs.com/angelica-duhurica/p/11304949.html