Guest User

Untitled

a guest
May 20th, 2018
149
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 1.67 KB | None | 0 0
  1. # Réplication mysql
  2.  
  3. ## Master
  4.  
  5. Editer `/etc/mysql/mysql.conf.d/mysqld.cnf`
  6.  
  7. - Modifier la ligne `bind-address` avec la bonne ip
  8.  
  9. - Ajouter
  10.  
  11. - `server-id = 1`
  12. - `log-bin = /var/log/mysql/mysql-bin.log`
  13. - `log-error = /var/log/mysql/mysql-error.log`
  14. - `binlog-do-db = newDb`
  15.  
  16. - Créer les 2 fichiers de log
  17.  
  18. - `sudo service mysql restart`
  19.  
  20. - Dans la console mysql
  21.  
  22. - `GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'password';`
  23. - `FLUSH PRIVILEGES;`
  24. - `USE newdatabase;`
  25. - `FLUSH TABLES WITH READ LOCK;`
  26. - `SHOW MASTER STATUS;`
  27. - Le rasultat doit resembler à :
  28.  
  29. ```
  30. mysql> SHOW MASTER STATUS;
  31. +------------------+----------+--------------+------------------+
  32. | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
  33. +------------------+----------+--------------+------------------+
  34. | mysql-bin.000001 | 107 | newdatabase | |
  35. +------------------+----------+--------------+------------------+
  36. 1 row in set (0.00 sec)
  37. ```
  38.  
  39. - dumper la base du master pour la mettre dans le slave
  40. - Une fois la configuration du slave faite exécuter : `UNLOCK TABLES;`
  41.  
  42.  
  43. ## Slave
  44.  
  45. - Importer le dump de la base du master
  46. - Editer le fichier `/etc/mysql/mysql.conf.d/mysqld.cnf`
  47. - Ajouter
  48. - `relay-log = /var/log/mysql/mysql-relay-bin.log`
  49. - `log_bin = /var/log/mysql/mysql-bin.log`
  50. - `binlog_do_db = newdatabase`
  51. - Créer les 2 fichiers de log
  52. - `sudo service mysql restart`
  53. - Dans la console mysql :
  54. - `CHANGE MASTER TO MASTER_HOST='<ip_master>',MASTER_USER='slave_user', MASTER_PASSWORD='password', MASTER_PORT=<port_master>, MASTER_LOG_FILE='mysql-bin.000001', MASTER_LOG_POS=107;`
  55. - `START SLAVE;`
  56. - `SHOW SLAVE STATUS\G`
Add Comment
Please, Sign In to add comment