« MySQL/Réplication » : différence entre les versions

72 octets enlevés ,  il y a 10 ans
* Utiliser les mêmes versions de MySQL sur eux peut aider.
 
=== FixingRéparer ===
Par défaut, la réplication stoppe en cas d'erreur (provenant du réseau ou d'une requête).
 
InDans thisce casecas, you'llregarder get ala trace indans the systemle log (typicallygénéralement <code>/var/log/syslog</code>) :
By default, replicate will stop if it meets an error. This can happen if your master and slaves were not consistent in the beginning, or due to a network error causing a malformed query.
<source lang=bash>
 
In this case, you'll get a trace in the system log (typically <code>/var/log/syslog</code>):
Oct 15 21:11:19 builder mysqld[4266]: 101015 21:11:19 [ERROR] Slave: Error 'Table 'mybase.form'
doesn't exist' on query. Default database: 'mybase'. Query:
'INSERT INTO `form` (`form_id`,`timestamp`,`user_id`) VALUES ('abed',1287172429,0)',
Error_code: 1146
</source>
La meilleure façon et de relancer la réplication entièrement.
 
On peut aussi tenter de réparer, par exemple faire sauter à MySQL la commande <code>1</code> :
The best way is to reset the replication entirely.
<source lang=sql>
 
You can also fix the mistake manually, and then ask MySQL to skip <code>1</code> statement this way:
STOP SLAVE;
SET GLOBAL SQL_SLAVE_SKIP_COUNTER = 1;
START SLAVE;
</source>
Attention en définissant ce nombre car il contient toutes les commandes, pas seulement les erreurs.
 
Une autre façon est d'utiliser les outils Maatkit :
You can set <code>SQL_SLAVE_SKIP_COUNTER</code> to any number, e.g. <code>100</code>. Beware that in this case, it will skip both valid and invalid statements, not only errors.
* mk-slave-restart (topour restartrelancer replicationla onréplication du slave it there are more errors andsi <code>SQL_SLAVE_SKIP_COUNTER</code> can'tne peut pas helpaider)
 
* mk-table-checksum (topour performfaire checksummingun of{{wt|checksum}} des tables onsur le master andet le slave)
 
* mk-table-sync (topour syncsynchroniser le slave withavec le master basedbasé sur ondes statsstatistiques generatedgénérés bypar <code>mk-table-checksum</code>).
Another way to fix broken replication is to use Maatkit tools.
* mk-slave-restart (to restart replication on slave it there are more errors and <code>SQL_SLAVE_SKIP_COUNTER</code> can't help)
* mk-table-checksum (to perform checksumming of tables on master and slave)
* mk-table-sync (to sync slave with master based on stats generated by mk-table-checksum)
 
=== Uninstalling ===