Pular para o conteúdo

Como realizar recuperação de backup consistente usando o RMAN

Recover Completo de um Backup Consistente

Hoje apresentarei uma recuperação de um backup consistente usando o RMAN.

Para esse pequeno teste, usei um banco oracle XE versão 11g Release 2. Esse banco não está com ARCHIVELOG ativo (NOARCHIVELOG).

Primeiro vou explicar o que é um backup consistente e um backup inconsistente de um banco de dados.

Backup Consistente

Um backup consistente é um backup efetuado com o banco de dados em estado NOMOUNT; também conhecido como “Backup Frio” ou “Cold Backup”; pode-se ouvir também: “com o banco baixado”.

Em suma, é um backup executado com o conjunto de RELOG fechado, sem executar alterações durante todo o processo de backup.

Backup Inconsistente

Um backup inconsistente é um backup efetuado com o banco de dados em estado OPEN; também conhecido como “Backup Quente” ou “Hot Backup”; pode-se ouvir também: “com o banco aberto”.

Em suma, é um backup executado com o conjunto de REDOLOG aberto, executando alterações durante o processo de backup.

Verificando se o ARCHIVELOG está ativo

 [oracle@host0916 ~]$ sqlplus /nolog
 
 SQL*Plus: Release 11.2.0.2.0 Production on Mon Dec 3 18:09:10 2012
 
 Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
 SQL> conn / as sysdba
 Connected.
 SQL> 
 SQL> archive log list
 Database log mode         No Archive Mode
 Automatic archival        Disabled
 Archive destination           USE_DB_RECOVERY_FILE_DEST
 Oldest online log sequence     1
 Current log sequence          2
 SQL> 
 SQL> exit
 Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production

Baixando o banco e executando um backup completo

 [oracle@host0916 ~]$ rman target /
 
 Recovery Manager: Release 11.2.0.2.0 - Production on Mon Dec 3 18:09:25 2012
 
 Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
 
 connected to target database: XE (DBID=2682118025)
 
 RMAN> shutdown immediate;
 
 using target database control file instead of recovery catalog
 database closed
 database dismounted
 Oracle instance shut down
 
 RMAN> startup mount
 
 connected to target database (not started)
 Oracle instance started
 database mounted
 
 Total System Global Area     417546240 bytes
 
 Fixed Size                     2227080 bytes
 Variable Size                289408120 bytes
 Database Buffers             121634816 bytes
 Redo Buffers                   4276224 bytes
 
 RMAN> backup database;
 
 Starting backup at 03-DEC-12
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=19 device type=DISK
 channel ORA_DISK_1: starting full datafile backup set
 channel ORA_DISK_1: specifying datafile(s) in backup set
 input datafile file number=00002 name=/u01/app/oracle/oradata/XE/sysaux.dbf
 input datafile file number=00001 name=/u01/app/oracle/oradata/XE/system.dbf
 input datafile file number=00004 name=/u01/app/oracle/oradata/XE/users.dbf
 input datafile file number=00003 name=/u01/app/oracle/oradata/XE/undotbs1.dbf
 channel ORA_DISK_1: starting piece 1 at 03-DEC-12
 channel ORA_DISK_1: finished piece 1 at 03-DEC-12
 piece handle=/u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_nnndf_TAG20121203T181125_8ctddzor_.bkp tag=TAG20121203T181125 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
 channel ORA_DISK_1: starting full datafile backup set
 channel ORA_DISK_1: specifying datafile(s) in backup set
 including current control file in backup set
 including current SPFILE in backup set
 channel ORA_DISK_1: starting piece 1 at 03-DEC-12
 channel ORA_DISK_1: finished piece 1 at 03-DEC-12
 piece handle=/u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_ncsnf_TAG20121203T181125_8ctdgj5f_.bkp tag=TAG20121203T181125 comment=NONE
 channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
 Finished backup at 03-DEC-12
 
 RMAN> shutdown immediate;
 
 database dismounted
 Oracle instance shut down
 
 RMAN> exit
 
 
 Recovery Manager complete.

Nesse momento, o banco foi apagado, incluindo o spfile

Iniciando o banco de dados para recuperação

 [oracle@bambu ~]$ rman target /
 
 Recovery Manager: Release 11.2.0.2.0 - Production on Mon Dec 3 18:58:21 2012
 
 Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
 
 connected to target database (not started)
 
 RMAN> startup nomount;
 
 startup failed: ORA-01078: failure in processing system parameters
 LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/xe/dbs/initXE.ora'
 
 starting Oracle instance without parameter file for retrieval of spfile
 
 Oracle instance started
 
 Total System Global Area     158662656 bytes
 
 Fixed Size                     2224592 bytes
 Variable Size                 92278320 bytes
 Database Buffers              58720256 bytes
 Redo Buffers                   5439488 bytes
 
 RMAN> 

