uyoug 2010 - rman sin misterios
DESCRIPTION
Presentación dada en evento del Grupo de Usuarios Oracle de Uruguay (UYOUG) en junio/2010.TRANSCRIPT
![Page 2: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/2.jpg)
2
Agenda
• Uso simple
• Conceptos
• Pasos para comenzar
• Troubleshooting
• Optimización
• Ejemplos
![Page 3: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/3.jpg)
3
¿ Que es RMAN ?
• utilitario de Oracle para manejar backup/recovery y su historia
• interfaz CLI y GUI
• existe desde Oracle 8 – 1997
• instalado junto con la base, en $ORACLE_HOME/bin
• es pro*C ejecutando PL/SQL
• bugs en distintas versiones: 1359
• Known RMAN Performance Problems [ID 247611.1]
- 32 bugs, corregidos todos en 11g (algunos antes)
![Page 4: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/4.jpg)
4
Arquitectura procesos RMAN
![Page 5: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/5.jpg)
5
¿best practices de b&r?
Algunas.
Productos relacionados con Backup & recovery:– datapump– flashback – secure backup
![Page 6: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/6.jpg)
6
respaldo con rman
Diferencias entre respaldo RMAN y manual (user-managed) :
–rman fija las reglas, pero es flexible–rman requiere menos instrumentación–rman provee más funcionalidades
![Page 7: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/7.jpg)
7
respaldo sin rman
• consistente (frío):cp path/* dest-bkp
• inconsistente (caliente) :Alter tablespace nnn begin backup;
cp path/datafile.dbf destbkp
Alter tablespace nnn end backup;
![Page 8: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/8.jpg)
8
respaldo con rman
• consistente (frío): rman target / startup mount;
backup database plus archivelog;
• Inconsistente (caliente) : rman target /
backup database plus archivelog;
![Page 9: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/9.jpg)
9
respaldo con rman
Si usamos XE:
$ORACLE_HOME/config/scripts/• backup.sh • restore.sh
![Page 10: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/10.jpg)
10
¿ realmente es tan fácil ?
oracle@oraculo:~/app/oracle/product/10.2.0/server/config/scripts> ./backup.sh
Warning: Log archiving (ARCHIVELOG mode) is currently disabled. If
you restore the database from this backup, any transactions that take
place between this backup and the next backup will be lost. It is
recommended that you enable ARCHIVELOG mode before proceeding so
that all transactions can be recovered upon restore. See the section
'Enabling ARCHIVELOG Mode...' in the online help for instructions.
Backup with log archiving disabled will shut down and restart the
database. Are you sure [Y/N]?
![Page 11: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/11.jpg)
11
¿realmente es tan fácil?
oracle@oraculo:~/app/oracle/product/10.2.0/server/config/scripts> ./backup.sh
Warning: Log archiving (ARCHIVELOG mode) is currently disabled. If
you restore the database from this backup, any transactions that take
place between this backup and the next backup will be lost. It is
recommended that you enable ARCHIVELOG mode before proceeding so
that all transactions can be recovered upon restore. See the section
'Enabling ARCHIVELOG Mode...' in the online help for instructions.
Backup with log archiving disabled will shut down and restart the
database. Are you sure [Y/N]? y
Backup in progress...
==================== ERROR =========================
Backup of the database failed
==================== ERROR =========================
RMAN error: See log for details.
Log file is at /usr/lib/oracle/xe/oxe_backup_current.log.
Press ENTER key to exit
![Page 12: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/12.jpg)
12
¿ realmente es tan fácil ?
oracle@oraculo:~/app/oracle/product/10.2.0/server/config/scripts> ./backup.sh
Warning: Log archiving (ARCHIVELOG mode) is currently disabled. If
you restore the database from this backup, any transactions that take
place between this backup and the next backup will be lost. It is
recommended that you enable ARCHIVELOG mode before proceeding so
that all transactions can be recovered upon restore. See the section
'Enabling ARCHIVELOG Mode...' in the online help for instructions.
Backup with log archiving disabled will shut down and restart the
database. Are you sure [Y/N]? y
Backup in progress...
Backup of the database succeeded.
Log file is at /usr/lib/oracle/xe/oxe_backup_current.log.
Press ENTER key to exit
![Page 13: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/13.jpg)
13
manual vs RMAN
• Cuanto ocupa el respaldo generado por RMAN ?
oracle@oraculo:~> du -hs oradata/XE
1.5G .oradata/XE
oracle@oraculo:~> ls -lrt /usr/lib/oracle/xe/app/oracle/flash_recovery_area/XE/backupset/2010_06_03/
total 1176688
-rw-r----- 1 oracle dba 1203748864 2010-06-03 00:57 o1_mf_nnndf_TAG20100603T005534_60g9xpkz_.bkp
![Page 14: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/14.jpg)
14
manual vs RMAN
• Cuanto ocupa el respaldo generado por RMAN ?
=> RMAN no respalda temp, redo logs, ni bloques libres !
01:41:16 XE>select sum(bytes)/1024/1024 mb from dba_free_space;
MB
----------
135.8125
1.5G datafiles 1.1G rman
![Page 15: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/15.jpg)
15
manual vs RMAN
Puede ocupar menos si es comprimido
• Dos formas:
– Backup as compressed backupset ...
– CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
-rw-r----- 1 oracle dba 1203986432 2010-06-03 01:31 o1_mf_nnndf_TAG20100603T013020_60gcywnl_.bkp
-rw-r----- 1 oracle dba 235642880 2010-06-03 01:38 o1_mf_nnndf_TAG20100603T013720_60gdd066_.bkp
Pasó de 1.1G a 200M (a costo de más CPU)
![Page 16: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/16.jpg)
16
manual vs RMAN
Cuidado con XE : backup.sh no genera comprimido: rman target /
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO BACKUPSET;
exit;
./backup.sh
rman target /
CONFIGURE DEVICE TYPE DISK BACKUP TYPE TO COMPRESSED BACKUPSET;
exit
./backup.sh
ls -lrt /usr/lib/oracle/xe/app/oracle/flash_recovery_area/XE/backupset/2010_06_03/
-rw-r----- 1 oracle dba 1203748864 2010-06-03 00:57 o1_mf_nnndf_TAG20100603T005534_60g9xpkz_.bkp
-rw-r----- 1 oracle dba 1203986432 2010-06-03 01:31 o1_mf_nnndf_TAG20100603T013020_60gcywnl_.bkp
![Page 17: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/17.jpg)
17
manual vs RMAN
Extracto de backup.sh: echo "Backup in progress..."
rman target / >> $rman_backup << EOF
set echo on;
shutdown immediate;
startup mount;
configure retention policy to redundancy 2;
configure controlfile autobackup format for device type disk clear;
configure controlfile autobackup on;
sql "create pfile=''$rman_spfile2init'' from spfile";
backup as backupset device type disk database;
configure controlfile autobackup off;
alter database open;
delete noprompt obsolete;
EOF
![Page 18: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/18.jpg)
18
manual vs RMAN
Para que comprima, backup.sh debe modificarse: echo "Backup in progress..."
rman target / >> $rman_backup << EOF
set echo on;
shutdown immediate;
startup mount;
configure retention policy to redundancy 2;
configure controlfile autobackup format for device type disk clear;
configure controlfile autobackup on;
sql "create pfile=''$rman_spfile2init'' from spfile";
backup as compressed backupset device type disk database;
configure controlfile autobackup off;
alter database open;
delete noprompt obsolete;
EOF
![Page 19: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/19.jpg)
19
Archivos
• ¿Qué generó?
• List backup;
• ¿Qué archivos respalda?
• datafiles (e image copies)
• controlfiles (e image copies)
• archivelog
• Spfile
• Por lo tanto, no respalda:
• redo logs, tempfiles (no son necesarios para recovery)
• archivos de tablas externas o bfiles
• binarios de la instalación
• archivos configuración de red
![Page 20: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/20.jpg)
20
Conceptos
• Backupset–Backup pieces–channels
• Expirado• Obsoleto• Crosscheck• Incarnations
![Page 21: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/21.jpg)
21
Recovery
![Page 22: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/22.jpg)
22
Incarnations
![Page 23: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/23.jpg)
23
¿hay que seguir sin usar RMAN?
• NO.
• Mientras, plan de empezar a corto plazo
• ¿Porqué?
– Solución uniforme : interfaz idéntica en distintos sistemas operativos
– Usa menos recursos y genera archivos más chicos.
– Funcionalidades no disponibles de forma manual :
![Page 24: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/24.jpg)
24
• Respaldos incrementales : respaldos más chicos, recuperación más rápida (sólo almacena los cambios)
• Block media recovery : repara datafile sin ponerlo offline
• Unused block compression (10.2): no copia bloques libres
• Compresión (bzip2 / zlib en 11g)
• Encriptación
• Repositorio de respaldos
• Data Recovery Advisor (11g)
• Detecta corrupción logica y física
• backup optimization – no copia archivos existentes idénticos en destino.
• Undo optimization (en 11g) – no copia undo no necesario.
Hay que usar RMAN
![Page 25: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/25.jpg)
25
• Usarlo implica:–practicar recovery–tener presente que archivos no
son transportables entre plataformas• ej : Respaldo tomado en x32 no se puede restaurar en x86_64.
–bugs (cada vez menos)
Hay que usar RMAN
![Page 26: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/26.jpg)
26
• definir política– nivel de servicio aceptable– retención– destino– nombres– paralelismo– tamaños máximos de archivos– uso de encriptación
Pasos para empezar a usarlo
![Page 27: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/27.jpg)
27
Primeros pasos
• crear script de configuración– recovery puede ser en otro equipo
• implementar scripts completos– Respaldar
– Borrar obsoletos
– Listar catalogo (documentación)
– Detectar errores
• validar que respaldos sean útiles
![Page 28: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/28.jpg)
28
Escenarios de recovery
* 2 básicos: completo y de tablespace
* 12 avanzados:Recovering After the Loss of Datafiles: ScenariosRecovering Through an Added Datafile with a Backup Control File: ScenarioRe-Creating Datafiles When Backups Are Unavailable: ScenarioRecovering Through RESETLOGS with Created Control File: ScenarioRecovering NOLOGGING Tables and Indexes: ScenarioRecovering Read-Only Tablespaces with a Backup Control File: ScenarioRecovering Transportable Tablespaces: ScenarioRecovering After the Loss of Online Redo Log Files: ScenariosRecovering After the Loss of Archived Redo Log Files: ScenarioRecovering from a Dropped Table: ScenarioPerforming Media Recovery in a Distributed Environment: Scenario
![Page 29: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/29.jpg)
29
Escenarios de recovery
* recuperar un respaldo completo
RMAN> RESTORE DATABASE; RMAN> RECOVER DATABASE;
* recuperar solo un tablespace
RMAN> SQL 'ALTER TABLESPACE users OFFLINE IMMEDIATE'; RMAN> RESTORE TABLESPACE users; RMAN> RECOVER TABLESPACE users; RMAN> SQL 'ALTER TABLESPACE users ONLINE';
![Page 30: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/30.jpg)
30
Primeros pasos
• validar que respaldos sean útiles– cintas sin errores– integridad de datos
• física: backup validate database ...
• lógica + física: – backup blocks all check logical validate database;– select * from V$DATABASE_BLOCK_CORRUPTION;
![Page 31: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/31.jpg)
31
Sólo en enterprise
1. allocate parallel disk channels
2. block change tracking
![Page 32: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/32.jpg)
32
Cuando hay errores
• Manuales
• Metalink
• Debugearrman target / log rman.log trace rman.trc
run{
allocate channel t1 type sbt………trace=2;
allocate channel t2 type sbt………trace=2;
allocate channel t3 type sbt………trace=2;
debug on;
restore database;
debug off;
}
![Page 33: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/33.jpg)
33
Cuando hay errores
• Media manager es de terceros
• sbtio.log
• Simular uso y comparar:run {
allocate channel t1 type sbt parms 'SBT_LIBRARY=oracle.disksbt,ENV=(BACKUP_DIR=d:\temp)' trace=2;
backup database;
}
![Page 34: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/34.jpg)
34
Optimizar backups
- hay que usar async IO (config. SO)
- paralelismo adecuado (channels) a cantidad de cintas
- revisar desempeño de MML
- se puede afinar conociendo la arquitectura de procesos RMAN:
RMAN Backup Performance [ID 360443.1]
![Page 35: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/35.jpg)
35
Optimizar recovery
• Scripts se ejecutan serial.
• Esto no es performante:run {
allocate channel t1 type sbt....;
allocate channel t2 type sbt....;
allocate channel t3 type sbt....;
restore datafile 2;
restore datafile 3;
restore datafile 5;
restore datafile 7;
restore datafile 11;
}
![Page 36: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/36.jpg)
36
Optimizar recovery
• Esto si:run {
allocate channel t1 type sbt....;
allocate channel t2 type sbt....;
allocate channel t3 type sbt....;
restore datafile 2,3,5,7,11;
}
![Page 37: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/37.jpg)
37
Ejemplos !
• Clonación clásica
• Clonación online (> 11.1)
• Clonación RAC
• Data Recovery Advisor
![Page 38: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/38.jpg)
38
¿Siguientes pasos?
• ejercitar escenarios separando roles de DBA's
• Usar Enterprise Manager
• Data Recovery Advisor
![Page 39: UYOUG 2010 - RMAN sin misterios](https://reader034.vdocuments.net/reader034/viewer/2022052307/5580ff4cd8b42a9d198b4fb7/html5/thumbnails/39.jpg)
39
Referencias• Oracle® Database Backup and Recovery Basics - 10.2
http://download.oracle.com/docs/cd/B19306_01/backup.102/b14192/toc.htm
• Oracle® Database Backup and Recovery Advanced User's Guide - 10.2
http://download.oracle.com/docs/cd/B19306_01/backup.102/b14191/toc.htm
• Oracle® Database Backup and Recovery User's Guide - 11.2
http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/toc.htm
• Metalink note 740911.1 - RMAN Restore Performance
• Metalink note 360443.1 - RMAN Backup Performance