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:
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:
- Query OK, 2 rows affected (0.09 sec)
- Query OK, 3 rows affected (0.19 sec)
At this point, on both the master and the slave, table
fc1
contains 2 rows, and table
fc2
contains 3 rows, as shown here:
- +---+------+
- | i | j |
- +---+------+
- | 1 | 1 |
- | 2 | 2 |
- +---+------+
- +---+------+
- | m | n |
- +---+------+
- | 1 | 1 |
- | 2 | 2 |
- | 3 | 1 |
- +---+------+
- +---+------+
- | i | j |
- +---+------+
- | 1 | 1 |
- | 2 | 2 |
- +---+------+
- +---+------+
- | m | n |
- +---+------+
- | 1 | 1 |
- | 2 | 2 |
- | 3 | 1 |
- +---+------+
Now suppose that you perform the following
DELETE
statement on the master:
Due to the cascade, table fc2
on the master now
contains only 1 row:
- +---+---+
- | m | n |
- +---+---+
- | 2 | 2 |
- +---+---+
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:
- +---+---+
- | m | n |
- +---+---+
- | 1 | 1 |
- | 3 | 1 |
- | 2 | 2 |
- +---+---+
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.
Traduction non disponible
Le manuel MySQL n'est pas encore traduit en français sur l'infobrol. Seule la version anglaise est disponible pour l'instant.
Document créé le 26/06/2006, dernière modification le 26/10/2018
Source du document imprimé : https://www.gaudry.be/mysql-rf-innodb-and-mysql-replication.html
L'infobrol est un site personnel dont le contenu n'engage que moi. Le texte est mis à disposition sous licence CreativeCommons(BY-NC-SA). Plus d'info sur les conditions d'utilisation et sur l'auteur.
Références
Ces références et liens indiquent des documents consultés lors de la rédaction de cette page, ou qui peuvent apporter un complément d'information, mais les auteurs de ces sources ne peuvent être tenus responsables du contenu de cette page.
L'auteur de ce site est seul responsable de la manière dont sont présentés ici les différents concepts, et des libertés qui sont prises avec les ouvrages de référence. N'oubliez pas que vous devez croiser les informations de sources multiples afin de diminuer les risques d'erreurs.