Network Security Internet Technology Development Database Servers Mobile Phone Android Software Apple Software Computer Software News IT Information

In addition to Weibo, there is also WeChat

Please pay attention

WeChat public account

Shulou

What's the difference between mysql cluster and master-slave?

2025-01-19 Update From: SLTechnology News&Howtos shulou NAV: SLTechnology News&Howtos > Database >

Share

Shulou(Shulou.com)06/01 Report--

This article is about the difference between mysql cluster and master-slave. Xiao Bian thinks it is quite practical, so share it for everyone to make a reference. Let's follow the editor and have a look.

Oracle database has been used before, and only used, did not care about the database architecture, the current project uses mysql database, and to understand the design data storage architecture. So I looked at mysql's cluster and master/slave concepts. Both are easy to confuse, especially for beginners.

Mysql cluster: share-nothing, a storage scheme for distributed node architecture to provide fault tolerance and high performance.

The mysql cluster installation package is required and installed on each machine in the cluster.

There are three key concepts: Sql nodes (multiple), data nodes (multiple), management nodes (one), and synchronous replication between data nodes to ensure data consistency between nodes.

Synchronous replication:

a) When the Master executes the commit statement, the transaction is sent to the slave, which begins preparing the commit of the transaction.

b) Each slave prepares the transaction and then sends an OK(or ABORT) message to the master indicating that the transaction is ready (or that it cannot be prepared).

c) The Master waits for all Slaves to send OK or ABORT messages; if the Master receives OK messages from all Slaves, it sends commit messages to all Slaves telling them to commit the transaction; if the Master receives ABORT messages from any Slaves, it sends ABORT messages to all Slaves telling them to abort the transaction.

e) Each Slave waits for an OK or ABORT message from the Master. If the Slaves receive a commit request, they commit the transaction and send an acknowledgement to the Master that the transaction has committed; if the Slaves receive a cancel request, they abort the transaction by reversing all changes and releasing the resources they own, and then send an acknowledgement to the Masterv that the transaction has aborted.

f) When the Master receives acknowledgements from all Slaves, it reports that the transaction was committed (or aborted) and proceeds to the next transaction.

Since synchronous replication requires a total of four message transfers, mysql cluster data updates are slower than standalone mysql. Therefore, mysql cluster is required to run in a local area network with gigabit or more. Nodes can adopt dual network cards, and node groups adopt direct connection mode.

Master-Slave: Install mysql community (normal version) on the master-slave machine.

The consistency of data is ensured by replication of mysql between master and slave. Compared to mysql cluster data synchronization mode is asynchronous.

Replication: To enable binlog on the master node, set a unique server id (unique in the local area network); set the server id on the slave node. Binlog records all operations on the master node, which will be copied to the relaylog on the slave node and replayed on the slave node.

Thank you for reading! What is the difference between mysql cluster and master-slave is shared here. I hope the above content can be of some help to everyone so that everyone can learn more knowledge. If you think the article is good, you can share it so that more people can see it!

Welcome to subscribe "Shulou Technology Information " to get latest news, interesting things and hot topics in the IT industry, and controls the hottest and latest Internet news, technology news and IT industry trends.

Views: 0

*The comments in the above article only represent the author's personal views and do not represent the views and positions of this website. If you have more insights, please feel free to contribute and share.

Share To

Database

Wechat

© 2024 shulou.com SLNews company. All rights reserved.

12
Report