Efetuando o restore do SPFILE

 RMAN> set dbid 2682118025
 
 executing command: SET DBID
 
 RMAN>
 RMAN> restore spfile from '/u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_ncsnf_TAG20121203T181125_8ctdgj5f_.bkp';
 
 Starting restore at 03-DEC-12
 using channel ORA_DISK_1
 
 channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_ncsnf_TAG20121203T181125_8ctdgj5f_.bkp
 channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
 Finished restore at 03-DEC-12
 
 RMAN> shutdown immediate;
 
 Oracle instance shut down
 
 RMAN> startup nomount;
 
 connected to target database (not started)
 Oracle instance started
 
 Total System Global Area     417546240 bytes
 
 Fixed Size                     2227080 bytes
 Variable Size                289408120 bytes
 Database Buffers             121634816 bytes
 Redo Buffers                   4276224 bytes
 
 RMAN>

Efetuando o restore do CONTROLFILE

 RMAN> restore controlfile from '/u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_ncsnf_TAG20121203T181125_8ctdgj5f_.bkp';
 
 Starting restore at 03-DEC-12
 using channel ORA_DISK_1
 
 channel ORA_DISK_1: restoring control file
 channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
 output file name=/u01/app/oracle/oradata/XE/control.dbf
 Finished restore at 03-DEC-12
 
 RMAN> alter database mount;
 
 database mounted
 released channel: ORA_DISK_1
 
 RMAN>

Efetuando o restore do banco de dados

 RMAN> restore database;
 
 Starting restore at 03-DEC-12
 Starting implicit crosscheck backup at 03-DEC-12
 allocated channel: ORA_DISK_1
 channel ORA_DISK_1: SID=19 device type=DISK
 Crosschecked 1 objects
 Finished implicit crosscheck backup at 03-DEC-12
 
 Starting implicit crosscheck copy at 03-DEC-12
 using channel ORA_DISK_1
 Finished implicit crosscheck copy at 03-DEC-12
 
 searching for all files in the recovery area
 cataloging files...
 cataloging done
 
 List of Cataloged Files
 =======================
 File Name: /u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_ncnnf_TAG20121203T181251_8ctdhok3_.bkp
 File Name: /u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_ncsnf_TAG20121203T181125_8ctdgj5f_.bkp
 File Name: /u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_nnsnf_TAG20121203T181258_8ctdhv1c_.bkp
 
 using channel ORA_DISK_1
 
 channel ORA_DISK_1: starting datafile backup set restore
 channel ORA_DISK_1: specifying datafile(s) to restore from backup set
 channel ORA_DISK_1: restoring datafile 00001 to /u01/app/oracle/oradata/XE/system.dbf
 channel ORA_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/XE/sysaux.dbf
 channel ORA_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/XE/undotbs1.dbf
 channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/XE/users.dbf
 channel ORA_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_nnndf_TAG20121203T181125_8ctddzor_.bkp
 channel ORA_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/XE/backupset/2012_12_03/o1_mf_nnndf_TAG20121203T181125_8ctddzor_.bkp tag=TAG20121203T181125
 channel ORA_DISK_1: restored backup piece 1
 channel ORA_DISK_1: restore complete, elapsed time: 00:00:46
 Finished restore at 03-DEC-12
 
 RMAN>

Abrindo o banco de dados para uso

 RMAN> alter database open resetlogs;
 
 database opened
 
 RMAN> exit
 
 
 Recovery Manager complete.

Confirmando se o banco de dados está OPEN

 [oracle@host0916 ~]$ sqlplus /nolog
 
 SQL*Plus: Release 11.2.0.2.0 Production on Mon Dec 3 18:15:40 2012
 
 Copyright (c) 1982, 2011, Oracle.  All rights reserved.
 
 SQL> conn / as sysdba
 Connected.
 SQL> select status from v$instance;
 
 STATUS
 ------------
 OPEN
 
 SQL> exit
 Disconnected from Oracle Database 11g Express Edition Release 11.2.0.2.0 - 64bit Production
 [oracle@host0916 ~]$ 

Como demonstrado, uma recuperação completa de um backup consistente é simples e funcional.

Quão útil foi este post ?

Clique em uma estrela para classificar o post

nota média 4.5 / 5. Contagem de votos: 29

Sem votos ! Seja o primeiro a classificar !

Deixe um comentário

O seu endereço de e-mail não será publicado. Campos obrigatórios são marcados com *

plugins premium WordPress