Showing posts with label RMAN. Show all posts
Showing posts with label RMAN. Show all posts

Thursday 23 November 2017

Time Based Archivelog Backup in Oracle 11gR2 RMAN

Scenario:

Sometimes we need to take archive log backup for specific time, so we can use the following steps for this purpose

Solution:

bash-4.2$ rman target sys/sys123

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Nov 23 16:22:49 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

connected to target database: ORCL (DBID=214666078)

RMAN> run {
2>      allocate channel ch1 type disk;
3>       backup archivelog from time "TO_DATE('11/20/2017 10:00:00', 'MM/DD/YYYY hh24:mi:ss')"
4>       until time "TO_DATE('11/23/2017 12:00:00', 'MM/DD/YYYY hh24:mi:ss')" format '/bak_archive/ARC0_ORCL_%U_%T';
5>       BACKUP AS COMPRESSED BACKUPSET CURRENT CONTROLFILE format '/bak_archive/CONTROL0_ORCL_%U_%T';
6> }

using target database control file instead of recovery catalog
allocated channel: ch1
channel ch1: SID=5673 instance=ORCL device type=DISK

Starting backup at 23-NOV-17
channel ch1: starting archived log backup set
channel ch1: specifying archived log(s) in backup set
input archived log thread=1 sequence=56 RECID=54439 STAMP=960793631
input archived log thread=2 sequence=57 RECID=54438 STAMP=960793630
channel ch1: starting piece 1 at 23-NOV-17
channel ch1: finished piece 1 at 23-NOV-17
piece handle=/bak_archive/ARC0_ORCL_crska3j7_1_1_20171123 tag=TAG20171123T162303 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 23-NOV-17

Starting backup at 23-NOV-17
channel ch1: starting compressed full datafile backup set
channel ch1: specifying datafile(s) in backup set
including current control file in backup set
channel ch1: starting piece 1 at 23-NOV-17
channel ch1: finished piece 1 at 23-NOV-17
piece handle=/bak_archive/CONTROL0_ORCL_csska3j8_1_1_20171123 tag=TAG20171123T162304 comment=NONE
channel ch1: backup set complete, elapsed time: 00:00:01
Finished backup at 23-NOV-17
released channel: ch1

RMAN> exit


Recovery Manager complete.
bash-4.2$

If we want to take archive log backup with sequence and kept in tape then use the following script

RUN
{
  ALLOCATE CHANNEL T1 TYPE 'sbt_tape' PARMS
    'ENV=(TDPO_OPTFILE=)' ;

  SET ARCHIVELOG DESTINATION TO '/bak_archive/archivelog';
  RESTORE ARCHIVELOG FROM SEQUENCE 3389 ;

  RELEASE CHANNEL T1;
}

If we want to report RMAN backup information for specific time the use the following script

LIST BACKUP OF ARCHIVELOG
  FROM TIME "TO_DATE('11/20/2017 10:00:00', 'MM/DD/YYYY hh24:mi:ss')"
  UNTIL TIME "TO_DATE('11/23/2017 12:00:00', 'MM/DD/YYYY hh24:mi:ss')";
 

Sunday 2 April 2017

RMAN Active Duplicate on RAC fails with ORA-17629 and ORA-17627: ORA-12154

RMAN active duplication of RAC database fails on restart operation with the following error messages:

oracle@said$ rman target sys@orcl

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 2 14:19:40 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

target database Password:
connected to target database: ORCL (DBID=209740460)

RMAN> connect auxiliary sys@stdby

auxiliary database Password:
connected to auxiliary database: ORCL (not mounted)

RMAN> duplicate target database for standby from active database;

Starting Duplicate Db at 02-APR-17
using target database control file instead of recovery catalog
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1921 instance=ORCL1 device type=DISK

contents of Memory Script:
{
   backup as copy reuse
   targetfile  '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwORCL2' auxiliary format
 '/u01/app/oracle/product/11.2.0/db_1/dbs/orapwORCL1'   ;
}
executing Memory Script

Starting backup at 02-APR-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=2689 instance=ULTIMUS1 device type=DISK
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 04/02/2017 14:20:46
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
RMAN-03009: failure of backup command on ORA_DISK_1 channel at 04/02/2017 14:20:45
ORA-17629: Cannot connect to the remote database server
ORA-17627: ORA-12154: TNS:could not resolve the connect identifier specified
ORA-17629: Cannot connect to the remote database server

RMAN> exit

Reason:


ORA-12154 is raised whenever the TNS alias is not found on tnsnames.ora

After verification of tnsanames.ora files from both installations on Target and Auxiliary we see all the proper entries are there Still the RMAN duplicate command fails on ORA-12154

The reason for ORA-12154 being raised is because the process is looking for tnsnames.ora in a different ORACLE_HOME on the Auxiliary side.   This different ORACLE_HOME on Auxiliary side is usually the GRID HOME.

On 11G RAC Customers can configure SCAN Listener to handle failover connections on DB and ASM instances.

When RMAN duplicate is executed it needs to shutdown/startup the database several times.  Once the DB is down, a TNS connection can get lost on next startup since the corresponding service associated with the instance is no longer available.  The connection from RMAN thus fails when looking for the tnsnames.ora file under the wrong home.

Resolution:

There are two ways to workaround this problem

1) Copy the tnsnames.ora file form the RDBMS Home to the GRID Home

2) Establish a direct connection instead of using a TNS alias.  For example:

