Skip to content

Posts from the ‘Backup & Recovery’ Category

RMAN-06059: expected archived log not found

When i try to take backup of archive log all using rman, it shows below error.

RMAN-00571: ========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ============
RMAN-00571: ========================================================
RMAN-03002: failure of backup command at 03/29/2010 12:20:05
RMAN-06059: expected archived log not found, lost of archived log co
coverability
ORA-19625: error identifying file D:\ORACLE\PRODUCT\10.2.0\FLASH_REC
ROKER\ARCHIVELOG\2010_03_25\O1_MF_1_257_5TQF22HV_.ARC
ORA-27041: unable to open file
OSD-04002: unable to open file
O/S-Error: (OS 2) The system cannot find the file specified.

Here what was the problem is, I was moved the archive log file using cut & paste when FRA location is fulled and then i changed the archive log destination also.In this case when i try to take backup of archive log ,the controlfile will search the oldest file on same location but it was missed, so that the system cannot find the file specified.

But i don’t want previous backup archive log.SO i try to fix following steps,Its ok now.

Step 1:

rman>crosscheck archivelog all;

Step 2:

rman>delete expired archivelog all;

Step 3:

rman>backup archivelog all;

input archive log thread=1 sequence=647 recid=400 stamp=714934627
channel ORA_DISK_1: starting piece 1 at 29-MAR-10
channel ORA_DISK_1: finished piece 1 at 29-MAR-10
piece handle=H:\RMAN\BROKER\BROKER714934764_S14_S1 tag=TAG20100329T165708 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:07
Finished backup at 29-MAR-10

Starting Control File and SPFILE Autobackup at 29-MAR-10
piece handle=D:\ORACLE\PRODUCT\FLASHRECOVERY\BROKER\AUTOBACKUP\2010_03_29\O1_MF_
S_714934832_5V1DN201_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 29-MAR-10.

Now backup finished.

RMAN: Create Catalog

How to create catalog for rman backup.I just provided here for step by step create catalog.

Detecting and Recovering from database Corruption :-

Block Corruption :-

Block may be corrupted in two ways

  • Media corruption
  • Logical Corruption.

Media Corruption :-

  • A media corrupt block is a block where the contents of the block make no sense whatsoever: its contents do not match the format expected by oracle, according to the formatting rules for the tablespace and the objects within it.
  • When a datafile is created, it is formatted into Oracle blocks ,of whatever block size was chosen for the tablespace.This is the first level of formatting.
  • A second level occurs when the blcok is actually used.When an object is allocated an extent, the blocks in the extent are not further formatted, but as the high water mark of the object is advanced into the new extent, then the blocks receive a second level of formatting, as they take on the chrateristics required for that particular segment.
  • If,because of damage to the disks, this formatting is lost, then the block will be ‘media corrupt’.

Logical corruption :-

  • Where the Oracle formatting is correct – the block does have the correct header area and a data area – but the contents of the block are internally inconsistent.
  • For example, the block header of a table block includes a row directory, stating where each row begins.
  • If when attempting to find a row, there isn’t one, this will be a logical corruption – an Oracle internal Error-rather that a media problem.

Parameter Relating to Block Corruption :-

DB_BLOCK_CHECKSUM
DB_BLOCK_CHECKING

  • DB_BLOCK_CHECKSUM on TRUE,whenever the DBWn process writes a block to disk it will compute a checksum for the block and include it in the block header.
  • when a server reads a block, if the checksum is present it will recalculate it and compare.
  • This will mean that any damage occuring in the time between the DBWn writing the block and its being read back will be detected.
  • Even when this parameter is on false, checksumming is still enabled for the system tablespace.
  • DB_BLOCK_CHECKING to TRUE will have impact on performance,
    and Oracle advises leaving it on default unless there are specific problems related to corruptions occuring in memory.
  • When set to TRUE, the ORacle block will check the block for consistency every time the buffer containing the block is accessed.
  • This will mean that if corruptions are occuring in memory, they will be detected immediately but the price is high-perhaps as much as 10 percent of processing cappacity.
  • Oracle Corporation advises leaving both these parameters on default, unless instructed otherwise by Oracle Support.

Detecting Block Corruptions :-

  • A corrupt block may be detected by your users when they try to read it.
  • Example :-
  • Windows based, Tablespace called DAMAGED with a datafile DAM.DBF. and a table CORRUPT_TAB, created within it. and a priamry key constraint added. Thsi caused the creation of an index, called CORR_PK, on the constrained column.
  • The file was deliberately damaged by using an editor to change a few bytes of some blocks of the CORRUPT_TAB table. May be of either media or logical corruption the file still exists and is of the correct size, but the contents have been damaged externally to ORacle. the index, however is not directly affected.

The Corrupted Block Error Message :-

