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