RMAN> connect auxiliary sys/pwd@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=myauxiliaryhost)(PORT=1521))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=QRM)(UR=A)))

For Example:

oracle@said$ rman target sys@orcl

Recovery Manager: Release 11.2.0.4.0 - Production on Sun Apr 2 14:21:10 2017

Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.

target database Password:
connected to target database: ORCL (DBID=209740460)

RMAN> connect auxiliary sys/sys123@(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=172.17.250.75)(PORT=1599))(CONNECT_DATA=(SERVER=DEDICATED)(SERVICE_NAME=ORCL)))

connected to auxiliary database: ORCL (not mounted)


RMAN> duplicate target database for standby from active database;


Hope this will work for you!!!!!!!


Monday 2 February 2015

ora-01547 ora-01152 ora-01110 ---ORA-01152: file 1 was not restored from a sufficiently old backup

ORA-01152: file 1 was not restored from a sufficiently old backup


RMAN> recover database;

starting media recovery

Oracle Error: 
ORA-01547: warning: RECOVER succeeded but OPEN RESETLOGS would get error below
ORA-01152: file 1 was not restored from a sufficiently old backup 
ORA-01110: data file 1: '/oracledb/oradata/stlbas/system01.dbf'

RMAN> list backup of archivelog all;


List of Backup Sets
===================


BS Key  Size       Device Type Elapsed Time Completion Time
------- ---------- ----------- ------------ ---------------
6867    2.88G      DISK        00:00:34     01-FEB-15
        BP Key: 6962   Status: AVAILABLE  Compressed: NO  Tag: TAG20150201T012203
        Piece Name: /back/rman/STLBAS_mmpu52v9_6870_1_20150201.arch

  List of Archived Logs in backup set 6867
  Thrd Seq     Low SCN    Low Time  Next SCN   Next Time
  ---- ------- ---------- --------- ---------- ---------
  1    36221   2600574277 31-JAN-15 2600605406 31-JAN-15
  1    36222   2600605406 31-JAN-15 2600627762 31-JAN-15
  1    36223   2600627762 31-JAN-15 2600647950 31-JAN-15
  1    36224   2600647950 31-JAN-15 2600662535 31-JAN-15
  1    36225   2600662535 31-JAN-15 2600717481 31-JAN-15
  1    36226   2600717481 31-JAN-15 2600741241 31-JAN-15
  1    36227   2600741241 31-JAN-15 2600790390 31-JAN-15
  1    36228   2600790390 31-JAN-15 2600816991 31-JAN-15
  1    36229   2600816991 31-JAN-15 2600825320 31-JAN-15
  1    36230   2600825320 31-JAN-15 2600835621 01-FEB-15
  1    36231   2600835621 01-FEB-15 2600840871 01-FEB-15
  1    36232   2600840871 01-FEB-15 2600844061 01-FEB-15
  1    36233   2600844061 01-FEB-15 2600846909 01-FEB-15
  1    36234   2600846909 01-FEB-15 2600849775 01-FEB-15
  1    36235   2600849775 01-FEB-15 2600852908 01-FEB-15
  1    36236   2600852908 01-FEB-15 2600855742 01-FEB-15
  1    36237   2600855742 01-FEB-15 2600858910 01-FEB-15
  1    36238   2600858910 01-FEB-15 2600861908 01-FEB-15
  1    36239   2600861908 01-FEB-15 2600864790 01-FEB-15
  1    36240   2600864790 01-FEB-15 2600867574 01-FEB-15
  1    36241   2600867574 01-FEB-15 2600870383 01-FEB-15
  1    36242   2600870383 01-FEB-15 2600873220 01-FEB-15
  1    36243   2600873220 01-FEB-15 2600876061 01-FEB-15
  1    36244   2600876061 01-FEB-15 2600879665 01-FEB-15
  1    36245   2600879665 01-FEB-15 2600882739 01-FEB-15
  1    36246   2600882739 01-FEB-15 2600885804 01-FEB-15
  1    36247   2600885804 01-FEB-15 2600888651 01-FEB-15
  1    36248   2600888651 01-FEB-15 2600891543 01-FEB-15
  1    36249   2600891543 01-FEB-15 2600894895 01-FEB-15
  1    36250   2600894895 01-FEB-15 2600897684 01-FEB-15
  1    36251   2600897684 01-FEB-15 2600900574 01-FEB-15
  1    36252   2600900574 01-FEB-15 2600903408 01-FEB-15
  1    36253   2600903408 01-FEB-15 2600906920 01-FEB-15
  1    36254   2600906920 01-FEB-15 2600910373 01-FEB-15
  1    36255   2600910373 01-FEB-15 2600913188 01-FEB-15
  1    36256   2600913188 01-FEB-15 2600915992 01-FEB-15
  1    36257   2600915992 01-FEB-15 2600918821 01-FEB-15
  1    36258   2600918821 01-FEB-15 2600921662 01-FEB-15
  1    36259   2600921662 01-FEB-15 2600924499 01-FEB-15
  1    36260   2600924499 01-FEB-15 2600927306 01-FEB-15
  1    36261   2600927306 01-FEB-15 2600930132 01-FEB-15
  1    36262   2600930132 01-FEB-15 2600932938 01-FEB-15
  1    36263   2600932938 01-FEB-15 2600936116 01-FEB-15
  1    36264   2600936116 01-FEB-15 2600939496 01-FEB-15
  1    36265   2600939496 01-FEB-15 2600942433 01-FEB-15
  1    36266   2600942433 01-FEB-15 2600945251 01-FEB-15
  1    36267   2600945251 01-FEB-15 2600948054 01-FEB-15
  1    36268   2600948054 01-FEB-15 2600950863 01-FEB-15
  1    36269   2600950863 01-FEB-15 2600953653 01-FEB-15
  1    36270   2600953653 01-FEB-15 2600956598 01-FEB-15
  1    36271   2600956598 01-FEB-15 2600959671 01-FEB-15
  1    36272   2600959671 01-FEB-15 2600962481 01-FEB-15
  1    36273   2600962481 01-FEB-15 2600968235 01-FEB-15
  1    36274   2600968235 01-FEB-15 2600971093 01-FEB-15

