Archive

Articles taggués ‘database’

MySQL Master / Slave Replication

11/10/2021 Comments off

Source: Uptime Made Easy

Master Slave MySQL Replication Summary

Master / Slave replication in MySQL is a great way to store an exact replica of your database on another machine in another location as part of a disaster recovery plan.  Before setting up Master / Slave replication there are a few things to remember.

  • Writes – Writes to the master database should make it to the slave.  But writes to the slave will not make it to the master.  If you do write records to the slave database directly, be prepared to have to either recreate the records or back them up separately and recover them if the replication breaks.  Many times the only way to get the databases to replicate again is to backup the master and recover it over the top of the slave deleting anything that was in the slave database before.
  • Broken Replication – Writes made directly to the slave can cause the replication to break due to duplicate key rows, etc..  Always write to the master.
  • Reads – Reads should be possible from either server.  Many organizations will use replication so as to create another database to read from thereby taking the load of all of their select statements and reports off the master server.

 

MySQL Replication schemeMaster Slave MySQL Replication

Steps to Setup MySQL Master / Slave Replication

Prerequisites

We will be assuming that the following prerequisites are done prior to beginning the steps listed below:

  • MySQL has been installed on both the master and the slave servers
  • The slave server is able to communicate directly to the mysqld port (typically 3306) on the master server, meaning that there is no firewall, routing, NAT or other problems preventing communication.
  • You have an administrator MySQL user that can create users on both the master and the slave machines.
  • You have permissions to edit the /etc/my.cnf files on both machines and enough privileges to restart mysql.

That should be it!  Let’s begin setting it up.

Lire la suite…

HowTo: Uninstall MySQL Server in Ubuntu Linux

22/06/2021 Comments off

Source: nixCraft

I‘m a new Ubuntu Linux user and my cloud hosting company installed MySQL server by default. I need to remove it and delete it from my server as I have no use of MySQL server. How can I uninstall MySQL on a Ubuntu based systems?

Typically following Mysql packages are installed on the Debian or Ubuntu Linux systems:

  • mysql-client – The latest version of MySQL database client.
  • mysql-server – The latest version of MySQL database server.
  • mysql-common – MySQL database common files.

How do I uninstall Mysql server?

Just use the apt-get command as follows remove both MySQL server and client in Ubuntu Linux:

sudo apt-get --purge remove mysql-client mysql-server mysql-common
sudo apt-get autoremove

Sample outputs (pay attention to package names):

Reading package lists... Done
Building dependency tree
Reading state information... Done
The following packages were automatically installed and are no longer required:
  linux-headers-3.2.0-31-virtual linux-headers-3.2.0-31
Use 'apt-get autoremove' to remove them.
The following packages will be REMOVED:
  libdbd-mysql-perl* libmysqlclient18* mysql-client* mysql-client-5.5* mysql-common* mysql-server*
  mysql-server-5.5*
0 upgraded, 0 newly installed, 7 to remove and 0 not upgraded.
After this operation, 67.5 MB disk space will be freed.
Do you want to continue [Y/n]? y
(Reading database ... 105097 files and directories currently installed.)
Removing mysql-server ...
Removing mysql-server-5.5 ...
mysql stop/waiting
Purging configuration files for mysql-server-5.5 ...
Removing mysql-client ...
Removing mysql-client-5.5 ...
Removing libdbd-mysql-perl ...
Removing libmysqlclient18 ...
Purging configuration files for libmysqlclient18 ...
Removing mysql-common ...
Purging configuration files for mysql-common ...
dpkg: warning: while removing mysql-common, directory '/etc/mysql' not empty so not removed.
Processing triggers for ureadahead ...
Processing triggers for man-db ...
Processing triggers for libc-bin ...
ldconfig deferred processing now taking place

Delete /etc/mysql/ directory using rm command:
$ sudo rm -rf /etc/mysql/

Understanding apt-get command options

  • --purge : Remove given packages and config files.
  • remove : Uninstall packages.
  • autoremove : Force to remove packages that were automatically installed to satisfy dependencies for other packages and are now no longer needed.

Installation Serveur Mail Postfix, Amavisd, Mysql, Spamassassin, Dspam, Dovecot

02/06/2021 Comments off

Ce tutoriel a été intégralement repris du site  http://www.starbridge.org et a été réalisé par tonio. Il est distribué sous licence creativecommons  Creative Commons License

Cet article, initié en 2007, est mis à jour régulièrement.
Le système sur lequel est basé ce document est une DEBIAN stable (Wheezy).
Le tuto est aussi entièrement compatible avec la version Testing (Jessie).

Ce tuto fonctionne également sous Ubuntu mais certains paquets présentent de légères différences. On essaiera de les indiquer si possible.

Mise à jour du 5/5/2015

Table des matières

Préparation de l’environnement

On prendra comme base pour l’exemple le domaine starbridge.org et le hostname du serveur de mail sera spike.

On met le système à jour :

aptitude update
aptitude full-upgrade

On vérifie les fichiers :

/etc/hostname : spike.starbridge.org
/etc/hosts : 127.0.0.1    spike.starbridge.org localhost.localdomain localhost spike

Lire la suite…

Categories: Logiciel, Tutoriel Tags: , , ,

Réplication MySQL

25/05/2021 Comments off

Source: Howto MySQL

Préparation

  • Prérequis : disposer de deux serveurs MySQL avec un datadir identique

Dans le cas où le futur master est en production et ne peut être arrété :

# mysqldump --master-data --all-databases > mysql.dump

--master-data ajoute un CHANGE MASTER TO dans le dump contenant les informations nécessaires au slave sur les logs (nom de fichier et position). Cette option implique--lock-all-tables qui bloquera toutes les tables pendant le dump.

  • Autoriser les connections MySQL distantes
  • Activer les logs binaires sur chaque serveur : log_bin = /var/log/mysql/mysql-bin.log dans le format mixed : binlog_format = mixed
  • Positionner un server-id différent sur chaque serveur (a priori, ne pas utiliser 0…)
  • Créer un utilisateur dédié pour la réplication sur chaque serveur avec le droit REPLICATION SLAVE :grant replication slave on *.* to repl@'%' identified by 'XXX';

Lire la suite…