progetti:cloud-areapd:operations:backup
Differences
This shows you the differences between two versions of the page.
| Both sides previous revisionPrevious revisionNext revision | Previous revision | ||
| progetti:cloud-areapd:operations:backup [2014/09/26 07:55] – [Bacula Backup] cresce@infn.it | progetti:cloud-areapd:operations:backup [2014/09/26 08:05] (current) – [Bacula Backup] cresce@infn.it | ||
|---|---|---|---|
| Line 1: | Line 1: | ||
| + | ====== Backup ====== | ||
| + | ====== MySQL DB Backup ====== | ||
| + | |||
| + | Il cluster MySQL e' composto da tre macchine nelle quali e' installato Percona XtraDB Cluster. Per eseguire il backup basta utilizzare uno qualsiasi dei tre server, essendo tutti in configurazione attiva. | ||
| + | Nel nostro cluster e' stato utilizzato mysql-cluster-01 per eseguire tutte le attivita' | ||
| + | |||
| + | Percona fornisce un tool per eseguire il backup e restore chiamato **innobackupex**. | ||
| + | |||
| + | Innobackupex esegue il “full backup” del cluster e non “partial backups” in quanto Percona utilizza un unico tablespace per tutti i databases. Per consentire i “partial backups” e' necessario utilizzare l' | ||
| + | |||
| + | Innobackupex e' uno script perl che utilizza il binario xtrabackup per eseguire il backup di tutti i dati delle tabelle InnoDB, tutte le definizioni delle tabelle nel database (.frm files), dati e files riferiti a MyISAM, ... , triggers e informazioni di configurazione del database in una directory con nome il timestamp attuale creata nella directory fornita al comando. | ||
| + | |||
| + | I files di backup sono salvati in una partizione montata sotto / | ||
| + | |||
| + | '' | ||
| + | ...............................................\\ | ||
| + | drwxr-xr-x 28 root root 4096 Sep 19 20:00 / | ||
| + | drwxr-xr-x 28 root root 4096 Sep 20 20:00 / | ||
| + | drwxr-xr-x 28 root root 4096 Sep 21 20:00 / | ||
| + | drwxr-xr-x 28 root root 4096 Sep 22 20:00 / | ||
| + | drwxr-xr-x 28 root root 4096 Sep 23 20:00 / | ||
| + | |||
| + | ===== Full Backup/ | ||
| + | |||
| + | Il backup viene eseguito ogni sera alle 20:00 tramite un cron job, nel quale viene invocato | ||
| + | il comando: / | ||
| + | |||
| + | Per eseguire il restore bisogna innanzitutto copiare il backup in un area temporanea e | ||
| + | applicare i logs al backup con i seguenti comandi: | ||
| + | |||
| + | mkdir /tmp/backup | ||
| + | cp -r / | ||
| + | innobackupex --apply-log --use-memory=2G /tmp/backup | ||
| + | |||
| + | A questo punto spegnare tutte le istanze mysql nel cluster con il comando: | ||
| + | |||
| + | <code bash> | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | ripulire l'area data di mysql: | ||
| + | |||
| + | <code bash> | ||
| + | rm -rf / | ||
| + | </ | ||
| + | |||
| + | e caricare il backup con l' | ||
| + | |||
| + | <code bash> | ||
| + | innobackupex --copy-back /tmp/backup | ||
| + | </ | ||
| + | |||
| + | Una volta caricato tutti i database, cambiare i permessi dell' | ||
| + | |||
| + | <code bash> | ||
| + | chown -R mysql:mysql / | ||
| + | </ | ||
| + | |||
| + | A questo punto e' possibile riavviare il server mysql nel nodo mysql-cluster-01 con il seguente comando: | ||
| + | |||
| + | <code bash> | ||
| + | / | ||
| + | </ | ||
| + | |||
| + | Non utilizzare il comando "/ | ||
| + | |||
| + | Una volta avviata la prima istanza procedere con le altre due. Nel caso non si sia gia' proceduto alla pulizia dell' | ||
| + | |||
| + | <code bash> | ||
| + | rm -rf / | ||
| + | </ | ||
| + | |||
| + | Ora e' possibile avviare mysql: | ||
| + | |||
| + | <code bash> | ||
| + | / | ||
| + | </ | ||
| + | ===== Partial Backups/ | ||
| + | |||
| + | Il backup viene eseguito ogni mattina alle 08:00 tramite un cron job. I backups dei singoli database sono eseguiti tramite il comando **mysqldump**. | ||
| + | Per eseguire il backup e' stato utilizzato lo script presente al link http:// | ||
| + | |||
| + | I vecchi backup verranno cancellati dall' | ||
| + | |||
| + | <code bash> | ||
| + | find / | ||
| + | </ | ||
| + | |||
| + | Per eseguire la cancellazione il comando find verra' eseguito in catena con gli script di backup. | ||
| + | |||
| + | Per eseguire il restore di un database bisogna innanzitutto eseguire il drop dello stesso dal server MySQL con account root. | ||
| + | |||
| + | <code bash> | ||
| + | mysql -u root | ||
| + | mysql> drop < | ||
| + | </ | ||
| + | |||
| + | Ora e' possibile caricare il database dal file presente in / | ||
| + | |||
| + | <code bash> | ||
| + | cp / | ||
| + | gunzip / | ||
| + | mysql -u root < / | ||
| + | rm -f / | ||
| + | </ | ||
| + | |||
| + | ====== Bacula Backup ====== | ||
| + | Per eseguire il backup dei servers viene utilizzato bacula. La seguente tabella mostra le macchine e le directories di cui viene eseguito il backup. | ||
| + | |||
| + | < | ||
| + | < | ||
| + | < | ||
| + | div.bacula table { | ||
| + | margin: 0 0 1em; | ||
| + | font-size: 100%; | ||
| + | } | ||
| + | div.bacula table.inline { | ||
| + | background-color: | ||
| + | border-collapse: | ||
| + | border-spacing: | ||
| + | } | ||
| + | div.bacula table.inline th { | ||
| + | background-color: | ||
| + | border: 1px solid #CCCCCC; | ||
| + | padding: 3px; | ||
| + | } | ||
| + | div.bacula table.inline td { | ||
| + | border: 1px solid #CCCCCC; | ||
| + | padding: 3px; | ||
| + | } | ||
| + | |||
| + | .leftalign { | ||
| + | text-align: left; | ||
| + | } | ||
| + | </ | ||
| + | </ | ||
| + | < | ||
| + | <div class=" | ||
| + | <table class=" | ||
| + | < | ||
| + | <tr class=" | ||
| + | <th class=" | ||
| + | <th class=" | ||
| + | <th class=" | ||
| + | <th class=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td rowspan=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | <td rowspan=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td rowspan=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | <td rowspan=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td rowspan=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | <td rowspan=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | </tr> | ||
| + | <tr class=" | ||
| + | <td class=" | ||
| + | <td class=" | ||
| + | </tr> | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
| + | </ | ||