RMAN> recover database UNTIL SEQUENCE 36274;


RMAN> recover database UNTIL SEQUENCE 36274;

Starting recover at 03-FEB-15
using channel ORA_DISK_1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/03/2015 12:23:14
RMAN-06556: datafile 1 must be restored from backup older than SCN 2600968235

RMAN> recover database UNTIL SEQUENCE 36275;

Starting recover at 03-FEB-15
using channel ORA_DISK_1

starting media recovery

channel ORA_DISK_1: starting archived log restore to default destination
channel ORA_DISK_1: restoring archived log
archived log thread=1 sequence=36274
channel ORA_DISK_1: reading from backup piece /back/rman/STLBAS_mmpu52v9_6870_1_20150201.arch
channel ORA_DISK_1: piece handle=/back/rman/STLBAS_mmpu52v9_6870_1_20150201.arch tag=TAG20150201T012203
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
archived log file name=/oracledb/oracle/dbs/arch1_36274_842022897.dbf thread=1 sequence=36274
media recovery complete, elapsed time: 00:00:01
Finished recover at 03-FEB-15


RMAN> alter database open resetlogs;

Monday 29 December 2014

Step by Step Duplicate a Database Using RMAN in Oracle Database 11g Release 2

Step 1: start Database in nomount mode using parameter file

SQL>startup nomount pfile='/tmp/stldb.ora';

Step 2: Restore control file using following command

RMAN>RESTORE CONTROLFILE from  '/source/app/oracle/fast_recovery_area/DB11G/Full_control_stldb_20141221_1724_866861424_1.ctl';

Step 3: Mount Database using following command

RMAN>alter database mount;

Step 4: Catalog the backup pieces which need to restore

RMAN>CATALOG START WITH '/source/app/oracle/fast_recovery_area/DB11G/';

Step 5: We can then duplicate the database using one of the following commands.

# Backup files are in matching location to that on the source server.
# Duplicate database to TARGET's current state.
DUPLICATE TARGET DATABASE TO DB11G
  SPFILE
  NOFILENAMECHECK;

# Duplicate database to TARGET's state 4 days ago.
DUPLICATE TARGET DATABASE TO DB11G
  UNTIL TIME 'SYSDATE-4'
  SPFILE
  NOFILENAMECHECK;

# Backup files are in a different location to that on the source server.
# Duplicate database to the most recent state possible using the provided backups.
# Works with just an AUXILIARY connection only.
DUPLICATE DATABASE TO DB11G
  SPFILE
  BACKUP LOCATION '/source/app/oracle/fast_recovery_area/DB11G'
  NOFILENAMECHECK;

or

DUPLICATE DATABASE TO DB11G
UNTIL TIME "TO_DATE('08/21/2014 02:41:47','MM/DD/YYYY HH24:MI:SS')"
BACKUP LOCATION '/source/app/oracle/fast_recovery_area/DB11G' NOFILENAMECHECK NORESUME;  
  

The time it takes to complete varies depending on the size of the database and the specification of the server. Once the process is finished RMAN produces a completion message and you have your duplicate instance.  
  

Ref: http://oracle-base.com/articles/11g/duplicate-database-using-rman-11gr2.php

Tuesday 8 April 2014

Restore Controlfile to specific location using RMAN


Restore Controlfile to specific location using RMAN

1. Restore controlfile to a location

RMAN> restore controlfile to '/u01/app/oracle/oradata/orcl/control01.ctl' 
from '/back/rman/controlfile.bkp';

2. Connect sqlplus as sysdba and controlfile location

[oracle@localhost ~]$ sqlplus / as sysdba  
  
SQL*Plus: Release 11.2.0.2.0 Production on Fri Nov 9 07:54:50 2012  
  
Copyright (c) 1982, 2010, Oracle.  All rights reserved.  
  
Connected to:  
Oracle Database 11g Enterprise Edition Release 11.2.0.2.0 - Production  
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> show parameter control_files  
  
NAME                                 TYPE        VALUE  
------------------------------------ ----------- ------------------------------  
control_files                        string      /home/oracle/app/oracle/oradata/orcl/control01.ctl,   

3. Change controlfile location where restored using spfile and shutdown instance

SQL> alter system set control_files='/u01/app/oracle/oradata/orcl/control01.ctl' scope=spfile;  
  
System altered.   


SQL> shutdown immediate;  
ORA-01507: database not mounted  
  
  
ORACLE instance shut down.

4. start it again in MOUNT mode using RMAN. 

[oracle@localhost ~]$ rman target /  
  
Recovery Manager: Release 11.2.0.2.0 - Production on Fri Nov 9 07:56:56 2012  
  
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.  
  
connected to target database (not started)  
  
RMAN> startup mount;  
  
Oracle instance started  
database mounted  
  
Total System Global Area     456146944 bytes  
  
