A brief introduction to mysql cluster (picture)
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
1 |
|
1 |
|
1 |
|
五、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!

Hot AI Tools

Undresser.AI Undress
AI-powered app for creating realistic nude photos

AI Clothes Remover
Online AI tool for removing clothes from photos.

Undress AI Tool
Undress images for free

Clothoff.io
AI clothes remover

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

Hot Article

Hot Tools

Notepad++7.3.1
Easy-to-use and free code editor

SublimeText3 Chinese version
Chinese version, very easy to use

Zend Studio 13.0.1
Powerful PHP integrated development environment

Dreamweaver CS6
Visual web development tools

SublimeText3 Mac version
God-level code editing software (SublimeText3)

Hot Topics





You can open phpMyAdmin through the following steps: 1. Log in to the website control panel; 2. Find and click the phpMyAdmin icon; 3. Enter MySQL credentials; 4. Click "Login".

MySQL is an open source relational database management system, mainly used to store and retrieve data quickly and reliably. Its working principle includes client requests, query resolution, execution of queries and return results. Examples of usage include creating tables, inserting and querying data, and advanced features such as JOIN operations. Common errors involve SQL syntax, data types, and permissions, and optimization suggestions include the use of indexes, optimized queries, and partitioning of tables.

MySQL's position in databases and programming is very important. It is an open source relational database management system that is widely used in various application scenarios. 1) MySQL provides efficient data storage, organization and retrieval functions, supporting Web, mobile and enterprise-level systems. 2) It uses a client-server architecture, supports multiple storage engines and index optimization. 3) Basic usages include creating tables and inserting data, and advanced usages involve multi-table JOINs and complex queries. 4) Frequently asked questions such as SQL syntax errors and performance issues can be debugged through the EXPLAIN command and slow query log. 5) Performance optimization methods include rational use of indexes, optimized query and use of caches. Best practices include using transactions and PreparedStatemen

MySQL is chosen for its performance, reliability, ease of use, and community support. 1.MySQL provides efficient data storage and retrieval functions, supporting multiple data types and advanced query operations. 2. Adopt client-server architecture and multiple storage engines to support transaction and query optimization. 3. Easy to use, supports a variety of operating systems and programming languages. 4. Have strong community support and provide rich resources and solutions.

Apache connects to a database requires the following steps: Install the database driver. Configure the web.xml file to create a connection pool. Create a JDBC data source and specify the connection settings. Use the JDBC API to access the database from Java code, including getting connections, creating statements, binding parameters, executing queries or updates, and processing results.

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

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.

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
