Home Database Mysql Tutorial A brief introduction to mysql cluster (picture)

A brief introduction to mysql cluster (picture)

Mar 11, 2017 pm 02:10 PM

1. What isMySQLCluster

MySQL cluster is a shared-nothing, distributed node architecture storage scheme, which is designed to provide fault tolerance and high performance.

Data update uses the read-committed isolation level to ensure the consistency of data on all nodes, and uses the two-phase commit mechanism (two-phasedcommit) to ensure that all nodes have the same data (if any If the write operation fails, the update fails).

Shared-nothing peer nodes make update operations on one server immediately visible on other servers. Propagating updates uses a complex communication mechanism designed to provide high throughput across the network.

Distribute the load through multiple MySQL servers to maximize program performance and ensure high availability and redundancy by storing data in different locations.

## 2. Architecture diagram



#3. How to store data
##1. The master-slave synchronization in the Mysqlcluster data node group uses synchronous replication to ensure the consistency of node data in the group. Generally implemented through a two-phase commit protocol, the general working process is as follows:

a) When the Master executes the commit statement, the transaction is sent to the slave, and the slave begins to prepare for the submission of the transaction.

b) Each slave must prepare a transaction, and then send an OK (or ABORT) message to the master, indicating that the transaction is ready (or the transaction cannot be prepared).

c) Master waits for all Slaves to send OK or ABORT messages

If the Master receives OK messages from all Slaves, it will send Slave sends a commit message to tell Slave to submit the transaction;

If the Master receives an ABORT message from any Slave, it sends an ABORT message to all Slave to tell the Slave to abort the transaction.

e) Each Slave waits for an OK or ABORT message from the Master.

If the Slave receives a commit request, they will submit the transaction and send a confirmation that the transaction has been submitted to the Master;

If the Slave receives Upon receiving a cancellation request, they will undo all changes and release the occupied resources, thus aborting the transaction, and then send confirmation to Masterv that the transaction has been aborted.

f) When the Master receives confirmation from all Slaves, it will report that the transaction has been committed (or aborted), and then continue with the next transaction.

Since synchronous replication requires a total of 4 message transfers, the data update speed of mysql cluster is slower than that of stand-alone mysql. Therefore, mysql cluster is required to run in a LAN of Gigabit or above. The nodes can use dual network cards and the node groups must be directly connected.


Question: Will expanding the cluster and adding data node groups cause the data update speed to decrease?

Answer: No, the data update speed will be faster. Because the data is processed separately, the data stored in each node group is different,

can also reduce locking.

2.Mysqlcluster stores all index columns in main memory, and other non-index columns can be stored in memory or stored on disk by creating a table space. If the data changes (insert, update, delete, etc.), the mysql cluster writes the changed records to the redo log, and then regularly writes the data to the disk through checkpoints. Because redo logs are committed asynchronously, a small number of transactions may be lost during a failure. In order to reduce transaction loss, MySQL Cluster implements delayed writes (default delay of two seconds, configurable), so that checkpoint writes can be completed when a failure occurs without losing the last checkpoint. Generally, the failure of a single data node will not cause any data loss because synchronous data replication is used within the cluster.

4.MySQL Horizontal expansion of the cluster

#1. Add a data node group to expand the write Operation to improve the storage capacity of the cluster. Online expansion is supported. First, add new nodes to clsuter. After starting, use the

ALTER ONLINE TABLE table_name REORGANIZE PARTITION

command to migrate data and distribute the data evenly to the data nodes.

2. Adding Slave only expands reading, but cannot achieve horizontal expansion of write operations.

The average load of the entire system can be described as:

AverageLoad=∑readload+ ∑writeload / ∑capacity
Copy after login

Assume that each server has 10,000 transactions per second, and the Master's write load per second is 4,000 transactions, and the read load per second The load is 6000, and the result is:


AverageLoad=6000+4000/10000=100%
Copy after login

Now, add 3 slaves, and the transaction volume per second increases to 40,000. Because write operations are also replicated, each write operation is executed 4 times, so the write load of each slave is 4000 transactions per second. Then the current load average is:


AverageLoad=6000+4*4000/ 4*10000=55%
Copy after login

五、MySQL Advantages and Disadvantages of Cluster