Fixed Size                     1344840 bytes  
Variable Size                364907192 bytes  
Database Buffers              83886080 bytes  
Redo Buffers                   6008832 bytes  

5. We have to perform a recovery of the database after the restore of the control file, 
even if any datafile was restored. 

RMAN> recover database;  

6. After the restore of the control file you have to open the database with RESETLOGS option. 

RMAN> alter database open resetlogs;  
  
database opened

SQL> show parameter control_file  
  
NAME                                 TYPE        VALUE  
------------------------------------ ----------- ------------------------------  
control_file_record_keep_time        integer     7  
control_files                        string      /u01/app/oracle/oradata/orcl/control01.ctl


Thats it.....

Wednesday 2 April 2014

ORA-00349 ORA-27041 Linux-x86_64 Error: 2: No such file or directory


Scenario: We want to restore Oracle 11g RMAN backup into different host with different mount point.We have restore database and recover archive log as well. But when we want to open the database then we are getting the following error

Solution:

RMAN> alter database open resetlogs;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 04/02/2014 19:13:54
ORA-00349: failure obtaining block size for '/u01/app/oracle/oradata/STLBAS/redo01.log'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9

RMAN>

ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/STLBAS/redo01.log' TO '/oracledb/oradata/stlbas/redo01.log';

SQL> alter database open resetlogs;


SQL>  alter database open resetlogs;
 alter database open resetlogs
*
ERROR at line 1:
ORA-00392: log 1 of thread 1 is being cleared, operation not allowed
ORA-00312: online log 1 thread 1: '/oracledb/oradata/stlbas/redo01.log'


SQL> select group#, status from v$log;

    GROUP# STATUS
---------- ----------------
         1 CLEARING_CURRENT
         3 CLEARING
         2 CLEARING

SQL>

alter database clear logfile group 1;

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00349: failure obtaining block size for
'/u01/app/oracle/oradata/STLBAS/redo02.log'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9
SQL>


SQL> ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/STLBAS/redo02.log' TO '/oracledb/oradata/stlbas/redo02.log';

Database altered.

SQL>

SQL> alter database open resetlogs;
alter database open resetlogs
*
ERROR at line 1:
ORA-00349: failure obtaining block size for
'/u01/app/oracle/oradata/STLBAS/redo03.log'
ORA-27041: unable to open file
Linux-x86_64 Error: 2: No such file or directory
Additional information: 9


SQL> ALTER DATABASE RENAME FILE '/u01/app/oracle/oradata/STLBAS/redo03.log' TO '/oracledb/oradata/stlbas/redo03.log';

Database altered.

SQL> alter database open resetlogs;

Database altered.

Tuesday 4 February 2014

Restore and Recover with latest controlfile backup but Database/Archivelog backup five days earlier

Problem: Here we have five days earlier Database/Archivelog backup without control controlfile but we have last night controlfile backup,now we need to restore and recover the Database.

Solution:

Step1: Shutdown Database.

 
Step2: connect to RMAN and startup in nomount mode.

 
RMAN>startup nomount;
Step3: Restore night controlfile backup


RMAN>restore controlfile from '/back/rman/STLBAS_3870_838523473_20140203_1.ctl';
Step4: Mount Database

 
RMAN>alter database mount;
Step5 : connect to sqlplus

 
Step6 :Recover Database with existing archivelog backup sequence number

 
RMAN>recover database until sequence 13099;

Note: If sequence 13099 not found then above command will ask for lower sequence number then
execute the following command

RMAN>recover database until sequence 13000;

Note: If sequence 13000 not found then above command will ask for lower sequence number then
execute the following command

RMAN>recover database until sequence 12000;

Step7 :If recover successfully then open database with resetlogs

 
RMAN>alter database open resetlogs;

Note: This solution is tested in my lab but before execute in production test it into your
test lab.

Wednesday 22 January 2014

RMAN-06059: expected archived log not found, lost of archived log compromises recoverability

Error:  
RMAN-03002: failure of backup command at 01/13/2014 07:02:54
RMAN-06059: expected archived log not found, lost of archived log compromises recoverability
ORA-19625: error identifying file /u01/app/oracle/product/11.1.0/db_1/dbs/arch1_3978_813813738.dbf
ORA-27037: unable to obtain file status

Cause: The archived log was not found. The repository thinks it does exist. If the archived log has in fact been lost and there is no backup, then the database is no longer recoverable across the point in time covered by the archived log. This may occur because the archived log was removed by an outside utility without updating the repository.

Solution: Check that archived log has been removed with an outside utility and the archivelog has already been backed up, then you can run CROSSCHECK ARCHIVELOG ALL. and try to take the backup again. Suggested script given below


backup current controlfile format '/back/rmaback/ORCL_%u_%s_%p_%T.ctl';
sql 'alter system switch logfile';
BACKUP DATABASE FORMAT '/back/rmaback/ORCL_%u_%s_%p_%T.DBF' TAG 'DATAFILE_BACKUP';
backup archivelog all format '/back/rmaback/ORCL_%u_%s_%p_%T.arch';
backup SPFILE FORMAT '/back/rmaback/ORCL_SPFILE_%u_%s_%p_%T.ORA' TAG 'SPFILE_BACKUP' ;
CROSSCHECK BACKUPSET;
CROSSCHECK ARCHIVELOG ALL;
DELETE noprompt OBSOLETE;
delete noprompt archivelog until time 'sysdate-7';
backup format '/back/rmaback/ORCL_%s_%t_%T_%p.ctl' current controlfile;


