informatique:sgbd:mysql:replication
Différences
Ci-dessous, les différences entre deux révisions de la page.
Les deux révisions précédentesRévision précédenteProchaine révision | Révision précédenteProchaine révisionLes deux révisions suivantes | ||
informatique:sgbd:mysql:replication [21/03/2021 15:59] – [Sur le slave] cyrille | informatique:sgbd:mysql:replication [13/01/2022 09:40] – [Quelques configs & manips] cyrille | ||
---|---|---|---|
Ligne 1: | Ligne 1: | ||
====== mysql replication ====== | ====== mysql replication ====== | ||
- | + | Des questions: | |
- | + | ||
- | Les questions: | + | |
* vérifier automatiquement que la réplication fonctionne | * vérifier automatiquement que la réplication fonctionne | ||
* le slave est désynchroniser car il ne pouvait pas communiquer avec le master | * le slave est désynchroniser car il ne pouvait pas communiquer avec le master | ||
* le fichier bin_log est trop petit pour contenir les requêtes le temps que le slave les récupère | * le fichier bin_log est trop petit pour contenir les requêtes le temps que le slave les récupère | ||
+ | Wording / Vocabulaire : **master & slave -> primary & replica**. | ||
Voir [[/ | Voir [[/ | ||
+ | |||
+ | ===== Quelques configs & manips ===== | ||
+ | |||
+ | * [[https:// | ||
+ | * Lui donner un nom --**log-basename** pour qu'il ne soit pas dépendant du hostname. | ||
+ | * Définissez **expire_logs_days** plus long que tout décalage possible du replica. | ||
+ | * max_binlog_size : default & max = 1GB | ||
+ | * [[https:// | ||
+ | * **max_relay_log_size** : default = 0 | ||
+ | |||
+ | [[https:// | ||
+ | |||
+ | To be sure replication is not broken while deleting log files, perform the following steps: | ||
+ | |||
+ | * Get a listing of binary log files on the primary by running SHOW BINARY LOGS. | ||
+ | * Go to each replica server and run SHOW SLAVE STATUS to check which binary log file each replica is currently reading. | ||
+ | * Find the earliest log file still being read by a replica. No log files before this one will be needed. | ||
+ | * If you wish, make a backup of the log files to be deleted | ||
+ | * Purge all log files before (not including) the file identified above. | ||
===== Essais de réplication ===== | ===== Essais de réplication ===== | ||
Ligne 49: | Ligne 67: | ||
</ | </ | ||
+ | |||
+ | ==== Configuration mysql ==== | ||
+ | |||
+ | Pour le master: | ||
+ | < | ||
+ | # | ||
+ | [server] | ||
+ | server_id=1 | ||
+ | # activer le log des requêtes pour la réplication | ||
+ | log-bin | ||
+ | # default | ||
+ | # | ||
+ | |||
+ | # N' | ||
+ | binlog-do-db=test | ||
+ | |||
+ | # | ||
+ | # | ||
+ | |||
+ | </ | ||
+ | |||
+ | Pour le slave: | ||
+ | < | ||
+ | # ./ | ||
+ | [server] | ||
+ | server_id=2 | ||
+ | |||
+ | report-host=the-slave | ||
+ | |||
+ | # TODO: | ||
+ | # | ||
+ | </ | ||
+ | |||
+ | === Documentation === | ||
+ | |||
+ | * MySql 8 | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | * MariaDB | ||
+ | * [[https:// | ||
+ | * [[https:// | ||
+ | |||
+ | == binlog-do-db == | ||
+ | |||
+ | |||
+ | Sans autre précision, tout sera répliqué, par exemple un conflit de '' | ||
+ | |||
+ | ==== Démarrer le tout ==== | ||
On lance les services | On lance les services | ||
Ligne 100: | Ligne 166: | ||
</ | </ | ||
- | Sans autre précision, tout sera répliqué, par exemple un conflit de '' | ||
db-slave_1 [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use ' | db-slave_1 [Warning] Neither --relay-log nor --relay-log-index were used; so replication may break when this MySQL server acts as a slave and has his hostname changed!! Please use ' | ||
- | Documentation: | + | === Documentation |
* syntaxe [[https:// | * syntaxe [[https:// | ||
* notamment pour MASTER_CONNECT_RETRY, | * notamment pour MASTER_CONNECT_RETRY, |
informatique/sgbd/mysql/replication.txt · Dernière modification : 21/01/2022 10:09 de cyrille