Advantages:

a) 99.999% high availability

b) Fast automatic failover

c) Flexible distributed architecture, no single point of failure

d )High throughput and low latency

e) Strong scalability, supports online expansion

Disadvantages:

a) There are many limitations, such as: foreign keys are not supported

b) Deployment, management, and configuration are complex

c) It takes up a lot of disk space and memory

d) Backup and recovery are inconvenient

e) When restarting, the data node will Loading into memory takes a long time

The above is the detailed content of A brief introduction to mysql cluster (picture). For more information, please follow other related articles on the PHP Chinese website!

Statement of this Website
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Tools

Notepad++7.3.1

Notepad++7.3.1

Easy-to-use and free code editor

SublimeText3 Chinese version

SublimeText3 Chinese version

Chinese version, very easy to use

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

Dreamweaver CS6

Dreamweaver CS6

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

MySQL's Role: Databases in Web Applications MySQL's Role: Databases in Web Applications Apr 17, 2025 am 12:23 AM

The main role of MySQL in web applications is to store and manage data. 1.MySQL efficiently processes user information, product catalogs, transaction records and other data. 2. Through SQL query, developers can extract information from the database to generate dynamic content. 3.MySQL works based on the client-server model to ensure acceptable query speed.

How to start mysql by docker How to start mysql by docker Apr 15, 2025 pm 12:09 PM

The process of starting MySQL in Docker consists of the following steps: Pull the MySQL image to create and start the container, set the root user password, and map the port verification connection Create the database and the user grants all permissions to the database

Laravel Introduction Example Laravel Introduction Example Apr 18, 2025 pm 12:45 PM

Laravel is a PHP framework for easy building of web applications. It provides a range of powerful features including: Installation: Install the Laravel CLI globally with Composer and create applications in the project directory. Routing: Define the relationship between the URL and the handler in routes/web.php. View: Create a view in resources/views to render the application's interface. Database Integration: Provides out-of-the-box integration with databases such as MySQL and uses migration to create and modify tables. Model and Controller: The model represents the database entity and the controller processes HTTP requests.

Solve database connection problem: a practical case of using minii/db library Solve database connection problem: a practical case of using minii/db library Apr 18, 2025 am 07:09 AM

I encountered a tricky problem when developing a small application: the need to quickly integrate a lightweight database operation library. After trying multiple libraries, I found that they either have too much functionality or are not very compatible. Eventually, I found minii/db, a simplified version based on Yii2 that solved my problem perfectly.

How to install mysql in centos7 How to install mysql in centos7 Apr 14, 2025 pm 08:30 PM

The key to installing MySQL elegantly is to add the official MySQL repository. The specific steps are as follows: Download the MySQL official GPG key to prevent phishing attacks. Add MySQL repository file: rpm -Uvh https://dev.mysql.com/get/mysql80-community-release-el7-3.noarch.rpm Update yum repository cache: yum update installation MySQL: yum install mysql-server startup MySQL service: systemctl start mysqld set up booting

Centos install mysql Centos install mysql Apr 14, 2025 pm 08:09 PM

Installing MySQL on CentOS involves the following steps: Adding the appropriate MySQL yum source. Execute the yum install mysql-server command to install the MySQL server. Use the mysql_secure_installation command to make security settings, such as setting the root user password. Customize the MySQL configuration file as needed. Tune MySQL parameters and optimize databases for performance.

Laravel framework installation method Laravel framework installation method Apr 18, 2025 pm 12:54 PM

Article summary: This article provides detailed step-by-step instructions to guide readers on how to easily install the Laravel framework. Laravel is a powerful PHP framework that speeds up the development process of web applications. This tutorial covers the installation process from system requirements to configuring databases and setting up routing. By following these steps, readers can quickly and efficiently lay a solid foundation for their Laravel project.

MySQL and phpMyAdmin: Core Features and Functions MySQL and phpMyAdmin: Core Features and Functions Apr 22, 2025 am 12:12 AM

MySQL and phpMyAdmin are powerful database management tools. 1) MySQL is used to create databases and tables, and to execute DML and SQL queries. 2) phpMyAdmin provides an intuitive interface for database management, table structure management, data operations and user permission management.

See all articles