Geen cache-versie.

Caching uitgeschakeld. Standaardinstelling voor deze pagina:ingeschakeld (code DEF204)
Als het scherm te langzaam is, kunt u de gebruikersmodus uitschakelen om de cacheversie te bekijken.

Rechercher dans le manuel MySQL

15.18 InnoDB and MySQL Replication

MySQL replication works for InnoDB tables as it does for MyISAM tables. It is also possible to use replication in a way where the storage engine on the slave is not the same as the original storage engine on the master. For example, you can replicate modifications to an InnoDB table on the master to a MyISAM table on the slave. For more information see, Section 17.3.4, “Using Replication with Different Master and Slave Storage Engines”.

For information about setting up a new slave for a master, see Section 17.1.2.6, “Setting Up Replication Slaves”, and Section 17.1.2.5, “Choosing a Method for Data Snapshots”. To make a new slave without taking down the master or an existing slave, use the MySQL Enterprise Backup product.

Transactions that fail on the master do not affect replication at all. MySQL replication is based on the binary log where MySQL writes SQL statements that modify data. A transaction that fails (for example, because of a foreign key violation, or because it is rolled back) is not written to the binary log, so it is not sent to slaves. See Section 13.3.1, “START TRANSACTION, COMMIT, and ROLLBACK Syntax”.

Replication and CASCADE.  Cascading actions for InnoDB tables on the master are replicated on the slave only if the tables sharing the foreign key relation use InnoDB on both the master and slave. This is true whether you are using statement-based or row-based replication. Suppose that you have started replication, and then create two tables on the master using the following CREATE TABLE statements:

  1.     i INT PRIMARY KEY,
  2.     j INT
  3.  
  4.     m INT PRIMARY KEY,
  5.     n INT,
  6.     FOREIGN KEY ni (n) REFERENCES fc1 (i)
  7.         ON DELETE CASCADE

Suppose that the slave does not have InnoDB support enabled. If this is the case, then the tables on the slave are created, but they use the MyISAM storage engine, and the FOREIGN KEY option is ignored. Now we insert some rows into the tables on the master:

  1. master> INSERT INTO fc1 VALUES (1, 1), (2, 2);
  2. Query OK, 2 rows affected (0.09 sec)
  3. Records: 2  Duplicates: 0  Warnings: 0
  4.  
  5. master> INSERT INTO fc2 VALUES (1, 1), (2, 2), (3, 1);
  6. Query OK, 3 rows affected (0.19 sec)
  7. Records: 3  Duplicates: 0  Warnings: 0

At this point, on both the master and the slave, table fc1 contains 2 rows, and table fc2 contains 3 rows, as shown here:

  1. master> SELECT * FROM fc1;
  2. +---+------+
  3. | i | j    |
  4. +---+------+
  5. | 1 |    1 |
  6. | 2 |    2 |
  7. +---+------+
  8. 2 rows in set (0.00 sec)
  9.  
  10. master> SELECT * FROM fc2;
  11. +---+------+
  12. | m | n    |
  13. +---+------+
  14. | 1 |    1 |
  15. | 2 |    2 |
  16. | 3 |    1 |
  17. +---+------+
  18. 3 rows in set (0.00 sec)
  19.  
  20. slave> SELECT * FROM fc1;
  21. +---+------+
  22. | i | j    |
  23. +---+------+
  24. | 1 |    1 |
  25. | 2 |    2 |
  26. +---+------+
  27. 2 rows in set (0.00 sec)
  28.  
  29. slave> SELECT * FROM fc2;
  30. +---+------+
  31. | m | n    |
  32. +---+------+
  33. | 1 |    1 |
  34. | 2 |    2 |
  35. | 3 |    1 |
  36. +---+------+
  37. 3 rows in set (0.00 sec)

Now suppose that you perform the following DELETE statement on the master:

  1. master> DELETE FROM fc1 WHERE i=1;
  2. Query OK, 1 row affected (0.09 sec)

Due to the cascade, table fc2 on the master now contains only 1 row:

  1. master> SELECT * FROM fc2;
  2. +---+---+
  3. | m | n |
  4. +---+---+
  5. | 2 | 2 |
  6. +---+---+
  7. 1 row in set (0.00 sec)

However, the cascade does not propagate on the slave because on the slave the DELETE for fc1 deletes no rows from fc2. The slave's copy of fc2 still contains all of the rows that were originally inserted:

  1. slave> SELECT * FROM fc2;
  2. +---+---+
  3. | m | n |
  4. +---+---+
  5. | 1 | 1 |
  6. | 3 | 1 |
  7. | 2 | 2 |
  8. +---+---+
  9. 3 rows in set (0.00 sec)

This difference is due to the fact that the cascading deletes are handled internally by the InnoDB storage engine, which means that none of the changes are logged.


Zoek in de MySQL-handleiding

Nederlandse vertaling

U hebt gevraagd om deze site in het Nederlands te bezoeken. Voor nu wordt alleen de interface vertaald, maar nog niet alle inhoud.

Als je me wilt helpen met vertalingen, is je bijdrage welkom. Het enige dat u hoeft te doen, is u op de site registreren en mij een bericht sturen waarin u wordt gevraagd om u toe te voegen aan de groep vertalers, zodat u de gewenste pagina's kunt vertalen. Een link onderaan elke vertaalde pagina geeft aan dat u de vertaler bent en heeft een link naar uw profiel.

Bij voorbaat dank.

Document heeft de 26/06/2006 gemaakt, de laatste keer de 26/10/2018 gewijzigd
Bron van het afgedrukte document:https://www.gaudry.be/nl/mysql-rf-innodb-and-mysql-replication.html

De infobrol is een persoonlijke site waarvan de inhoud uitsluitend mijn verantwoordelijkheid is. De tekst is beschikbaar onder CreativeCommons-licentie (BY-NC-SA). Meer info op de gebruiksvoorwaarden en de auteur.

Referenties

  1. Bekijk - html-document Taal van het document:en Manuel MySQL : https://dev.mysql.com/

Deze verwijzingen en links verwijzen naar documenten die geraadpleegd zijn tijdens het schrijven van deze pagina, of die aanvullende informatie kunnen geven, maar de auteurs van deze bronnen kunnen niet verantwoordelijk worden gehouden voor de inhoud van deze pagina.
De auteur Deze site is als enige verantwoordelijk voor de manier waarop de verschillende concepten, en de vrijheden die met de referentiewerken worden genomen, hier worden gepresenteerd. Vergeet niet dat u meerdere broninformatie moet doorgeven om het risico op fouten te verkleinen.

Inhoudsopgave Haut