search
HomeDatabaseMysql TutorialWhat are the three replication modes of Mysql master and slave?

MySQL Asynchronous Replication

MySQL asynchronous replication is the default replication mode during the master-slave replication process. Replication involves three threads, including the master I/O thread, the slave I/O thread, and the slave SQL thread. Because it is asynchronous replication, the submission of the master transaction does not need to be confirmed by the slave. That is, after the master I/O thread submits the transaction, it does not need to wait for the reply confirmation from the slave I/O thread. The master does not guarantee that the binlog will be written to the relay. in the log; after slave I/O writes the binlog to the relay log, it is asynchronously executed by the slave sql thread and applied to slave mysql. Slave I/O does not require reply confirmation from slave sql, and does not guarantee that the relay log is completely written. In mysql.

What are the three replication modes of Mysql master and slave?

Semi-synchronous replication

In order to make up for the shortcomings of traditional asynchronous replication, MySQL introduced semi-synchronous replication in version 5.5, which is an improvement over traditional asynchronous replication. . Before the master transaction is committed, it must be ensured that the binlog log has been written to the slave's relay log. Only after receiving the response from the slave to the master can the transaction be committed. Despite this, the second half of the relay log will still be passed to the sql thread for execution asynchronously.

What are the three replication modes of Mysql master and slave?

##Group Replication

Based on the defects of traditional asynchronous replication and semi-synchronous replication-data consistency cannot be guaranteed, MySQL official in 5.7. Version 17 officially launches group replication (MySQL Group Replication, referred to as MGR).

A replication group is composed of several nodes. The submission of a transaction must be resolved and approved by the majority of nodes in the group (N / 2 1) before it can be submitted. As shown in the figure above, a replication group consists of 3 nodes. The Consensus layer is the consistency protocol layer. During the transaction submission process, inter-group communication occurs. Only when 2 nodes resolve (certify) the transaction, the transaction can finally be resolved. Submit and respond.

The main purpose of introducing group replication is to solve the data inconsistency problem caused by traditional asynchronous replication or semi-synchronous replication. Group replication relies on the distributed consistency protocol (a variant of the Paxos protocol) to achieve the ultimate consistency of distributed data and provide a true data high availability solution (whether it is truly highly available remains to be discussed). The multi-write solution it provides brings hope to us to achieve a multi-active solution.

In the MGR environment, the number of servers must be more than 3 and an odd number to implement the 2/n 1 algorithm.

What are the three replication modes of Mysql master and slave?

A replication group consists of several nodes (database instances). Each node in the group maintains its own copy of data (Share Nothing), and implements atomic messages and Global ordered messages to achieve consistency of instance data within the group.

MGR’s solution now has features

Data consistency guarantee:Ensure that most nodes in the cluster receive logs

Node writing support: In multi-write mode, all nodes in the cluster can be written (but considering the 1 to high concurrency scenario to ensure high data consistency, production does not choose multi-master writing, use single master Cluster)

Fault Tolerance: Ensure that the system is still available when it fails (including split brain), and double writing has no impact on the system

The current impact of MGR's solution

  • Only supports InnoDB tables, and each table must have a primary key for conflict detection of write set;

  • The GTID feature must be turned on , the binary log format must be set to ROW, used for primary selection and write set

  • COMMIT may cause failure, similar to the failure scenario of the snapshot transaction isolation level

  • Currently, an MGR cluster supports up to 9 nodes

  • Does not support foreign keys and save point features, and cannot perform global constraint detection and partial rollback

  • Binary log does not support binlog event checksum

The above is the detailed content of What are the three replication modes of Mysql master and slave?. For more information, please follow other related articles on the PHP Chinese website!

Statement
This article is reproduced at:亿速云. If there is any infringement, please contact admin@php.cn delete
What Are the Limitations of Using Views in MySQL?What Are the Limitations of Using Views in MySQL?May 14, 2025 am 12:10 AM

MySQLviewshavelimitations:1)Theydon'tsupportallSQLoperations,restrictingdatamanipulationthroughviewswithjoinsorsubqueries.2)Theycanimpactperformance,especiallywithcomplexqueriesorlargedatasets.3)Viewsdon'tstoredata,potentiallyleadingtooutdatedinforma

Securing Your MySQL Database: Adding Users and Granting PrivilegesSecuring Your MySQL Database: Adding Users and Granting PrivilegesMay 14, 2025 am 12:09 AM

ProperusermanagementinMySQLiscrucialforenhancingsecurityandensuringefficientdatabaseoperation.1)UseCREATEUSERtoaddusers,specifyingconnectionsourcewith@'localhost'or@'%'.2)GrantspecificprivilegeswithGRANT,usingleastprivilegeprincipletominimizerisks.3)

What Factors Influence the Number of Triggers I Can Use in MySQL?What Factors Influence the Number of Triggers I Can Use in MySQL?May 14, 2025 am 12:08 AM

MySQLdoesn'timposeahardlimitontriggers,butpracticalfactorsdeterminetheireffectiveuse:1)Serverconfigurationimpactstriggermanagement;2)Complextriggersincreasesystemload;3)Largertablesslowtriggerperformance;4)Highconcurrencycancausetriggercontention;5)M

MySQL: Is it safe to store BLOB?MySQL: Is it safe to store BLOB?May 14, 2025 am 12:07 AM

Yes,it'ssafetostoreBLOBdatainMySQL,butconsiderthesefactors:1)StorageSpace:BLOBscanconsumesignificantspace,potentiallyincreasingcostsandslowingperformance.2)Performance:LargerrowsizesduetoBLOBsmayslowdownqueries.3)BackupandRecovery:Theseprocessescanbe

MySQL: Adding a user through a PHP web interfaceMySQL: Adding a user through a PHP web interfaceMay 14, 2025 am 12:04 AM

Adding MySQL users through the PHP web interface can use MySQLi extensions. The steps are as follows: 1. Connect to the MySQL database and use the MySQLi extension. 2. Create a user, use the CREATEUSER statement, and use the PASSWORD() function to encrypt the password. 3. Prevent SQL injection and use the mysqli_real_escape_string() function to process user input. 4. Assign permissions to new users and use the GRANT statement.

MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

See all articles

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 Article

Hot Tools

Zend Studio 13.0.1

Zend Studio 13.0.1

Powerful PHP integrated development environment

SublimeText3 Linux new version

SublimeText3 Linux new version

SublimeText3 Linux latest version

SAP NetWeaver Server Adapter for Eclipse

SAP NetWeaver Server Adapter for Eclipse

Integrate Eclipse with SAP NetWeaver application server.

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

DVWA

DVWA

Damn Vulnerable Web App (DVWA) is a PHP/MySQL web application that is very vulnerable. Its main goals are to be an aid for security professionals to test their skills and tools in a legal environment, to help web developers better understand the process of securing web applications, and to help teachers/students teach/learn in a classroom environment Web application security. The goal of DVWA is to practice some of the most common web vulnerabilities through a simple and straightforward interface, with varying degrees of difficulty. Please note that this software