Outils pour utilisateurs

Outils du site


informatique:sgbd:mysql:replication

Différences

Ci-dessous, les différences entre deux révisions de la page.

Lien vers cette vue comparative

Les deux révisions précédentesRévision précédente
Prochaine révision
Révision précédente
informatique:sgbd:mysql:replication [21/03/2021 16:17] – [Configuration mysql] cyrilleinformatique:sgbd:mysql:replication [21/01/2022 10:09] (Version actuelle) – [mysql replication] 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**.
 +
 +  * mariadb.com/kb
 +    * [[https://mariadb.com/kb/en/setting-up-replication/|Setting Up Replication]]
  
 Voir [[/informatique/sgbd/mysql|MySql]]. Voir [[/informatique/sgbd/mysql|MySql]].
 +
 +===== Quelques configs & manips =====
 +
 +  * [[https://mariadb.com/kb/en/binary-log/|Binary Log ]]
 +    * 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://mariadb.com/kb/en/relay-log/|Relay Log]]
 +    * **max_relay_log_size** : default = 0
 +
 +[[https://mariadb.com/kb/en/using-and-maintaining-the-binary-log/#safely-purging-binary-log-files-while-replicating|Safely Purging Binary Log Files While Replicating]]
 +
 +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 82: Ligne 103:
 </code> </code>
  
-Documentation:+=== Documentation === 
   * MySql 8   * MySql 8
     * [[https://dev.mysql.com/doc/refman/8.0/en/replication-options-replica.html|17.1.6.3 Replica Server Options and Variables]]     * [[https://dev.mysql.com/doc/refman/8.0/en/replication-options-replica.html|17.1.6.3 Replica Server Options and Variables]]
Ligne 89: Ligne 111:
     * [[https://mariadb.com/kb/en/standard-replication/|MariaDB Replication]]     * [[https://mariadb.com/kb/en/standard-replication/|MariaDB Replication]]
     * [[https://mariadb.com/kb/en/setting-up-replication/|Setting Up Replication]]     * [[https://mariadb.com/kb/en/setting-up-replication/|Setting Up Replication]]
 +
 +== binlog-do-db ==
 +
 +
 +Sans autre précision, tout sera répliqué, par exemple un conflit de ''PRIMARY KEY'' sur la table ''mysql.user'' peut arrêter la réplication ''[ERROR] Slave SQL: Could not execute Write_rows_v1 event on table mysql.user; Duplicate entry 'localhost-root' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysqld-bin.000001, end_log_pos 26196, Gtid 0-1-36, Internal MariaDB error code: 1062''
  
 ==== Démarrer le tout ==== ==== Démarrer le tout ====
Ligne 142: Ligne 169:
 </code> </code>
  
-Sans autre précision, tout sera répliqué, par exemple un conflit de ''PRIMARY KEY'' sur la table ''mysql.user'' peut arrêter la réplication ''[ERROR] Slave SQL: Could not execute Write_rows_v1 event on table mysql.user; Duplicate entry 'localhost-root' for key 'PRIMARY', Error_code: 1062; handler error HA_ERR_FOUND_DUPP_KEY; the event's master log mysqld-bin.000001, end_log_pos 26196, Gtid 0-1-36, Internal MariaDB error code: 1062'' 
  
 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 '--log-basename=#' or '--relay-log=mysqld-relay-bin' to avoid this problem. 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 '--log-basename=#' or '--relay-log=mysqld-relay-bin' to avoid this problem.
  
-Documentation:+=== Documentation === 
   * syntaxe [[https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html|CHANGE MASTER]]   * syntaxe [[https://dev.mysql.com/doc/refman/8.0/en/change-master-to.html|CHANGE MASTER]]
     * notamment pour MASTER_CONNECT_RETRY, MASTER_RETRY_COUNT     * notamment pour MASTER_CONNECT_RETRY, MASTER_RETRY_COUNT
informatique/sgbd/mysql/replication.1616339854.txt.gz · Dernière modification : 21/03/2021 16:17 de cyrille

Sauf mention contraire, le contenu de ce wiki est placé sous les termes de la licence suivante : CC0 1.0 Universal
CC0 1.0 Universal Donate Powered by PHP Valid HTML5 Valid CSS Driven by DokuWiki