Cheers....

Sunday 24 November 2013

Backup Archivelog to specific location using RMAN

Goal:

Following script will take archive log backup in a specific location using RMAN

run
{
allocate channel ch1 type disk format 'd:\arch\%d_%s_%p_%U_ARCH';
backup archivelog all delete input;
}

RMAN backup (Control File, Data File) to specific location

Goal:

Following script will use to take RMAN backup in a specific location

run{
backup current controlfile format 'D:\RMAN\full_%s_%t_%p.ctl';
sql 'alter system switch logfile';
backup incremental level 0 format 'D:\RMAN\full_%s_%t_%p.dbf' database;
backup format 'D:\RMAN\full_%s_%t_%p.arch'  archivelog all delete input;
}

Saturday 23 November 2013

12 steps to build report server like production using RMAN (Oracle) backup in Windows

Goal:

The following procedure will be used to build a report server as like production 
 
1. Create a service 
oradim -new -sid itbl

2. Database version should be same.
3. Database installation and location should be same
4. SPfile should be copied from Production.
5. set DB_ID in RMAN
6. Report server should be in nomount state.
7. Restore Control file
RESTORE CONTROLFILE from 'D:\RMAN\FULL_7_807217623_1.CTL';

8. alter database mount;


9. Catalog all backup pieces need to restore

CATALOG START WITH 'D:\RMAN\FULL_7_807217623_1.CTL';
CATALOG START WITH 'D:\RMAN\FULL_9_807217630_1.DBF';
CATALOG START WITH 'D:\RMAN\FULL_10_807217660_1.ARCH';
CATALOG START WITH 'D:\RMAN\FULL_11_807217670_1.ARCH';

10. Restore Database;

11. Recover Database;
12. alter database open RESETLOGS;

Recover when one or all control files deleted in Oracle

RMAN> RESTORE CONTROLFILE from 'F:\oracle\product\10.2.0\Backup\Controlfile\CF_C-1331185808-20130207-01';

Starting restore at 07-FEB-13
using channel ORA_DISK_1

channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
output filename=F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL01.CTL
output filename=F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL02.CTL
output filename=F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\CONTROL03.CTL
Finished restore at 07-FEB-13

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> alter database open;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/07/2013 20:06:46
ORA-01589: must use RESETLOGS or NORESETLOGS option for database open

RMAN> alter database open RESETLOGS;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of alter db command at 02/07/2013 20:07:00
ORA-01152: file 1 was not restored from a sufficiently old backup
ORA-01110: data file 1: 'F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\SYSTEM01.DBF'

RMAN> recover database;

Starting recover at 07-FEB-13
Starting implicit crosscheck backup at 07-FEB-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
Crosschecked 4 objects
Finished implicit crosscheck backup at 07-FEB-13

Starting implicit crosscheck copy at 07-FEB-13
using channel ORA_DISK_1
Finished implicit crosscheck copy at 07-FEB-13

searching for all files in the recovery area
cataloging files...
no files cataloged

using channel ORA_DISK_1

starting media recovery

archive log thread 1 sequence 2 is already on disk as file F:\ORACLE\PRODUCT\10.
2.0\ORADATA\ORCL\REDO02.LOG
archive log filename=F:\ORACLE\PRODUCT\10.2.0\ORADATA\ORCL\REDO02.LOG thread=1 s
equence=2
media recovery complete, elapsed time: 00:00:05
Finished recover at 07-FEB-13

RMAN> alter database open RESETLOGS;

database opened

RMAN>

Cataloging backup piece in RMAN

Applies to:
 
Oracle Server – Enterprise Edition any Version  9 to 12 Information in this document applies to any platform.

Goal:

The following command will cataloged backup pieces in RMAN
 
# Catalog specific backup piece.
CATALOG BACKUPPIECE '/backup/MYSID/01dmsbj4_1_1.bcp';

# Catalog all files and the contents of directories which
# begin with the pattern "/backup/MYSID/arch".
CATALOG START WITH '/backup/MYSID/arch';

# Catalog all files in the current recovery area.
CATALOG RECOVERY AREA NOPROMPT;

# Catalog all files in the current recovery area.
# This is an exact synonym of the previous command.
CATALOG DB_RECOVERY_FILE_DEST NOPROMPT;

Configure RMAN to purge archivelogs after applied on standby

Applicable:

Oracle Database - Enterprise Edition - Version 10.2.0.1 to 10.2.0.5

GOAL:

We need RMAN to automatically purge archivelogs from the FRA once they are applied to the standby database.


SOLUTION

In a dataguard configuration, the archivelogs from the FRA will be automatically purged when the following conditions
are met by the database. If you need it purged in at the Primary site, set it on Primary database.

1) prior to 11g, if not using mandatory archivelog destinations, the database (primary and standby) must be restarted
with the following parameter:

SQL > alter  system  set "_ log_deletion_policy"='ALL' scope=spfile;

2) configure the following parameter in RMAN (primary and standby):
        RMAN> CONFIGURE   ARCHIVELOG  DELETION  POLICY  TO  APPLIED ON STANDBY;
       
3) the archivelog must have been applied to the standby. Run the following query to list all archivelogs applied to the
standby:

select   a.thread#, a.sequence#,a.applied
from   v$archived_log a, v$database d
where  a.activation# =d.activation#
and a.applied='YES'
/

4) If on the primary site, the archivelog must be obsolete per RMAN retention policy
To list the obsolete objects, run the following query:

