The difference between Mysql "cluster" and "master-slave"


  1. Mysql cluster: share-nothing, a storage solution for distributed node architecture in order 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 node (multiple), data node (multiple), management node (one), and synchronous replication is used 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, and the slave begins to prepare for 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 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 will send a commit message to all Slaves to tell the Slaves to submit the transaction; if the Master receives an ABORT message from any Slave, It sends an ABORT message to all slaves, telling the slaves 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 will commit the transaction and send a confirmation that the transaction has been committed to the Master; if the slaves receive a cancellation request, they will undo all changes and release the resources occupied, thereby aborting the transaction, and then sending a message to the Masterv Send confirmation that the transaction has been aborted. 
    f) After the Master receives confirmations from all Slaves, it will report that the transaction is committed (or aborted), and then proceed to 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 single-machine mysql. Therefore, mysql cluster is required to run in a local area network of more than gigabit, the nodes can use dual network cards, and the direct connection mode is used between node groups. 
    write picture description here

  2. Master-Slave: Just install mysql community (normal version) on the master-slave machine. 
    Data consistency is ensured between master and slave through mysql replication. Compared with the data synchronization method of mysql cluster, it is asynchronous. 
    Replication: The master node needs to open binlog and set a unique server id (unique in the local area network); the slave node sets the server id, and binlog records all operations on the master, which will be copied to the relaylog of the slave node and played back on the slave node. 
    write picture description here

    4.

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=325783273&siteId=291194637