Anda di halaman 1dari 13

ASM HANDS-ON TRAINING

Lab 11 Restoring a Lost Database from Backup


Alejandro Vargas | Principal Support Consultant Oracle Advanced Customer Services

INDEX

Summary.......................................................................................................................................................................2 Lab Preparation.............................................................................................................................................................2 Backup and Restore of ASM Metadata.........................................................................................................................3 Backup ASM metadata..................................................................................................................................................3 Restore ASM metadata.................................................................................................................................................3 Restore the 11g Database............................................................................................................................................6 Startup nomount the database......................................................................................................................................7 Restore the Spfile to ASM.............................................................................................................................................8 Restart the Instance with the Restored Spfile ..............................................................................................................9 Restore the Controlfile ..................................................................................................................................................9 Mount the Database....................................................................................................................................................10 Restore the Database.................................................................................................................................................10 Open the Database.....................................................................................................................................................11

1/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
Summary
To work on the 11g part of the Labs we will start restoring an 11g database we have on a backup. The backup consist of an incremental level 0 backupset, a controlfile and spfile backup and the archived logs required to recover the database. The restore is done in 6 steps Re-create the ASM metada Restore the spfile Restore the controlfile Restore the datafiles Recover the database Open resetlogs

Lab Preparation
To prepare the diskgroup DATADGNR AND FRADG for this lab we will remove all data from them [oracle@asmxpt ~]$ asmcmd ASMCMD> ls ARCHDG/ DATADG/ DATADGNR/ DATAONFS/ FRADG/ ASMCMD> rm -rf DATADGNR/* ASMCMD> rm -rf fradg/* 2/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
ASMCMD> ls -l DATADGNR ASMCMD> ls -l FRADG

Backup and Restore of ASM Metadata Backup ASM metadata


The ASM metadata was backed up when the database was functional. ASMCMD> md_backup -b /u01/app/oracle/BACKUP/sati11/asm_md_backup -g 'DATADGNR','FRADG' Disk group to be backed up: DATADGNR Disk group to be backed up: FRADG Current alias directory path: SATI11/TEMPFILE Current alias directory path: SATI11/CONTROLFILE Current alias directory path: SATI11/DATAFILE Current alias directory path: SATI11 Current alias directory path: SATI11/ONLINELOG Current alias directory path: SATI11/PARAMETERFILE Current alias directory path: SATI11/AUTOBACKUP Current alias directory path: SATI11 Current alias directory path: SATI11/AUTOBACKUP/2009_02_12

Restore ASM metadata


To restore ASM metadata we use the 11g command md_restore, the following options are available to the md_restore command, the highlighted option indicate the sintax we will use in this lab. ASMCMD> help md_restore 3/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
md_restore -b <backup_file> [-li] [-t (full)|nodg|newdg] [-f <sql_script_file>] [-g '<diskgroup_name>,<diskgroup_name>,...'] [-o '<old_diskgroup_name>:<new_diskgroup_name>,...'] Perform ASM Metadata restore for disk groups. -b Read metadata information from <backup_file>. -l Print messages to a file (Not implemented). -i Ignore errors. Normally if md_restore encounters an error, it will stop. Specifying this flag ignores that. -t Specify diskgroup creation. full - create disk group and restore metadata. nodg - restore metadata only. newdg - create disk group with a different name and restore metadata; -o is required. -f Write SQL commands to <sql_script_file> instead of executing them. -g Select the disk groups to be restored. If no disk groups defined, all of them will be restored. -o Rename disk group <old_diskgroup_name> to <new_diskgroup_name>.
The backup we will use contains the metadata of the data and fra diskgroups as it was when the 11g database was active, the disk structure remained the same, because of that we will use the option t nodg that prevent diskgroup creation and restore metadata into existing diskgroups

[oracle@asmxpt sati11]$ asmcmd md_restore -b /u01/app/oracle/BACKUP/sati11/asm_md_backup t nodg Current Diskgroup being restored: DATADGNR System template TEMPFILE modified! System template DUMPSET modified! System template XTRANSPORT modified! System template DATAFILE modified! System template ARCHIVELOG modified! 4/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
System template ASM_STALE modified! System template CHANGETRACKING modified! System template ONLINELOG modified! System template FLASHBACK modified! System template AUTOBACKUP modified! System template DATAGUARDCONFIG modified! System template PARAMETERFILE modified! System template CONTROLFILE modified! System template BACKUPSET modified! Directory +DATADGNR/SATI11 re-created! Directory +DATADGNR/SATI11/CONTROLFILE re-created! Directory +DATADGNR/SATI11/ONLINELOG re-created! Directory +DATADGNR/SATI11/DATAFILE re-created! Directory +DATADGNR/SATI11/TEMPFILE re-created! Directory +DATADGNR/SATI11/PARAMETERFILE re-created! Current Diskgroup being restored: FRADG System template DATAGUARDCONFIG modified! System template DUMPSET modified! System template XTRANSPORT modified! System template DATAFILE modified! System template ARCHIVELOG modified! System template TEMPFILE modified! System template CHANGETRACKING modified! System template ONLINELOG modified! System template AUTOBACKUP modified! System template FLASHBACK modified! System template PARAMETERFILE modified! System template CONTROLFILE modified! System template BACKUPSET modified! Directory +FRADG/SATI11 re-created! Directory +FRADG/SATI11/AUTOBACKUP re-created! 5/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
Directory +FRADG/SATI11/AUTOBACKUP/2009_02_12 re-created!
Now we can check the metadata inside ASM ASMCMD> lsdg
State MOUNTED MOUNTED MOUNTED MOUNTED MOUNTED Type EXTERN EXTERN NORMAL EXTERN EXTERN Rebal N N N N N Sector 512 512 512 512 512 Block 4096 4096 4096 4096 4096 AU 1048576 1048576 1048576 1048576 1048576 Total_MB 1000 1000 8188 2000 6141 Free_MB 947 948 8080 1944 6086 Req_mir_free_MB 0 0 2047 0 0 Usable_file_MB 947 948 3016 1944 6086 Offline_disks 0 0 0 0 0 Name ARCHDG/ DATADG/ DATADGNR/ DATAONFS/ FRADG/

ASMCMD> ls -l DATADGNR/SATI11/ Type Redund Striped Time

ASMCMD> ls -l FRADG/SATI11 Type Redund Striped Time

Sys N N N N N Sys N

Name CONTROLFILE/ DATAFILE/ ONLINELOG/ PARAMETERFILE/ TEMPFILE/ Name AUTOBACKUP/

Restore the 11g Database


We set the ORACLE_SID variable to sati11 and initiate an Rman session, we wrote the DBID on a logfile before removing the database. [oracle@asmxpt ~]$ cd /u01/app/oracle/BACKUP/sati11 [oracle@asmxpt sati11]$ ls -ltr total 2130628 -rw-r----- 1 oracle dba 1070153728 Feb 12 17:31 01k76mof_1_1 -rw-r----- 1 oracle dba 9830400 Feb 12 17:32 02k76mst_1_1 -rw-r----- 1 oracle dba 9797632 Feb 12 17:37 03k76n73_1_1 6/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
-rw-r--r--rw-r--r--rw-r--r--rw-r--r-1 1 1 1 oracle oracle oracle oracle dba 1023 Feb 12 dba 1089792000 Feb 12 dba 22222 Feb 12 dba 268 Feb 12 17:38 17:43 18:02 18:08 initsati11.ora.bk sati11.backup asm_md_backup dbid_124143874.lst

Setup the DBID on Rman ORACLE_SID=sati11 [oracle@asmxpt sati11]$ rman target / Recovery Manager: Release 11.1.0.7.0 - Production on Fri Feb 13 08:58:21 2009 Copyright (c) 1982, 2007, Oracle. All rights reserved.

connected to target database (not started) RMAN> set dbid=124143874 executing command: SET DBID

Startup nomount the database.


The pfile on ORACLE_HOME/dbs points to the spfile inside ASM that does not exist at this point. Still Rman will permit to start an auxiliary instance using predefined internal parameter values RMAN> startup nomount;

7/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
startup failed: ORA-01078: failure in processing system parameters ORA-01565: error in identifying file '+DATADGNR/sati11/spfilesati11.ora' ORA-17503: ksfdopn:2 Failed to open file +DATADGNR/sati11/spfilesati11.ora ORA-15056: additional error message ORA-17503: ksfdopn:DGOpenFile05 Failed to open file +DATADGNR/sati11/spfilesati11.ora ORA-17503: ksfdopn:2 Failed to open file +DATADGNR/sati11/spfilesati11.ora ORA-15173: entry 'spfilesati11.ora' does not exist in directory 'sati11' ORA-06512: at line 4 starting Oracle instance without parameter file for retrieval of spfile Oracle instance started Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers 159019008 bytes 1312052 67111628 88080384 2514944 bytes bytes bytes bytes

Restore the Spfile to ASM


In this case we have a a current controlfile backup on the /u01/app/oracle/BACKUP/sati11 directory. RMAN> RESTORE SPFILE FROM '/u01/app/oracle/BACKUP/sati11/02k76mst_1_1';

Starting restore at 13-FEB-09 using channel ORA_DISK_1 channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/BACKUP/sati11/02k76mst_1_1 channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete 8/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
Finished restore at 13-FEB-09

Restart the Instance with the Restored Spfile


Once the spfile is restored to its original place on ASM we can restart the instance, we use the force option that actually does a shutdown and startup RMAN> STARTUP FORCE NOMOUNT; Oracle instance started Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers 351522816 bytes 1313344 281019840 62914560 6275072 bytes bytes bytes bytes

Restore the Controlfile


The controlfile was backed up on the same backupset where the spfile was located RMAN> RESTORE CONTROLFILE FROM '/u01/app/oracle/BACKUP/sati11/03k76n73_1_1'; Starting restore at 13-FEB-09 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=151 device type=DISK channel ORA_DISK_1: restoring control file channel ORA_DISK_1: restore complete, elapsed time: 00:00:08 9/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
output file name=+DATADGNR/sati11/controlfile/current.258.678705843 output file name=+DATADGNR/sati11/controlfile/current.257.678705845 Finished restore at 13-FEB-09

Mount the Database


Having the controlfile we can mount the database RMAN> ALTER DATABASE MOUNT; database mounted released channel: ORA_DISK_1

Restore the Database


The information of the database backupset is located on the controlfile we can issue the restore command directly, it will find the required backups if they are located in the same directory where they were made and catalogued. This backup was made as a consistent backup with the database mounted, so there is no need to apply any archived logs to open the database. RMAN> RESTORE DATABASE; Starting restore at 13-FEB-09 Starting implicit crosscheck backup at 13-FEB-09 allocated channel: ORA_DISK_1 channel ORA_DISK_1: SID=151 device type=DISK Crosschecked 2 objects Finished implicit crosscheck backup at 13-FEB-09 Starting implicit crosscheck copy at 13-FEB-09 10/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
using channel ORA_DISK_1 Finished implicit crosscheck copy at 13-FEB-09 searching for all files in the recovery area cataloging files... no files cataloged 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 channel channel channel channel channel ORA_DISK_1: ORA_DISK_1: ORA_DISK_1: ORA_DISK_1: ORA_DISK_1: ORA_DISK_1: restoring datafile 00001 to +DATADGNR/sati11/datafile/system.260.678630385 restoring datafile 00002 to +DATADGNR/sati11/datafile/sysaux.261.678630415 restoring datafile 00003 to +DATADGNR/sati11/datafile/undotbs1.259.678630429 restoring datafile 00004 to +DATADGNR/sati11/datafile/users.257.678630483 reading from backup piece /u01/app/oracle/BACKUP/sati11/01k76mof_1_1 piece handle=/u01/app/oracle/BACKUP/sati11/01k76mof_1_1 tag=TAG20090212T172950

channel ORA_DISK_1: restored backup piece 1 channel ORA_DISK_1: restore complete, elapsed time: 00:03:46 Finished restore at 13-FEB-09

Open the Database


As I mentioned before this database was backed up while closed so there is no need to perform recovery. It can be opened directly using the resetlogs option. RMAN> ALTER DATABASE OPEN RESETLOGS; database opened We can check how it looks and run some queries to see if the database is working 11/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
[oracle@asmxpt sati11]$ ora ------------ORACLE_BASE=/u01/app/oracle ORACLE_HOME=/u01/app/oracle/11g_db ORACLE_SID=sati11 ------------oracle 6462 1 0 09:24 ? oracle 8904 1 0 Feb12 ? ------------oracle 8693 1 0 Feb12 ?

00:00:02 ora_smon_sati11 00:00:02 asm_smon_+ASM

00:00:17 /u01/app/oracle/11g_db/bin/tnslsnr LISTENER_ASMXPT -inherit

------------[oracle@asmxpt sati11]$ sql SQL*Plus: Release 11.1.0.7.0 - Production on Fri Feb 13 09:46:35 2009 Copyright (c) 1982, 2008, Oracle. All rights reserved.

Connected to: Oracle Database 11g Enterprise Edition Release 11.1.0.7.0 - Production With the Partitioning, OLAP, Data Mining and Real Application Testing options SQL> select file_name from dba_data_files; FILE_NAME -------------------------------------------------------------------------------+DATADGNR/sati11/datafile/system.259.678706167 +DATADGNR/sati11/datafile/sysaux.261.678706169 +DATADGNR/sati11/datafile/undotbs1.260.678706169 +DATADGNR/sati11/datafile/users.268.678706171 12/13

ASM HANDS-ON TRAINING


Lab 11 Restoring a Lost Database from Backup
End of Lab 11

13/13

Anda mungkin juga menyukai