Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- # Réplication mysql
- ## Master
- Editer `/etc/mysql/mysql.conf.d/mysqld.cnf`
- - Modifier la ligne `bind-address` avec la bonne ip
- - Ajouter
- - `server-id = 1`
- - `log-bin = /var/log/mysql/mysql-bin.log`
- - `log-error = /var/log/mysql/mysql-error.log`
- - `binlog-do-db = newDb`
- - Créer les 2 fichiers de log
- - `sudo service mysql restart`
- - Dans la console mysql
- - `GRANT REPLICATION SLAVE ON *.* TO 'slave_user'@'%' IDENTIFIED BY 'password';`
- - `FLUSH PRIVILEGES;`
- - `USE newdatabase;`
- - `FLUSH TABLES WITH READ LOCK;`
- - `SHOW MASTER STATUS;`
- - Le rasultat doit resembler à :
- ```
- mysql> SHOW MASTER STATUS;
- +------------------+----------+--------------+------------------+
- | File | Position | Binlog_Do_DB | Binlog_Ignore_DB |
- +------------------+----------+--------------+------------------+
- | mysql-bin.000001 | 107 | newdatabase | |
- +------------------+----------+--------------+------------------+
- 1 row in set (0.00 sec)
- ```
- - dumper la base du master pour la mettre dans le slave
- - Une fois la configuration du slave faite exécuter : `UNLOCK TABLES;`
- ## Slave
- - Importer le dump de la base du master
- - Editer le fichier `/etc/mysql/mysql.conf.d/mysqld.cnf`
- - Ajouter
- - `relay-log = /var/log/mysql/mysql-relay-bin.log`
- - `log_bin = /var/log/mysql/mysql-bin.log`
- - `binlog_do_db = newdatabase`
- - Créer les 2 fichiers de log
- - `sudo service mysql restart`
- - Dans la console mysql :
- - `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;`
- - `START SLAVE;`
- - `SHOW SLAVE STATUS\G`
Add Comment
Please, Sign In to add comment