Mysql
Linux/Unix

Comment Supprimer la réplication MySQL Master/Slave sur CentOS 7

Nous avons vu dans un article précèdent comment configurer la réplication MySQL Master/Slave sur CentOS 7. Dans cet article nous allons voir comment désactiver la réplication MySQL.

Serveur slave :

Nous allons commencer par supprimer la réplication au niveau du serveur slave :

Connectez-vous à la consol Mysql :

root@Slave ~]# mysql -u root -p 
Enter Password : 
Welcome to the MySQL monitor. Commands end with ; or \g. 
Your MySQL connection id is 1 Server version: 5.5.37-cll MySQL Community Server (GPL) 

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved. 

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners. 
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Arrêtez le serveur slave avec la commande ci-dessous :

mysql> stop slave; 
Query OK, 0 rows affected, 1 warning (0.00 sec)

Réinitialisez la configuration du slave :

mysql> reset slave all; 
Query OK, 0 rows affected (0.00 sec)

Vérifiez le status du slave :

mysql> show slave status\G 
Empty set (0.00 sec)

Supprimer ensuite l’utilisateur de réplication (replica dans mon cas) :

mysql> select user,host from mysql.user where user='replica'; 
+-----------------+-----------+ 
| user            | host      | 
+-----------------+-----------+ 
| replica         | localhost | 
+-----------------+-----------+ 
1 row in set (0.00 sec)
mysql> drop user 'replica'@'localhost'; 
Query OK, 0 rows affected (0.01 sec)

Vérifiez si l’utilisateur a été bien supprimé :

mysql> select user,host from mysql.user where user='replica'; 
Empty set (0.00 sec)

Déconnectez vous du consol MySQL:

mysql> exit 
Bye

Supprimer les lignes lié à la réplication su fichier my.cnf :

[mysqld]
server-id=1
log-bin=mysql-bin

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

Enfin redémarrez le servie mysql :

root@slave ~# service mysql restart 
Shutting down MySQL...... SUCCESS! 
Starting MySQL. SUCCESS!

Serveur Mysql master :

Connectez-vous à la consol Mysql :

root@Master ~]# mysql -u root -p
Enter Password :
Welcome to the MySQL monitor. Commands end with ; or \g.
Your MySQL connection id is 1 Server version: 5.5.37-cll MySQL Community Server (GPL)

Copyright (c) 2000, 2014, Oracle and/or its affiliates. All rights reserved.

Oracle is a registered trademark of Oracle Corporation and/or its affiliates. Other names may be trademarks of their respective owners.
Type 'help;' or '\h' for help. Type '\c' to clear the current input statement.

Supprimez l’utilisateur de réplication :

mysql> drop user 'replica'@'localhost';
Query OK, 0 rows affected (0.01 sec)

Exécutez la commande flush the privileges :

mysql> flush privileges; 
Query OK, 0 rows affected (0.00 sec)

Supprimez les lignes liés à la réplication su fichier my.cnf :

[mysqld]
server-id=2
log-bin=mysql-bin

datadir=/var/lib/mysql
socket=/var/lib/mysql/mysql.sock

Enfin redémarrez le servie mysql :

root@Master ~# service mysql restart
Shutting down MySQL...... SUCCESS!
Starting MySQL. SUCCESS!

Laisser un commentaire

Votre adresse e-mail ne sera pas publiée. Les champs obligatoires sont indiqués avec *