RMAN> SHOW RETENTION POLICY;
RMAN>REPORT OBSELETE;

5) there is space pressure in the FRA
When an archivelog is automatically deleted from the FRA, you will see this in the database's alert.log:

REFERENCES

 
Oracle Metalink Doc ID  728053.1
NOTE:331924.1 - RMAN backups in Max Performance/Max Availability Data Guard Environment
NOTE:740322.1 - RMAN Archived Redo Logs Are Deleted Before Being Applied at Standby Database
BUG:6216036 - RMAN+DG ARCHIVELOG DELETION POLICY APPLIED ON STANDBY NOT RESPECTED



Saturday 21 September 2013

Maintenance of archivelogs which are already applied on standby database in Oracle 10g

Maintenance Of Archivelogs On Standby Databases

Applies to:
Oracle Server – Enterprise Edition – Version: 10.1.0.0 to 11.1
Information in this document applies to any platform.

Goal
Maintenance of archivelogs which are already applied on standby database in Oracle 10g

Solution
In Oracle 10g, RMAN has a specific configuration for archivelog deletion policy i.e.
ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY
This parameter can be set on primary and standby databases.
To enable automatic maintenance of the archivelogs on standby perform the below steps on standby database :

Step 1 :  Enable the flash recovery area on the standby database so that all the archivelogs are shipped in the flash recovery area.
Example :
To enable Flash Recovery Area and to allow the archivelogs to be shipped to Flash Recovery Area set the below parameters
SQL> alter system set DB_RECOVERY_FILE_DEST=’/disk1/FRA’;
SQL> alter system set DB_RECOVERY_FILE_DEST_SIZE=80G;
SQL> alter system set  LOG_ARCHIVE_DEST_1=’LOCATION=USE_DB_RECOVERY_FILE_DEST’;

Step 2 : Set the parameter Archive log deletion policy to applied on standby
Example :
RMAN> CONFIGURE ARCHIVELOG DELETION POLICY TO APPLIED ON STANDBY;
Note : With the above settings whenever there is a space pressure in Flash Recovery Area all the archivelogs that are applied on standby database will be automatically deleted.

References
Oracle Metalink Doc ID 464668.1

Error RMAN-06023 but there are backups available

Error RMAN-06023 but there are backups available


Demo case:
Environment : Oracle 10.2.0.1 on Linux 64bit


I have backup files of the database:

$ ls -l /oracle/backup/*
ARCH_OTP_20101117_0tlt6lum_s8221_p1
controlf_OTP_0ult6mop_8222_20101117
FULL_OTP_0rlt6ip4
spfile_OTP_0vlt6mos_8223_20101117

Restore controlfile from backup and mount database:

$ rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Thu Nov 18 08:32:09 2010
Copyright (c) 1982, 2007, Oracle.  All rights reserved.
connected to target database (not started)

RMAN> startup nomount;
Oracle instance started
Total System Global Area     838860800 bytes
Fixed Size                     2087672 bytes
Variable Size                750781704 bytes
Database Buffers              67108864 bytes
Redo Buffers                  18882560 bytes

RMAN> restore controlfile from '/back/rmaback/o1_mf_s_826770604_93vwxw3j_.bkp';

Starting restore at 18.11.2010 08:40:51

channel c1: restoring control file
channel c1: restore complete, elapsed time: 00:00:01
output filename=/oracledb/oradata/stlbas/control01.ctl
output filename=/oracledb/oradata/stlbas/control02.ctl
Finished restore at 18.11.2010 08:40:52
released channel: c1

RMAN> alter database mount;
database mounted

I will delete all EXPIRED backups from RMAN repository:


RMAN> crosscheck backup;
RMAN> delete noprompt expired backup;

RMAN> crosscheck archivelog all;
RMAN> delete noprompt expired archivelog all;

For this case it is very important to mention that I’ve had enabled controlfile autobackup (CONFIGURE CONTROLFILE AUTOBACKUP ON) in older incarnations. With this parameter enabled RMAN automatically takes backup of controlfile and server parameter file whenever the database structure metadata in the control file changes or whenever a backup or copy operation is performed using RMAN.

List backup command shows that there are two old autobackup files in flash recovery area.


RMAN> list backup;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
8199    Full    7.89M      DISK        00:00:00     16.06.2010 14:50:28
        BP Key: 8199   Status: AVAILABLE  Compressed: NO  Tag: TAG20100616T145028
        Piece Name: /oracle/oradata/archive/flash_recovery_area/OTP/autobackup/2010_06_16/o1_mf_s_721839028_61kl4o2y_.bkp
  Control File Included: Ckp SCN: 43471045788   Ckp time: 16.06.2010 14:50:28
  SPFILE Included: Modification time: 16.06.2010 13:15:03

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
8200    Full    7.89M      DISK        00:00:00     16.06.2010 14:49:49
        BP Key: 8200   Status: AVAILABLE  Compressed: NO  Tag: TAG20100616T144949
        Piece Name: /oracle/oradata/archive/flash_recovery_area/OTP/autobackup/2010_06_16/o1_mf_s_721838989_61kl3hhq_.bkp
  Control File Included: Ckp SCN: 43471045571   Ckp time: 16.06.2010 14:49:49
  SPFILE Included: Modification time: 16.06.2010 13:15:03


To continue with my restore process I will catalog my backup files noted before.

RMAN> catalog start with '/oracle/backup/';

searching for all files that match the pattern /oracle/backup/

List of Files Unknown to the Database
=====================================
File Name: /oracle/backup/FULL_OTP_0rlt6ip4
File Name: /oracle/backup/ARCH_OTP_20101117_0tlt6lum_s8221_p1
File Name: /oracle/backup/controlf_OTP_0ult6mop_8222_20101117

Do you really want to catalog the above files (enter YES or NO)? YES
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: /oracle/backup/FULL_OTP_0rlt6ip4
File Name: /oracle/backup/ARCH_OTP_20101117_0tlt6lum_s8221_p1
File Name: /oracle/backup/controlf_OTP_0ult6mop_8222_20101117

Check backup of database.

RMAN> list backup of database;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
8196    Incr 0  11.18G     DISK        00:53:38     17.11.2010 01:53:58
        BP Key: 8201   Status: AVAILABLE  Compressed: YES  Tag: WEEKLY_FULL
        Piece Name: /oracle/backup/FULL_OTP_0rlt6ip4
  List of Datafiles in backup set 8196
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  1    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/system01.dbf
  2    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/users02.dbf
  3    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/sysaux01.dbf
  4    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/users01.dbf
  5    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/tools01.dbf
  6    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/users03.dbf
  7    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/undotbs01.dbf
  8    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/cluser_tbs01.dbf

Restore database files from backup to another location.

RMAN> run
2> {
3> allocate channel c1 device type disk;
4> SET NEWNAME FOR DATAFILE 1 TO '/oracledb/oradata/stlbas/system01.dbf';
5> SET NEWNAME FOR DATAFILE 2 TO '/oracledb/oradata/stlbas/users02.dbf';
6> SET NEWNAME FOR DATAFILE 3 TO '/oracledb/oradata/stlbas/sysaux01.dbf';
7> SET NEWNAME FOR DATAFILE 4 TO '/oracledb/oradata/stlbas/users01.dbf';
8> SET NEWNAME FOR DATAFILE 5 TO '/oracledb/oradata/stlbas/tools01.dbf';
9> SET NEWNAME FOR DATAFILE 6 TO '/oracledb/oradata/stlbas/users03.dbf';
10> SET NEWNAME FOR DATAFILE 7 TO '/oracledb/oradata/stlbas/undotbs01.dbf';
11> SET NEWNAME FOR DATAFILE 8 TO '/oracledb/oradata/stlbas/cluser_tbs01.dbf';
12>
13> RESTORE DATABASE;
14> SWITCH DATAFILE ALL;
15> RECOVER DATABASE;
16> }

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

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 18.11.2010 08:46:21

released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 11/18/2010 08:46:22
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore

Hm...
For me this was unexpected error because I had database backup available.


RMAN> list backup of datafile 4;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
8196    Incr 0  11.18G     DISK        00:53:38     17.11.2010 01:53:58
        BP Key: 8201   Status: AVAILABLE  Compressed: YES  Tag: WEEKLY_FULL
        Piece Name: /oracle/backup/FULL_OTP_0rlt6ip4
  List of Datafiles in backup set 8196
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  4    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/users01.dbf

RMAN> list backup of datafile 3;


List of Backup Sets
===================

BS Key  Type LV Size       Device Type Elapsed Time Completion Time
------- ---- -- ---------- ----------- ------------ -------------------
8196    Incr 0  11.18G     DISK        00:53:38     17.11.2010 01:53:58
        BP Key: 8201   Status: AVAILABLE  Compressed: YES  Tag: WEEKLY_FULL
        Piece Name: /oracle/backup/FULL_OTP_0rlt6ip4
  List of Datafiles in backup set 8196
  File LV Type Ckp SCN    Ckp Time            Name
  ---- -- ---- ---------- ------------------- ----
  3    0  Incr 48852276752 17.11.2010 01:00:20 /oracledb/oradata/stlbas/sysaux01.dbf





After two hours of searching for answers and performing more tests I ran to the Metalink document 965122.1.

The problem were those autobackups in FRA that I showed before. That files belonged to different incarnation than the available backups current incarnation.

[From Metalink document]
If we start a RESTORE database with a BACKUP controlfile and Flash Recovery Area is defined, RMAN execute and implicit crosscheck and catalog of all the objects in the Flash Recovery Area.

RMAN will catalog any objects in the Flash Recovery Area that will not be registered in the controlfile and if any of this files belongs to an incarnation different from CURRENT incarnation in the controlfile then changes controlfile CURRENT incarnation to the one found in the file that is being cataloged.

This prevents database from restoring backups that belong to old CURRENT incarnation.
RMAN considers backup availble for being restored if the backup incarnation and CURRENT incarnation in controlfile are the same.



So I’ve decided to temporary disable FRA during recovery process commenting db_recovery_file_dest and db_recovery_file_dest_size parameters in parameter file.


RMAN> shutdown abort;

Oracle instance shut down

$ vi $ORACLE_HOME/dbs/initotp.ora
...
#*.db_recovery_file_dest='/oracle/oradata/archive/flash_recovery_area'
#*.db_recovery_file_dest_size=2147483648

...

$ sqlplus "/as sysdba"

SQL> startup nomount pfile='$ORACLE_HOME/dbs/initotp.ora';
ORACLE instance started.

Total System Global Area  838860800 bytes
Fixed Size                  2087672 bytes
Variable Size             750781704 bytes
Database Buffers           67108864 bytes
Redo Buffers               18882560 bytes

Restore and recover database.

RMAN> run
2> {
3> allocate channel c1 device type disk;
4> restore controlfile from '/oracle/backup/controlf_OTP_0ult6mop_8222_20101117';
5> }



RMAN> alter database mount;
database mounted

RMAN> catalog start with '/oracle/backup';



RMAN> run
2> {
3> allocate channel c1 device type disk;
4> SET NEWNAME FOR DATAFILE 1 TO '/oracledb/oradata/stlbas/system01.dbf';
5> SET NEWNAME FOR DATAFILE 2 TO '/oracledb/oradata/stlbas/users02.dbf';
6> SET NEWNAME FOR DATAFILE 3 TO '/oracledb/oradata/stlbas/sysaux01.dbf';
7> SET NEWNAME FOR DATAFILE 4 TO '/oracledb/oradata/stlbas/users01.dbf';
8> SET NEWNAME FOR DATAFILE 5 TO '/oracledb/oradata/stlbas/tools01.dbf';
9> SET NEWNAME FOR DATAFILE 6 TO '/oracledb/oradata/stlbas/users03.dbf';
10> SET NEWNAME FOR DATAFILE 7 TO '/oracledb/oradata/stlbas/undotbs01.dbf';
11> SET NEWNAME FOR DATAFILE 8 TO '/oracledb/oradata/stlbas/cluser_tbs01.dbf';
12>
13> RESTORE DATABASE;
14> SWITCH DATAFILE ALL;
15> RECOVER DATABASE;
16> }

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

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 18.11.2010 09:01:48

channel c1: starting datafile backupset restore
channel c1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /oracledb/oradata/stlbas/system01.dbf
restoring datafile 00002 to /oracledb/oradata/stlbas/users02.dbf
restoring datafile 00003 to /oracledb/oradata/stlbas/sysaux01.dbf
restoring datafile 00004 to /oracledb/oradata/stlbas/users01.dbf
restoring datafile 00005 to /oracledb/oradata/stlbas/tools01.dbf
restoring datafile 00006 to /oracledb/oradata/stlbas/users03.dbf
restoring datafile 00007 to /oracledb/oradata/stlbas/undotbs01.dbf
restoring datafile 00008 to /oracledb/oradata/stlbas/cluser_tbs01.dbf
channel c1: reading from backup piece /var/umoracle/otp/fullbkp_dir/FULL_OTP_0rlt6ip4
channel c1: restored backup piece 1
failover to piece handle=/mnt/l01dbdev-s01storage1/oracle/backup/FULL_OTP_0rlt6ip4 tag=WEEKLY_FULL
channel c1: restore complete, elapsed time: 01:28:51
Finished restore at 18.11.2010 10:30:40

datafile 1 switched to datafile copy
input datafile copy recid=9 stamp=735388241 filename=/oracledb/oradata/stlbas/system01.dbf
datafile 2 switched to datafile copy
input datafile copy recid=10 stamp=735388241 filename=/oracledb/oradata/stlbas/users02.dbf
datafile 3 switched to datafile copy
input datafile copy recid=11 stamp=735388241 filename=/oracledb/oradata/stlbas/sysaux01.dbf
datafile 4 switched to datafile copy
input datafile copy recid=12 stamp=735388241 filename=/oracledb/oradata/stlbas/users01.dbf
datafile 5 switched to datafile copy
input datafile copy recid=13 stamp=735388241 filename=/oracledb/oradata/stlbas/tools01.dbf
datafile 6 switched to datafile copy
input datafile copy recid=14 stamp=735388242 filename=/oracledb/oradata/stlbas/users03.dbf
datafile 7 switched to datafile copy
input datafile copy recid=15 stamp=735388242 filename=/oracledb/oradata/stlbas/undotbs01.dbf
datafile 8 switched to datafile copy
input datafile copy recid=16 stamp=735388242 filename=/oracledb/oradata/stlbas/cluser_tbs01.dbf

Starting recover at 18.11.2010 10:30:43

starting media recovery

channel c1: starting archive log restore to default destination
channel c1: restoring archive log
archive log thread=1 sequence=33610
channel c1: reading from backup piece /var/otp/fullbkp_dir/ARCH_OTP_20101117_0tlt6lum_s8221_p1
channel c1: restored backup piece 1
failover to piece handle=/oracle/backup/ARCH_OTP_20101117_0tlt6lum_s8221_p1 tag=ARCHIVELOGS
channel c1: restore complete, elapsed time: 00:11:44
archive log filename=/oracle/oradata/archive/arch_1_33610_586538926.arc thread=1 sequence=33610
unable to find archive log
archive log thread=1 sequence=33611
released channel: c1
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 11/18/2010 10:50:16
RMAN-06054: media recovery requesting unknown log: thread 1 seq 33611 lowscn 48852472202
RMAN> exit


$ sqlplus "/as sysdba"

SQL> recover database using backup controlfile until cancel;
ORA-00279: change 48852472202 generated at 11/17/2010 01:54:16 needed for
thread 1
ORA-00289: suggestion :
/oracle/oradata/archive/arch_1_33611_586538926.arc
ORA-00280: change 48852472202 for thread 1 is in sequence #33611

Specify log: {=suggested | filename | AUTO | CANCEL}
CANCEL
Media recovery cancelled.

SQL> alter database open resetlogs;
Database altered.

I'm glad that this problem occurred now in test environment because those two hours spent on searching for answers could be critical in recovery of a production database.

You never know :)


REFERENCES
Metalink - [ID 965122.1]