Sql>select count(*) from corrupt_tab;
count(*)
——-
50

sql>select * from corrupt_tab;
select * from corrupt_tab
*
ERROR at line 1:
ORA-01578:ORACLE data block corrupted(file # 7, block # 5)
ORA-01110:data file 7: ‘C:\ORACLE\ORADATA\DAM.DBF’
sql>

  • The first query succeeds. This is because although the query appears to request a full table scan, in fact Oracle can execute the query without reading the table atall.
  • There is a primary key constraint on the table, which means that Oracle can count the number of rows by scanning the index, not the table. The second query which requires reading the table itself,fails witha na ORA_01578 error message that lists the address of the corrupted block and the messate returned to the session that detected teh problem, but there is also this message in the alert log UDUMP directory.you can identify which object id affect in the trace file.

Ex: – objd=52077
sql>select owner,object_name,object_type from dba_objects where object_id=52077;
An alternative Query to identify the object would be to match the data block address against the DBA_EXTENTS view.
sql>select owner,segment_name,segment_type from dba_extents where file_id=7 and 5 between block_id and block_id + blocks;
owner segment_name segment_type
——- ———— ————-
HR CORRUPT_TAB TABLE

Unless the corruption is in the header blocks of the datafile, it will only be detected when the block is read by a server process.

DBVERIFY Utility :-

  • An external utility run from an operating system prompt to verify datafiles.
  • It can be run against files while they are in use, or aginst image copies made with user managed backups or by rman.
  • It cannot verify online or archive redo logs, nor the contrlfile nor rman backup sets.
  • the files to be verified can exist on a conventional file system or on Automatic storage management disks or on a raw devices.

Executable –> Unix – $oracle_home/bin/dbv
windows – %oracle_home%\bin\dbv.exe

  • If “Total pages influx” is greater than zero, it is not an indication of any problem; it merely shows that while DBVERIFY was running against an open file,it encountered a block that was currently being written to by the DBWn process.
  • When that happens, it will re-read the block until it gets a consistent image. “Total Pages Influx is the number of times it had to do this.
  • If you are using rman to backup your datafiles, DBVERIFY is not needed, because RMAN will perform its own verification.
  • DBVERIFY is essential if you are using user managed backups, in order to determine that the backups are actullay usable.

C:\Documents and Settings\mazar>dbv file=D:\oracle\product\10.2.0\oradata\riyadh
\USERS01.DBF

DBVERIFY: Release 10.2.0.1.0 – Production on Tue Feb 9 15:22:25 2010

Copyright (c) 1982, 2005, Oracle. All rights reserved.

DBVERIFY – Verification starting : FILE = D:\oracle\product\10.2.0\oradata\riyad
h\USERS01.DBF

DBVERIFY – Verification complete

Total Pages Examined : 640
Total Pages Processed (Data) : 35
Total Pages Failing (Data) : 0
Total Pages Processed (Index): 2
Total Pages Failing (Index): 0
Total Pages Processed (Other): 53
Total Pages Processed (Seg) : 0
Total Pages Failing (Seg) : 0
Total Pages Empty : 550
Total Pages Marked Corrupt : 0
Total Pages Influx : 0
Highest block SCN : 1685733 (0.1685733)

C:\Documents and Settings\mazar>

The ANALYZE command :-

sql>analyze table validate structure;
sql>analyze index validate struture;
sql>analyze table validate struture cascade;

  • When validating the structure of a table, analyze verifies the integrity of each of data blocks and rows. When validating the structure of an index, it veriifes the integrity of the data blocks and the index keys.
  • The cascade option will verify both the table and any associated indexes.
  • CASCADE can be a very time consuming process for large objects because it checks to ensure each index entry points to a valid table row.

ANALYZE..VALID STRUTURE are that for partitioned tables it will check that rows are in the correct partition ,and for indexes it will compute the ratio of space devoted to active index entries and space wasted because the index entries refer to deleted rows. VIEW INDEX_STATS.

DBMS_REPAIR Package :-

DBMS_REPAIR is a set of procedures that will check objects for problems and make the objects usable again.

DBMS_REPAIR Procedures

The following table lists the procedures included in the DBMS_REPAIR package.

Procedure Name Description
ADMIN_TABLES Provides administrative functions (create, drop, purge) for repair or orphan key tables.Note: These tables are always created in the SYS schema.
CHECK_OBJECT Detects and reports corruptions in a table or index
DUMP_ORPHAN_KEYS Reports on index entries that point to rows in corrupt data blocks
FIX_CORRUPT_BLOCKS Marks blocks as software corrupt that have been previously identified as corrupt by the CHECK_OBJECT procedure
REBUILD_FREELISTS Rebuilds the free lists of the object
SEGMENT_FIX_STATUS Provides the capability to fix the corrupted state of a bitmap entry when segment space management is AUTO
SKIP_CORRUPT_BLOCKS When used, ignores blocks marked corrupt during table and index scans. If not used, you get error ORA-1578 when encountering blocks marked corrupt.

Comparison of Corruption Detection Methods

Detection Method Description
DBMS_REPAIR PL/SQL package Performs block checking for a specified table, partition, or index. It populates a repair table with results.
DB_VERIFY utility Performs block checking on an offline database
ANALYZE TABLE SQL statement Used with the VALIDATE STRUCTURE option, the ANALYZE TABLE statement verifies the integrity of the structure of an index, table, or cluster; checks or verifies that tables and indexes are synchronized.
DB_BLOCK_CHECKING initialization parameter When DB_BLOCK_CHECKING=TRUE, corrupt blocks are identified before they are marked corrupt. Checks are performed when changes are made to a block.

Step 1: Create a repair table
BEGIN
DBMS_REPAIR.ADMIN_TABLES (
     TABLE_NAME => ‘REPAIR_TABLE’,
     TABLE_TYPE => dbms_repair.repair_table,
     ACTION     => dbms_repair.create_action,
     TABLESPACE => ‘USERS’);
END;
/

desc repair_table;

query select tablespace_id, schema_name, object_name, block_id from repair_Table;

SET SERVEROUTPUT ON
DECLARE num_corrupt INT;
BEGIN
num_corrupt := 0;
DBMS_REPAIR.CHECK_OBJECT (
     SCHEMA_NAME => ‘SCOTT’,
     OBJECT_NAME => ‘DEPT’,
     REPAIR_TABLE_NAME => ‘REPAIR_TABLE’,
     CORRUPT_COUNT =>  num_corrupt);
DBMS_OUTPUT.PUT_LINE(‘number corrupt: ‘ || TO_CHAR (num_corrupt));
END;
/

SELECT OBJECT_NAME, BLOCK_ID, CORRUPT_TYPE, MARKED_CORRUPT,
       CORRUPT_DESCRIPTION, REPAIR_DESCRIPTION
     FROM REPAIR_TABLE;

Fixing corrupt blocks

SET SERVEROUTPUT ON
DECLARE num_fix INT;
BEGIN
num_fix := 0;
DBMS_REPAIR.FIX_CORRUPT_BLOCKS (
     SCHEMA_NAME => ‘SCOTT’,
     OBJECT_NAME=> ‘DEPT’,
     OBJECT_TYPE => dbms_repair.table_object,
     REPAIR_TABLE_NAME => ‘REPAIR_TABLE’,
     FIX_COUNT=> num_fix);
DBMS_OUTPUT.PUT_LINE(‘num fix: ‘ || TO_CHAR(num_fix));
END;
/

Skipping Corrupt Blocks

BEGIN
DBMS_REPAIR.SKIP_CORRUPT_BLOCKS (
     SCHEMA_NAME => ‘SCOTT’,
     OBJECT_NAME => ‘DEPT’,
     OBJECT_TYPE => dbms_repair.table_object,
     FLAGS => dbms_repair.skip_flag);
END;
/

Querying scott’s tables using the DBA_TABLES view shows that SKIP_CORRUPT is enabled for table scott.dept.

SELECT OWNER, TABLE_NAME, SKIP_CORRUPT FROM DBA_TABLES    WHERE OWNER = ‘SCOTT’;
…………

Recovering Corrupt Blocks with RMAN

–> If you are making user-managed backups, you cannot perform a block recovery becuase the granularity of a user managed restore is the datafile

–> If one block of a file many gigabytes big is corrupted, you must restore and recover the entire datafile through the usual.

  • Take the damaged file offline.
  • Restore the file from a backup made before the corruption occured.
  • Recover the file completely
  • Bring the recovered file online.

This can be done with zero loss, but the impact on your users ,in terms of downtime , may be enormous.

RMAN backups open the possibilty of block level restore and recovery, perhaps with no downtime at all.

Note :- Block media recovery is applicable only to datafile blocks. If a block of an online log file, an archive log file or a controlfile is coruupted. you must have a multiplexed copy available if you ever need to recover.

Detection Of Corrupt Blocks :-

–> RMAN ,being an Oracle aware tool, will verify the contents of data blocks as it reads  them; unless instructed otherwise,it wil lterminate the backup as soon as it hits a corrupt block.

–>If you wish, you can run RMAN backups that specify a tolerance for corrupted blocks. If this is done ,then rather than throwing an error and terminating the backup immediately when aa corruption is detected, RMAN will continue to backup the datafile but will record the address of any corruptions it encounters in its repository.

Example :-

Rman to continue a backup as long as no more than one hundred corrupt blocks are encountered.

RMAN>run {
set maxcorrupt for datafile 7 to 100;
backup datafile 7;}

the details of Corrupt blocks are visible in two places.

V$DATABASE_BLOCK_CORRUPTION  –> the address of the cause of the problem. the datafile and block number.

V$BACKUP_CORRUPTION  –> for backup set backups

V$COPY_CORRUPTION –>backup were to an image copy.

RMAN will always check for physical corruption, known as “media corruption” in the non RMAN world.

Example : this would be a block that oracle cannot process at all: an invalid checksum, or a block full of zeros.

RMAN can also be instructed to check for logical corruption, also known as “SOftware Corruption” as well.

These checks will occur whenever a file is backed up, whether as an image copy or into a backup set.
RMAN>backup nochecksum datafile 7;

will not check for physical corruption and

RMAN>backup check logical datafile 6;

Overview of BLock Media Recovery : BMR

–> BMR changes the granularity of  a restore and recovery operation from the datafile to just the damaged blocks.

Advantage :-

   –>The file does not have to be taken offline ; normal DML can continue.
   –> The mean time to recover is much reduced, since only the damaged blocks are involved in the operation, not the whole file. The only downtime that will occur is if a session happens to hit a block that is actully damaged and has not yet been recovered.

Process :

  • Rman will extract backups of these blocks from a backup set or an image copy and write them to the datafile.
  • Then RMAN will pass through the archive logs generated since the backup and extract redo records relevant to the restored blocks and apply them.
  • The recovery will always be complete – it would be logically impossible to do an incomplete recovery; incomplete recovery of just one block would leave the database in an inconsistent state.
  • If a session hits a corruopted block before the BMR process has completed, then it will still receive an ORA-01578 error but it is quite possible that the BMR operation will be complete before any users are aware of the problem.
  • BMR can be applied to any data block whatsoever: Unlike DBMS_REPAIR, it is not restircted to tables and indexes; LOB and UNDO segments can also be block recovered.

Block Recover Command :

The block recover command always specifies a list of one or more blocks to be restored and recoverd.

RMAN>blockrecover datafile 7 block 5;
RMAN to restore and recover the one specified block from the most recent backup set or image copy of the file

RMAN>blockrecover datafile 7 block 5,6,7 datafile 9 block 21,25;

There may be doubt regarding 7 block 5 from backupset 1093;

Will restore from the nominated backup set, which could also be specified by a tag:

RMAN>blockrecover datafile 7 block 5 from tag monthly_whole;

Instructs RMAn to restore and recover every block that has been discovered to be damaged by a previous backup operation, using only backups made at least one week ago.

Note :- BMR context, the keyword UNTIL does not denote an incomplete recovery. It means that the restore must be from a backup made before a particular date ( or sequence number or SCN).

RMAN : Freeing FRA Space in an Emergency

The flashback recovery area has run out of space. You see a message in the alert log similar to the following :

Can not open flashback thread because there is no more space in flash recovery area.

sql>alter database open;
alter database open
*
ERROR at line 1:
ORA-38760 : This database instance failed to turn on flashback database.

Solution :

1.Increase space:-

You can increase the size of the flashback area.

sql>alter system set db_recovery_file_dest_size=10G;

2.Remove Restore Points

The alternative to increasing the size of the flashback area is to remove some of the older restore points that you no longer need.

sql>col name format a25
sql>select name , storage_size from v$restore_points;
Name                              Storage_size
RP0                                207028224
RP1                                                0
RP2                                915701760
PRE_TEST1                                    0
POST_TEST1                                  0
GOOD_ONE                                   0
QA_GOLD                                      0
BRANCH_1                                    0
AFTER_BRANCH_2                        0
AFTER_BRANCH_3                        0

10 rows selected.

restore points RP0 and RP2 have torage associated with them.this is because guaranteed restore points. You should remove them to make some room in the flash recovery area.

sql>drop restore point rp2;

Restore point dropped.

sql>drop restore point rp0;

Restore poing rp0;

Restore point dropped.

you may be able to start the database.
3.Disable Flashback

If solutions 1 and 3 fail or not applicable, you may want to disable flashback in the database temporarily.

sql>shutdown immediate

Oracle instance shutdown.

sql>startup mount

Database mounted.

sql>alter database flashback off;
Database altered.

This will stop the flashback operations and will stop generating flashback logs. To free up some space , you may want to delete some more files such as archived redo logs, unneeded backups and so on.

$ rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Wed Dec 23 14:20:52 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: RIYADH (DBID=3624306176)

RMAN> delete noprompt archivelog all;

using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=153 devtype=DISK

List of Archived Log Copies
Key     Thrd Seq     S Low Time  Name
——- —- ——- – ——— —-
1       1    2       A 28-OCT-09 D:\ORACLE\ARCHIVE_01\ARC00002_0701448453.001
2       1    2       A 28-OCT-09 D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RI
YADH\ARCHIVELOG\2009_12_19\O1_MF_1_2_5LRWHYC7_.ARC
3       1    3       A 19-DEC-09 D:\ORACLE\ARCHIVE_01\ARC00003_0701448453.001
4       1    3       A 19-DEC-09 D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RI
YADH\ARCHIVELOG\2009_12_20\O1_MF_1_3_5LVJOJ5C_.ARC
5       1    4       A 20-DEC-09 D:\ORACLE\ARCHIVE_01\ARC00004_0701448453.001
6       1    4       A 20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RI
YADH\ARCHIVELOG\2009_12_23\O1_MF_1_4_5M3FN1N0_.ARC
7       1    5       A 23-DEC-09 D:\ORACLE\ARCHIVE_01\ARC00005_0701448453.001
deleted archive log
archive log filename=D:\ORACLE\ARCHIVE_01\ARC00002_0701448453.001 recid=1 stamp=
706008375
deleted archive log
archive log filename=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\ARCHIVE
LOG\2009_12_19\O1_MF_1_2_5LRWHYC7_.ARC recid=2 stamp=706008375
deleted archive log
archive log filename=D:\ORACLE\ARCHIVE_01\ARC00003_0701448453.001 recid=3 stamp=
706094569
deleted archive log
archive log filename=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\ARCHIVE
LOG\2009_12_20\O1_MF_1_3_5LVJOJ5C_.ARC recid=4 stamp=706094569
deleted archive log
archive log filename=D:\ORACLE\ARCHIVE_01\ARC00004_0701448453.001 recid=5 stamp=
706353596
deleted archive log
archive log filename=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\ARCHIVE
LOG\2009_12_23\O1_MF_1_4_5M3FN1N0_.ARC recid=6 stamp=706353596
deleted archive log
archive log filename=D:\ORACLE\ARCHIVE_01\ARC00005_0701448453.001 recid=7 stamp=
706370138
Deleted 7 objects.

Similarly…

RMAN>delete noprompt backup of database;
RMAN>delete noprompt copy of database;

sql>alter database open;
Database altered.

The database is now fully functional , but without the flashback ability. if you want to reenable flashback later ,you can do. because you’ve cleared unneeded files, the flash recovery area is fully usable whenever you choose to againg enable flashback.

I asked Mr.Surachart about Restore Point…

Mohamed Says : What is Restore point?
Surachart Says : A restore point is a user defined name that can be substituted for an SCN or clock time when used in conjuction with flashback database, flashback table and RMAN.

Mohamed Says : If i am go to delete restore point means m what’s happen?

Surachart Says : If you delete restore point , flashback not guarantee to that time or scn.

RMAN 2.2 Connecting to RMAN and BASIC Backup

To connect to RMAN, you need to establish the following

  • OS Environement Variables.
  • Access to a privileged OS account or schema with sysdba privilege.

You can connect to RMAN either the OS command line interface or through EM.

The following examples assumes you have on to a UNIX and Windows server using the Oracle account .

$ rman target / on Unix.

cmd>rman target /   on Windows.

You must connect to RMAN with either a user that is OS authenticated or a username /pasword that is in the password file.

 While connected as  RMAN, you can startup and shutdown your target database.

C:\Documents and Settings\AZAR>set oracle_sid=riyadh

C:\Documents and Settings\AZAR>rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Sun Dec 20 11:56:33 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup

Oracle instance started
database mounted
database opened

Total System Global Area     247463936 bytes

Fixed Size                     1248332 bytes
Variable Size                 79692724 bytes
Database Buffers             159383552 bytes
Redo Buffers                   7139328 bytes

RMAN> shutdown immediate

using target database control file instead of recovery catalog
database closed
database dismounted
Oracle instance shut down

RMAN>exit

Backup & Restore Database

$rman target /
RMAN messages displaying information about which files are being backed up and wo which file and location.

RMAN> backup database;

Starting backup at 20-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=139 devtype=DISK
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSTEM01.D
BF
input datafile fno=00003 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSAUX01.D
BF
input datafile fno=00002 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\UNDOTBS01.
DBF
input datafile fno=00004 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USERS01.DB
F
channel ORA_DISK_1: starting piece 1 at 20-DEC-09
channel ORA_DISK_1: finished piece 1 at 20-DEC-09
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSET\2009_
12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.BKP tag=TAG20091220T123746 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:18
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current control file in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 20-DEC-09
channel ORA_DISK_1: finished piece 1 at 20-DEC-09
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSET\2009_
12_20\O1_MF_NCSNF_TAG20091220T123746_5LVW5VJ3_.BKP tag=TAG20091220T123746 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:05
Finished backup at 20-DEC-09

To display information about your backup, use the list backup commands.

RMAN> list backup;
List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
1       Full    517.96M    DISK        00:01:09     20-DEC-09
        BP Key: 1   Status: AVAILABLE  Compressed: NO  Tag: TAG20091220T123746
        Piece Name: D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSE
T\2009_12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.BKP
  List of Datafiles in backup set 1
  File LV Type Ckp SCN    Ckp Time  Name
  —- — —- ———- ——— —-
  1       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYST
EM01.DBF
  2       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\UNDO
TBS01.DBF
  3       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSA
UX01.DBF
  4       Full 629209     20-DEC-09 D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USER
S01.DBF

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
——- —- — ———- ———– ———— —————
2       Full    6.80M      DISK        00:00:03     20-DEC-09
        BP Key: 2   Status: AVAILABLE  Compressed: NO  Tag: TAG20091220T123746
        Piece Name: D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSE
T\2009_12_20\O1_MF_NCSNF_TAG20091220T123746_5LVW5VJ3_.BKP
  Control File Included: Ckp SCN: 629239       Ckp time: 20-DEC-09
  SPFILE Included: Modification time: 20-DEC-09

RMAN>

 Oracle recommand that you set the NLS_DATE_FORMAT-DD-MON-RRRR HH24:MI:SS AT os LEVEL.

RMAN will allocate a  channel and backup to a default location on disk.

Simulating a Media Failure and  Restore and Recover database :

To simulate media failure, you can rename a datafile at the OS level on your target database server, when starts up, it reads the control file and compares the information to all the datafiles.

C:\Documents and Settings\AZAR>move D:\oracle\product\10.2.0\oradata\riyadh\US
ERS01.DBF D:\oracle\product\10.2.0\oradata\riyadh\USERS01.bk

or

Unix –> $ mv  /oracle/RIYADH/users01.dbf      /oracle/RIYADH/users.bk

C:\Documents and Settings\AZAR>rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Sun Dec 20 12:57:15 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database (not started)

RMAN> startup

Oracle instance started
database mounted
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 12/20/2009 12:57:33
ORA-01157: cannot identify/lock data file 4 – see DBWR trace file
ORA-01110: data file 4: ‘D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USERS01.DBF’

RMAN> exit
Recovery Manager complete.

Restore and Recover :

  • Restore is the process of copying backup datafiles from the backup files.
  • Recovery is the process of applying transaction information to the datafiles to recover them to the state were in just before the failure occured.

 

C:\Documents and Settings\AZAR>rman target /

Recovery Manager: Release 10.2.0.1.0 – Production on Sun Dec 20 12:58:03 2009

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: RIYADH (DBID=3624306176, not open)

RMAN> restore database;

Starting restore at 20-DEC-09
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=157 devtype=DISK

channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSTEM01.DBF

restoring datafile 00002 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\UNDOTBS01.DB
F
restoring datafile 00003 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\SYSAUX01.DBF

restoring datafile 00004 to D:\ORACLE\PRODUCT\10.2.0\ORADATA\RIYADH\USERS01.DBF
channel ORA_DISK_1: reading from backup piece D:\ORACLE\PRODUCT\10.2.0\FLASH_REC
OVERY_AREA\RIYADH\BACKUPSET\2009_12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece handle=D:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\RIYADH\BACKUPSET\2009_
12_20\O1_MF_NNNDF_TAG20091220T123746_5LVW3H3F_.BKP tag=TAG20091220T123746
channel ORA_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 20-DEC-09

RMAN> recover database;

Starting recover at 20-DEC-09
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:06

Finished recover at 20-DEC-09

RMAN> alter database open;

database opened.


 

 

RMAN 2.1 Toggling Archivelog Mode

Problem

You attempted to use RMAN to backup your database and  received this error message.

RMAN – 03009 : failure of backup command on ORA_DISK_1 channel.
ORA- 19602 : cannot backup or copy active file in NOARCHIVELOG mode.

This message indicates that before you can create an RMAN online backup, you need to place your database into archivelog mode.

Solution:

Enabling Archivelog Mode

sql>connect / as sysdba
sql>shutdown immediate
sql>startup mount
sql>alter database archivelog;
sql>alter database open;

Displaying Archive Inforamtion

sql> select log_mode from v$database;

log_mode

Archivelog

Disabling Archivelogmode :

sql>shutdown immediate
sql>startup mount
sql>alter database noarchivelog;
sql>alter database open;
sql>select log_mode from v$database;
log_mode
Noarchivelog

Change archive log destination

sql>alter system set log_archive_dest=’c:\oracle\archive’ scope=spfile;

sql>archive log list
sql>archive log list
database log mode archive
automatic archival enable
Location ‘\orace\archive\’

How It works :

  • Online backup — Archivelogmode should be enabled.
  • Its allows you to recover all committed transactions.
  • This mode protects your database from disk failure because your transaction information can be restored and recovered from the archive log files.
  • Every online redo log switch that the contents of the logs are successfully copied to archived redo log files.
  • Oracle will not allow an online redo log file to be overwritten until it is copied to an archived redo log file.
  • If oracle cannot copy an online redo log file to an archived redo log file, then your database will stop processing and hang. so check your free space on directory.
  • No need for log_archive_start when your changing noarchive to archive in 10g.

RMAN 1.4 RMAN Architecture

RMAN Architecture

You can start performing backups with RMAN executable from the $ORACLE_HOME/bin directory.

Recovery Catalog

  1. The target database control file will always store the RMAN repository, which is the set of RMAN related backup and recovery information —> RMAN METADATA.
  2. It’s smarter to use a dedicated database to store the RAMN repository then create a special schema called the recovery catalog.
  3. Thus avoiding the risk of the critical metadata being overwritten when the control files runs out of space.
  4. Flash Recovery Area :
  5. This is a location on disk where the database will store the backup and recovery related files.
  6. MML -Media Management Layer
  7. RMAN can directly interact only with disk drives.
  8. if you want to use tape drives to store your backups, you’ll need a MML in addition to RMAN.
  9. RMAN can’t directly inteact with the tape drives.
  10. Oracle also provides Oracle Secure backup , most well integrated media management layer for RMAN backup.

Benefits of using RMAN

  1. The powerful Data Recovery Advisor Feature which enables you to easily diagonse and repair data failures and corruption.
  2. It automatically manages the backup files without DBA intervention.
  3. It automatically deletes unnecessary backup datafiles and archived redo log files both from disk and tape.
  4. Reporting of backup actions.
  5. Duplicating a database or creating a standby database.
  6. Verify available backups are useable for recovery
  7. Incremental backup
  8. I lets you perform database duplication without backups by using the network enabled database duplication feature also known as active duplication.
  9. It automatically detects corrupt data blocks during backups V$DATABASE_BLOCK_CORRUPTION view.
  10. when only a few data blocks are corrupted, you can recover at the data block level.
  11. Unused block complession feature, wherein RMAN skips unused data blocks during a backup.
  12. RMAN provides the ability to perform encrypted backups.
  13. You can use a powerful scrpting language which lets you write custom backup and recovery scripts quickly.

Text description of rmang001.gif follows
 http://download.oracle.com/docs/cd/B10500_01/server.920/a96566/rcmarchi.htm

RMAN 1.3 Recovery Types

Database Recovery and Consistent VS Inconsistent Backups

Consistent Backups

Inconsistent Backups

If you shutdown your database using shutdown norml, shutdown immediate and shutdown transactional, you’ll have a consistent backup. Shutdown abort or shutdown force or if there is an instance failure , you’ll end up with an inconsistent database.
All uncommitted changes are rolled back Any committed changes are not rolled back automatticaly
The contents of the database buffer cache written to the datafiles on disk. Changes made to the database buffer cache aren’t written to the datafiles on disk.
All resources such as lock and latches are released. No need for instance recovery. All resources such as locks and latches are still held and aren’t released

Crash Recovery :

  1. The Oracle server will perform an automatic crash recovery when you restart the instance.
  2. Don’t need to restore or recovery tasks.
  3. The server will use the information in the undo tablespace to perform automatic instance recovery by rolling back uncommitted transactions  in  the database.

Rolling Forward

Rolling Back

 

The Oracle server will update all data files with the information from the redo log file. The log files are always written to before the data is recorded in the data file. thus ,an instance recovery may usually leave the online log files “ahead” of the data files.

 

Uncommitted changes that were added to the data files during the roll forward operation are rolled  back. Undo tablespace contents uncommitted changes to their Original states. At the end of rollback stage, only committed data at the time of the instance failure is retained in the data files.

FAST_START_MTTR_TARGET

  1. The database server must apply all transactions b/w the last checkpoint and end of the redo log to the data files.
  2.   Number of seconds you want the crash recovery to take.
  3.   Oracle will try to recover the instance as close as possible to the time that you specify for the FAST_START_MTTR_TARGET
  4.   MAX value is 3,600 seconds (1 hour).

Media Recovery

  1.   The server won’t be able to automatically recover from such  a catastrophe
  2.   Must provide the lost datafiles from backup.
  3.   If error occured, Find V$RECOVER_FILE view, which lists all files that need media recovery
  4.  You use two basic commands RERTORE OR RECOVER

You must do the following as part of  a Media Recovery operation

  1.   Restore the necessary data files from backup ,either to the old or to an alternative location
  2.   Rename the data files , if necessary, so the database will know about their new location
  3.   Recover the data files (bring them up to date), if necessary, by applying redo information to them

To open the database after a Successful Restore and Recovery

  1.   You must have synchronized copies of all the control files
  2.   you must have synchronized online data files.
  3.   you must have at least one member of each redo log group

Deciding on the Appropriate Recovery Technique

  1.   If you run into logical errors, perform a TSPITR or consider using an appropriate flashback technique to make a point in time recovery.
  2.   If you have data corruption in a few blocks in a data files or a set of data files, use block media recovery.
  3. If a user error affects a large set of tables or the entire database ,use the flashback feature to revert the database to a previous “good” time by undoing all the changes since that point in time.

RMAN 1.2 Backup Types

Physical and Logical Backups

  1. Copy of Datafile using an OS utility such as cp command.
  2. You can use this file to restore the database contents if you lose the disk file.
  3. Copy of the files like Datafiles, control files and redo log files.
  4. logical backups by using Oracle Data pump Export tool wherein you copy the definitions and contents all of the database’s logical componets such as table and so on.
  5. Its not complete backup and recovery solution.

Whole and Partial backups

  1. Backup of the entire database.
  2. Partial backup –> backup of a tablespace or datafile in a database.
  3. Datafile backup —> only a single OS file.
  4. Tablespace backup –> all the datafiles that are part of the tablespace.

Online and Offline Backups

  1. RMAN support both online ( HOT ) and offline ( COLD ) backups.
  2. An online backup is always inconsistent during a recovery , the application of the necessary archived log file will make the backup consistent.

Full and Incremental Backups

  1. It will contain complete backups of all the datafiles.
  2. It contain only the changed data blocks in the datafiles.
  3. You can make incremental backups only with the help of RMAN.

Consistent and Inconsistent Backups

What is SCN?

  1. SCN is an Oracle assigned number that indicates a committed version of a database.
  2. Its quite possible that different datafiles in the database might have a different SCN at any given point in time.
  3. If the SCN across all the datafiles are synchronized, it means that the data across the datafiles comes from a single point of time and thus, is consistent.
  4. During each checkpoint, the server makes all the datafiles SCN consistent w.r.t an identical SCN.
  5. It updates control file  with that SCN information.
  6. This synchronization of the SCN gives you a consistent backup of your database.

Inconsistent Backup

  1. If you backup your database while it’s running, you may end up with backups of the various data files at various time points and different SCN.
  2. This means your database are inconsistent, since the SCN aren’t identical across all the datafiles.
  3. If you’re using inconsistent backups, you must use the archive redo log files to make the data current and synchronize the SCN across the datafiles.
  4. If you’re using the RMAN offline backup, the database must be mounted before you can actually perform the RMAN backup. RMAN needs to update the target database control file.

RMAN 1.1 Types of Failure

Statement Failures

  1. When a program attempts to enter invalid data into an Oracle Table.
  2. Long data insertion job or data import job to fail midway between there is no more room to put the data in.
  3. Proper privileges to perform a task.

User process Failure

  1. abnormal disconnect or performing a terminal program error and losing the session connection.
  2. DBA not much work to do here.
  3. BG process rollback the uncommitted transaction  changes to the data and releases the locks.

Instance Failure

  1. Your database comes down such as Hardware , a power failure and an emergency shutdown procedure.
  2. An instance shutdown when the key Oracle bg process such as PMON shutdown because of an error condition.
  3. Check Alert log and trace files.
  4. Just restarting the Database instance using by STARTUP Command.
  5. The database was clearly shutdown and the database files aren’t synchronized.
  6. Oracle will perform an automatic instance or crash recovery at this point.
  7. Automatically perform a rollback uncommitted transactions by using the data from undo segments and roll forward committed changes it in the online redo logs.
  8. Don’t need to any sort of backup when restarting the database.

Network Failure

  1. Net listener, NIC and network connection has failed.
  2. DBA must configure the multiple network cards.

User Error

  1. Wrongly deleting  data from table and dropping a table you can use FLASHBACK feature.
  2. If the transactions not completed yet, rollback statement.
  3. Oracle LOGMINER also comes on handy situation like this.

Media Failure

  1. It occur when you lose a disk or a disk  controller fails.
  2. Examples of media failure  i) Head crash II) File corruption III)Overwriting or deleting of a datafile.
  3. Any one of the multiplexed control files are deleted or lost because of disk failure you must restore the missing control file from an existing control file.
  4. Datafiles, undo table space is deleted or lost because of a disk failure.If you lose one of these files, the instance may shutdown or may not sutdown in such case

         sql> shutdown abort;           Then

         sql>startup mount

          Restore the datafiles and recover it.

  1.         An entire redo log group lost. if you have atleast one member of the redo log group , your database instance can continue to operating normally.
  2. Restore the log file by copying one of  the other members of the same group.