3904
Commentaire:
|
3924
|
Texte supprimé. | Texte ajouté. |
Ligne 1: | Ligne 1: |
## page was renamed from OVH/idneuf/MySQL Rédiger « OVH/idneuf/MySQL » ici. |
<<TableOfContents()>> |
Ligne 4: | Ligne 3: |
= REPLICATION = | {{{#!wiki caution '''Reste à documenter (dans la section des ''Notes'') :''' * le choix du `server-id = 130` (comment on détermine cette valeur) * la nécessité ou non du paramètre `MASTER_LOG_FILE='mysql-bin.000001'` * la signification du paramètre `MASTER_LOG_POS=719` (comment on détermine cette valeur) * le séquencement des commandes (doit-on par exemple rattacher l'esclave entre le LOCK et le UNLOCK du maître) * la généralisation pour l'ajout un esclave supplémentaire après coup * les éventuelles URL de pages web de référence utilisées }}} |
Ligne 6: | Ligne 13: |
== Config MASTER : == | = Mise en place de la réplication = |
Ligne 8: | Ligne 15: |
=== /etc/mysql/conf.d/local.conf === | == Config' côté maître == |
Ligne 10: | Ligne 17: |
Fichier `/etc/mysql/conf.d/local.cnf`: {{{ | |
Ligne 15: | Ligne 23: |
#Replication master->slave | # réplication master->slave |
Ligne 22: | Ligne 30: |
}}} | |
Ligne 23: | Ligne 32: |
=== MySQL === mysql> GRANT REPLICATION SLAVE ON *.* TO 'auf_repl'@'prod-db02-idneuf.vpc02.auf' IDENTIFIED BY 'fb327bb1765683e9fe0278'; Query OK, 0 rows affected (0.00 sec) |
Commandes MySQL : {{{#!mysql mysql> GRANT REPLICATION SLAVE ON *.* TO 'auf_repl'@'prod-db02-idneuf.vpc02.auf' IDENTIFIED BY 'xxxxxxxxxxxxxxxx'; |
Ligne 29: | Ligne 35: |
Query OK, 0 rows affected (0.01 sec) |
|
Ligne 40: | Ligne 44: |
Query OK, 0 rows affected (0.00 sec) | }}} |
Ligne 42: | Ligne 46: |
== Config' côté esclave == | |
Ligne 43: | Ligne 48: |
== Config SLAVE == ===/etc/mysql/conf.d/local.conf=== |
Fichier `/etc/mysql/conf.d/local.cnf` : {{{ |
Ligne 52: | Ligne 54: |
#Replication master->slave | # réplication master->slave |
Ligne 60: | Ligne 62: |
}}} | |
Ligne 61: | Ligne 64: |
=== MySQL === mysql> CHANGE MASTER TO MASTER_HOST='prod-db01-idneuf.vpc02.auf',MASTER_USER='auf_repl', MASTER_PASSWORD='fb327bb1765683e9fe0278', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=719; ERROR 1198 (HY000): Cette opération ne peut être réalisée avec un esclave actif, faites STOP SLAVE d'abord mysql> stop slave; Query OK, 0 rows affected (0.01 sec) mysql> CHANGE MASTER TO MASTER_HOST='prod-db01-idneuf.vpc02.auf',MASTER_USER='auf_repl', MASTER_PASSWORD='fb327bb1765683e9fe0278', MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=719; Query OK, 0 rows affected (0.01 sec) mysql> start slave; Query OK, 0 rows affected (0.00 sec) mysql> show slave status\G; |
Commandes MySQL : {{{ mysql> STOP SLAVE; mysql> CHANGE MASTER TO MASTER_HOST='prod-db01-idneuf.vpc02.auf',MASTER_USER='auf_repl',MASTER_PASSWORD='xxxxxxxxxxxxxxxx',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=719; mysql> START SLAVE; mysql> SHOW SLAVE STATUS\G; |
Ligne 116: | Ligne 110: |
1 row in set (0.00 sec) | }}} |
Ligne 118: | Ligne 112: |
ERROR: No query specified |
== Notes == |
Reste à documenter (dans la section des Notes) :
le choix du server-id = 130 (comment on détermine cette valeur)
la nécessité ou non du paramètre MASTER_LOG_FILE='mysql-bin.000001'
la signification du paramètre MASTER_LOG_POS=719 (comment on détermine cette valeur)
- le séquencement des commandes (doit-on par exemple rattacher l'esclave entre le LOCK et le UNLOCK du maître)
- la généralisation pour l'ajout un esclave supplémentaire après coup
- les éventuelles URL de pages web de référence utilisées
Mise en place de la réplication
Config' côté maître
Fichier /etc/mysql/conf.d/local.cnf:
[mysqld] language = /usr/share/mysql/french bind-address = 0.0.0.0 log_slow_queries = /var/log/mysql/mysql-slow.log # réplication master->slave server-id = 130 log_bin = /var/log/mysql/mysql-bin.log binlog_do_db = drupal [mysqldump] quote-names
Commandes MySQL :
mysql> GRANT REPLICATION SLAVE ON *.* TO 'auf_repl'@'prod-db02-idneuf.vpc02.auf' IDENTIFIED BY 'xxxxxxxxxxxxxxxx'; mysql> FLUSH TABLES WITH READ LOCK; mysql> SHOW MASTER STATUS; +------------------+----------+--------------+------------------+ | File | Position | Binlog_Do_DB | Binlog_Ignore_DB | +------------------+----------+--------------+------------------+ | mysql-bin.000001 | 445 | drupal | | +------------------+----------+--------------+------------------+ 1 row in set (0.00 sec) mysql> UNLOCK TABLES;
Config' côté esclave
Fichier /etc/mysql/conf.d/local.cnf :
[mysqld] language = /usr/share/mysql/french bind-address = 0.0.0.0 log_slow_queries = /var/log/mysql/mysql-slow.log # réplication master->slave server-id = 131 relay-log = /var/log/mysql/mysql-relay-bin.log log_bin = /var/log/mysql/mysql-bin.log binlog_do_db = drupal [mysqldump] quote-names
Commandes MySQL :
mysql> STOP SLAVE; mysql> CHANGE MASTER TO MASTER_HOST='prod-db01-idneuf.vpc02.auf',MASTER_USER='auf_repl',MASTER_PASSWORD='xxxxxxxxxxxxxxxx',MASTER_LOG_FILE='mysql-bin.000001',MASTER_LOG_POS=719; mysql> START SLAVE; mysql> SHOW SLAVE STATUS\G; *************************** 1. row *************************** Slave_IO_State: Connecting to master Master_Host: prod-db01-idneuf.vpc02.auf Master_User: auf_repl Master_Port: 3306 Connect_Retry: 60 Master_Log_File: mysql-bin.000001 Read_Master_Log_Pos: 719 Relay_Log_File: mysql-relay-bin.000001 Relay_Log_Pos: 4 Relay_Master_Log_File: mysql-bin.000001 Slave_IO_Running: Connecting Slave_SQL_Running: Yes Replicate_Do_DB: Replicate_Ignore_DB: Replicate_Do_Table: Replicate_Ignore_Table: Replicate_Wild_Do_Table: Replicate_Wild_Ignore_Table: Last_Errno: 0 Last_Error: Skip_Counter: 0 Exec_Master_Log_Pos: 719 Relay_Log_Space: 107 Until_Condition: None Until_Log_File: Until_Log_Pos: 0 Master_SSL_Allowed: No Master_SSL_CA_File: Master_SSL_CA_Path: Master_SSL_Cert: Master_SSL_Cipher: Master_SSL_Key: Seconds_Behind_Master: NULL Master_SSL_Verify_Server_Cert: No Last_IO_Errno: 2005 Last_IO_Error: error connecting to master 'auf_repl@prod-db01-idneuf.vpc02.auf:3306' - retry-time: 60 retries: 86400 Last_SQL_Errno: 0 Last_SQL_Error: Replicate_Ignore_Server_Ids: Master_Server_Id: 130