Skip to content
Advertisements

Posts from the ‘Backup & Recovery’ Category

catalog start with rman hangs

When I am trying to restore the full database to target new host,  I have used to catalog the backup piece but It took more time but not complete

RMAN> catalog start with ‘/u02/backup/backup/’;

Starting implicit crosscheck backup at 26-FEB-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=6 device type=DISK
Crosschecked 27 objects
Finished implicit crosscheck backup at 26-FEB-16

Starting implicit crosscheck copy at 26-FEB-16
using channel ORA_DISK_1

 

Solution :

Disable the recovery file destination, and then tried to catalog the backuppiece, Its okay now.

SQL> alter system set db_recovery_file_dest=” scope=both;

 

Advertisements

ORA-00600 kcratr_nab_less_than_odr when alter database open fails

This is the issues may occur  after power failures

SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00600: internal error code, arguments: [kcratr_nab_less_than_odr], [1],
[23], [81], [189], [], [], [], [], [], [], []

Solution :

 
Alter database open fails with ORA-00600 kcratr_nab_less_than_odr (Doc ID 1296264.1)


ORA-27206: requested file not found in media management catalog

During take backup through Veritas netbackup, it shows below errors

channel ch00: starting piece 1 at 2011-10-31:10:13:48
RMAN-03009: failure of backup command on ch01 channel at 10/31/2011 10:14:23
ORA-19513: failed to identify sequential file
ORA-27206: requested file not found in media management catalog

The problem has occurred If you are added your client ip address in master netbackup server while configure backup policy.
So change client hostname with domain name instead of ip address of client.

RMAN-03009 ORA-19506 ORA-27028 ORA-19511 error while configure oracle backup in veritas netbackup

When i’m trying configure oracle backup on veritas netbackup, it showing the below errors

RMAN> 2> 3> 4> 5> 6> 7> 8> 9> 10> 11> 12> 13> 14> 15> 16> 17> 18>
allocated channel: ch00
channel ch00: sid=125 devtype=SBT_TAPE
channel ch00: Symantec/BackupExec/1.1.0

allocated channel: ch01
channel ch01: sid=90 devtype=SBT_TAPE
channel ch01: Symantec/BackupExec/1.1.0

Starting backup at 2011-10-30:14:34:49
channel ch00: starting incremental level 0 datafile backupset
channel ch00: specifying datafile(s) in backupset
input datafile fno=00005 name=H:\BROKER\PACE01.DBF
input datafile fno=00002 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\BROKER\UNDOTBS01.DBF
input datafile fno=00003 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\BROKER\SYSAUX01.DBF
input datafile fno=00014 name=H:\BROKER\PACE04.DBF
input datafile fno=00012 name=D:\CIGNATBS\CCIDATA01.DBF
input datafile fno=00004 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\BROKER\USERS01.DBF
input datafile fno=00007 name=D:\ORACLE\CATALOG\BROKER\RMAN01.DBF
channel ch00: starting piece 1 at 2011-10-30:14:34:50
channel ch01: starting incremental level 0 datafile backupset
channel ch01: specifying datafile(s) in backupset
input datafile fno=00006 name=H:\BROKER\FACE01.DBF
input datafile fno=00001 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\BROKER\SYSTEM01.DBF

channel ch01: starting piece 1 at 2011-10-30:14:34:51
RMAN-03009: failure of backup command on ch00 channel at 10/30/2011 14:34:52
ORA-19506: failed to create sequential file, name="bk_uhsmqdf8a_s1596_p1_t765902090", parms=""
ORA-27028: skgfqcre: sbtbackup returned error
ORA-19511: Error received from media manager layer, error text:
   BEError(0x80004005) Unspecified error 
 

Cause :

The problem has occured because I have already configured symantec backup exec agent software on particular database server, So it has created own orasbt.dll file in c:\windows\system32 directory and that particular database sbt device is configured with symantec backup exec . While the existing system running,  I installed veritas netbackup client  agent also on the same server without removing symantec backup exec and removed orasbt.dll file.

If symantec backup exec is already install on the same server, and if we are trying to install netbackup then it does not overwrite on orasbt.dll file.

This is the reason when i take backup, the allocated channel showing symantec backup exec not veritas oracle netbackup.

Solution :

Uninstall Both client software (Symantec Backup exec and Vertias ntbackup)

delete orasbt.dll file from  “C:\windows\system32\”

Install again Veritas Oracle netbackup.  Now Its works fine.

RMAN> run {
2> ALLOCATE CHANNEL ch00 TYPE 'SBT_TAPE';
3> SEND 'NB_ORA_SERV=xxxxxx.ace-ins.com,NB_ORA_CLIENT=yyyyyy.ace-ins.com,N
B_ORA_POLICY=dbtest';
4> BACKUP INCREMENTAL LEVEL=0 FORMAT 'bk_u%u_s%s_p%p_t%t' DATABASE;
5> }

allocated channel: ch00
channel ch00: sid=147 devtype=SBT_TAPE
channel ch00: Veritas NetBackup for Oracle - Release 7.0 (20100104)

sent command to channel: ch00

Starting backup at 31-OCT-11
channel ch00: starting incremental level 0 datafile backupset
channel ch00: specifying datafile(s) in backupset
input datafile fno=00001 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSTEM01.D
BF
input datafile fno=00003 name=D:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSAUX01.D
BF

Transport an entire database to a Different platform

Here I’m go to demonstrate How do we transport entire database to a different platform.

We can use “convert database” command to move an entire database to different operating system But we need to check out both Operating system having same endian format.

Here I’m go to Transport Database From Linux 32 bit machine to Windows 7 64 bit machine.

Source Database :

Database Name –> dbasm

OS –>Linux 32 Bit,

Endian Format :

SQL> col platform_name for a40
SQL> set linesize 100
SQL> select a.platform_id,a.platform_name,b.endian_format
  2  from v$database a,v$transportable_platform b where b.platform_id(+) = a.platform_id;

PLATFORM_ID PLATFORM_NAME                            ENDIAN_FORMAT
----------- ---------------------------------------- --------------
         10 Linux IA (32-bit)                        Little

Target Database :

OS --> Windows 7 64 Bit

Endian Format (I checked currently running on another database of this OS).
SQL> set linesize 100
SQL> col platform_name for a40
SQL> select a.platform_id,a.platform_name,b.endian_format
2 from v$database a,v$transportable_platform b where b.platform_id(+) = a.platform_id;

PLATFORM_ID PLATFORM_NAME ENDIAN_FORMAT
----------- ---------------------------------------- --------------
12 Microsoft Windows x86 64-bit Little

Step 1 : Create One Tablespace and add a table and some data

SQL> select name from v$database;

NAME---------DBASM

SQL> create tablespace testtbs datafile '+DATA' size 50m;

Tablespace created.

SQL> create user testme identified by testme default tablespace testtbs;

User created.

SQL> grant connect,resource to testme;

Grant succeeded.

SQL> conn testme/testmeConnected.SQL> create table employee(name varchar2(20));

Table created.

SQL> insert into employee values('azar');

1 row created.

SQL> insert into employee values('kareem');

1 row created.

SQL> insert into employee values('jabar');

1 row created.

SQL> insert into employee values('ajmal');

1 row created.

SQL> commit;

Commit complete.

Step 2: Check Datafile

NAME
--------------------------------------------------------------------------------
+DATA/dbasm/datafile/system.256.753010703
+DATA/dbasm/datafile/sysaux.257.753010705
+DATA/dbasm/datafile/undotbs1.258.753010705
+DATA/dbasm/datafile/users.259.753010705
+DATA/dbasm/datafile/testtbs.275.753248961

Step 3:

             Take RMAN BACKUP

Step 4:
The source database is eligible for transporting to the destination operatingsystem platform by executing the dbms_tdb.check_db procedure.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  636100608 bytes
Fixed Size                  1338392 bytes
Variable Size             222299112 bytes
Database Buffers          406847488 bytes
Redo Buffers                5615616 bytes
Database mounted.
SQL> alter database open read only;

Database altered.

SQL> set serveroutput on
SQL> declare
  2  db_ready boolean;
  3  begin
  4  db_ready := dbms_tdb.check_db('Microsoft Windows x86 64-bit',dbms_tdb.skip_readonly);
  5  end;
  6  /

PL/SQL procedure successfully completed.

For External Table.

SQL> declare
  2  external boolean;
  3  begin
  4  external := dbms_tdb.check_external;
  5  end;
  6  /
The following directories exist in the database:
SYS.ORACLE_OCM_CONFIG_DIR, SYS.DATA_PUMP_DIR, SYS.XMLDIR

PL/SQL procedure successfully completed.

Step 5: Convert Database . Database should be in Read Only mode.

[oracle@mazar ~]$ rlwrap rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Wed Jun 8 05:28:46 2011

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

connected to target database: DBASM (DBID=2095353796)

RMAN> convert database new database 'dbasm'
2> transport script '/u01/temp/dbasm_script'
3> to platform 'Microsoft Windows x86 64-bit'
4> db_file_name_convert '+DATA/dbasm/datafile/' '/u01/temp/';

Starting conversion at source at 08-JUN-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=33 device type=DISK

Directory SYS.ORACLE_OCM_CONFIG_DIR found in the database
Directory SYS.DATA_PUMP_DIR found in the database
Directory SYS.XMLDIR found in the database

User SYS with SYSDBA and SYSOPER privilege found in password file
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00001 name=+DATA/dbasm/datafile/system.256.753010703
converted datafile=/u01/temp/system.256.753010703
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:59
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00002 name=+DATA/dbasm/datafile/sysaux.257.753010705
converted datafile=/u01/temp/sysaux.257.753010705
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00003 name=+DATA/dbasm/datafile/undotbs1.258.753010705
converted datafile=/u01/temp/undotbs1.258.753010705
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00005 name=+DATA/dbasm/datafile/testtbs.275.753248961
converted datafile=/u01/temp/testtbs.275.753248961
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile conversion
input datafile file number=00004 name=+DATA/dbasm/datafile/users.259.753010705
converted datafile=/u01/temp/users.259.753010705
channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03
Edit init.ora file /u01/app/oracle/product/11.2.0/dbhome_1/dbs/init_00mebgha_1_0.ora. This PFILE will be used to create the database on the target platform
Run SQL script /u01/temp/dbasm_script on the target platform to create database
To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the target platform
To change the internal database identifier, use DBNEWID Utility
Finished conversion at source at 08-JUN-11

RMAN>

Step 6:
Now Move the “dbasm_script”,pfile –“init_00mebgha_1_0.ora”, and all db file from “/u01/temp/”
to Windows platform using External Hard Disk.
Now you need to edit the “Init” file and “dbasm_script” appropriate your windows directory struture where you want restore
all datafiles.
i just Edited My init Ora file like Below

Step 7: copied init_00mebgha_1_0.ora and renamed it initDBASM.ora –>
C:\app\Azar\product\11.2.0\dbhome_1\dbs\initDBASM.ora
Edit initDBASM.ora

# Please change the values of the following parameters:

  db_create_file_dest      = "C:\app\Azar\product\11.2.0\dbhome_1\dbs\dbasm"

  db_recovery_file_dest    = "C:\app\Azar\product\11.2.0\dbhome_1\dbs\dbasm"

  db_recovery_file_dest_size= 8078229504

  audit_file_dest          = "C:\app\Azar\admin\dbasm\adump"

  db_name                  = "DBASM"

# Please review the values of the following parameters:

# __oracle_base            = "C:\app\Azar"

  __shared_pool_size       = 209715200

  __large_pool_size        = 4194304

  __java_pool_size         = 4194304

  __streams_pool_size      = 4194304

  __sga_target             = 637534208

  __db_cache_size          = 406847488

  __shared_io_pool_size    = 0

  remote_login_passwordfile= "EXCLUSIVE"

  db_domain                = ""

  dispatchers              = "(PROTOCOL=TCP) (SERVICE=dbasmXDB)"

  __pga_aggregate_target   = 213909504

# The values of the following parameters are from source database:

  processes                = 150

  sga_target               = 637534208

  db_block_size            = 8192

  compatible               = "11.2.0.0.0"

  log_archive_format       = "%t_%s_%r.dbf"

  undo_tablespace          = "UNDOTBS1"

  audit_trail              = "OS"

  open_cursors             = 300

  pga_aggregate_target     = 211812352

# diagnostic_dest          = "C:\app\Azar"

Step 8: Copied dbasm_script.sql file –> C:\app\dbasm_script.sql
Edited below like

STARTUP NOMOUNT PFILE='C:\app\Azar\product\11.2.0\dbhome_1\dbs\initDBASM.ora'

-- Create SPFILE
CREATE SPFILE FROM PFILE = 'C:\app\Azar\product\11.2.0\dbhome_1\dbs\initDBASM.ora';

STARTUP FORCE NOMOUNT
CREATE CONTROLFILE REUSE SET DATABASE "DBASM" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 SIZE 50M BLOCKSIZE 512,
  GROUP 2 SIZE 50M BLOCKSIZE 512,
  GROUP 3 SIZE 50M BLOCKSIZE 512
DATAFILE
  'C:\app\Azar\oradata\dbasm\system.256.753010703',
  'C:\app\Azar\oradata\dbasm\sysaux.257.753010705',
  'C:\app\Azar\oradata\dbasm\undotbs1.258.753010705',
  'C:\app\Azar\oradata\dbasm\users.259.753010705',
  'C:\app\Azar\oradata\dbasm\testtbs.275.753248961'
CHARACTER SET WE8MSWIN1252
;

-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;

-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE 
     SIZE 20971520  AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
-- End of tempfile additions.
--

set echo off
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
prompt * Your database has been created successfully!
prompt * There are many things to think about for the new database. Here
prompt * is a checklist to help you stay on track:
prompt * 1. You may want to redefine the location of the directory objects.
prompt * 2. You may want to change the internal database identifier (DBID) 
prompt *    or the global database name for this database. Use the 
prompt *    NEWDBID Utility (nid).
prompt ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~

SHUTDOWN IMMEDIATE 
STARTUP UPGRADE 
@@ ?/rdbms/admin/utlirp.sql 
SHUTDOWN IMMEDIATE 
STARTUP
-- The following step will recompile all PL/SQL modules.
-- It may take serveral hours to complete.
@@ ?/rdbms/admin/utlrp.sql 
set feedback 6;

Step 9:

Copied DBF files to “C:\app\Azar\oradata\dbasm\”

Step 10: Create new instance and password file

C:\Windows\system32>oradim -new -sid dbasm
Instance created.

C:\Windows\system32>orapwd file=c:\app\Azar\product\11.2.0\dbhome_1\database\PWDdbasm.ora password=Test123

Step 11: Run the script file

C:\Windows\system32>set ORACLE_SID=dbasm

C:\Windows\system32>sqlplus

SQL*Plus: Release 11.2.0.1.0 Production on Wed Jun 8 14:31:52 2011

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

Enter user-name: sys/Test123 as sysdba
Connected to an idle instance.

SQL> @c:\app\dbasm_script.sql
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes

File created.
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes

Control file created.

Database altered.

ALTER TABLESPACE TEMP ADD TEMPFILE
*
ERROR at line 1:
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]
ORA-00604: error occurred at recursive SQL level 1
ORA-06553: PLS-801: internal error [56327]

~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
* Your database has been created successfully!
* There are many things to think about for the new database. Here
* is a checklist to help you stay on track:
* 1. You may want to redefine the location of the directory objects.
* 2. You may want to change the internal database identifier (DBID)
*    or the global database name for this database. Use the
*    NEWDBID Utility (nid).
~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
Database closed.
Database dismounted.
ORACLE instance shut down.
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes
Database mounted
Database opened.

DOC>   utlirp.sql completed successfully. All PL/SQL objects in the
DOC>   database have been invalidated.
DOC>
DOC>   Shut down and restart the database in normal mode and run utlrp.sql to
DOC>   recompile invalid objects.
DOC>#######################################################################
DOC>#######################################################################
DOC>#
SQL> SHUTDOWN IMMEDIATE
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> STARTUP
ORACLE instance started.

Total System Global Area  634679296 bytes
Fixed Size                  2178416 bytes
Variable Size             184550032 bytes
Database Buffers          440401920 bytes
Redo Buffers                7548928 bytes
Database mounted.
Database opened.
SQL> -- The following step will recompile all PL/SQL modules.
SQL> -- It may take serveral hours to complete.
SQL> @@ ?/rdbms/admin/utlrp.sql
SQL> Rem
SQL> Rem $Header: utlrp.sql 24-jul-2003.10:06:51 gviswana Exp $
SQL> Rem
SQL> Rem utlrp.sql
SQL> Rem
SQL> Rem Copyright (c) 1998, 2003, Oracle Corporation.  All rights reserved.
SQL> Rem
SQL> Rem    NAME
SQL> Rem         utlrp.sql - Recompile invalid objects
SQL> Rem

Warning: XDB now invalid, could not find xdbconfig
ORDIM INVALID OBJECTS: CODE_SEQUENCE110_T - 6 - 13
ORDIM INVALID OBJECTS: CODE_SEQUENCE112_COLL - 6 - 13
ORDIM INVALID OBJECTS: CODE_SQ111_T - 6 - 13
ORDIM INVALID OBJECTS: ORD_DICOM_HEADER114_T - 6 - 13
ORDIM INVALID OBJECTS: MEDIA_STORAGE_SOP_CLASS116_T - 6 - 13
ORDIM INVALID OBJECTS: MEDIA_STORAGE_SOP_INSTA117_T - 6 - 13
ORDIM INVALID OBJECTS: TRANSFER_SYNTAX_UID118_T - 6 - 13
ORDIM INVALID OBJECTS: IMPLEMENTATION_CLASS_UI119_T - 6 - 13
ORDIM INVALID OBJECTS: IMPLEMENTATION_VERSION_120_T - 6 - 13
ORDIM INVALID OBJECTS: SOURCE_APPLICATION_ENTI121_T - 6 - 13
ORDIM INVALID OBJECTS: FILE_META_HEADER115_T - 6 - 13
ORDIM INVALID OBJECTS: NAME124_T - 6 - 13
ORDIM INVALID OBJECTS: ID125_T - 6 - 13
ORDIM INVALID OBJECTS: BIRTH_DATE126_T - 6 - 13
ORDIM INVALID OBJECTS: SEX127_T - 6 - 13
ORDIM INVALID OBJECTS: PATIENT123_T - 6 - 13
ORDIM INVALID OBJECTS: INSTANCE_UID129_T - 6 - 13
ORDIM INVALID OBJECTS: DATE130_T - 6 - 13
ORDIM INVALID OBJECTS: TIME132_T - 6 - 13
ORA-25153: Temporary Tablespace is Empty
ORA-01403: no data found
FAILED CHECK FOR PACKAGE BODY WWV_FLOW_API

PL/SQL procedure successfully completed.

Now Database successfully created.

Step 12: Check the new database

SQL> select status from v$instance;

STATUS
------------
OPEN

SQL> select name from v$database;

NAME
---------
DBASM

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
C:\APP\AZAR\ORADATA\DBASM\SYSTEM.256.753010703
C:\APP\AZAR\ORADATA\DBASM\SYSAUX.257.753010705
C:\APP\AZAR\ORADATA\DBASM\UNDOTBS1.258.753010705
C:\APP\AZAR\ORADATA\DBASM\USERS.259.753010705
C:\APP\AZAR\ORADATA\DBASM\TESTTBS.275.753248961

SQL> select * from v$tempfile;

no rows selected

SQL> ALTER TABLESPACE TEMP ADD TEMPFILE SIZE 20971520  AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;

Tablespace altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
C:\APP\AZAR\PRODUCT\11.2.0\DBHOME_1\DBS\DBASM\DBASM\DATAFILE\O1_MF_TEMP_6YYR9B7D
_.TMP

SQL> conn testme/testme
Connected.
SQL> select * from tab;

TNAME                          TABTYPE  CLUSTERID
------------------------------ ------- ----------
EMPLOYEE                       TABLE

SQL> select * from employee;

NAME
--------------------
azar
kareem
jabar
ajmal

SQL>

Ref :

http://download.oracle.com/docs/cd/E11882_01/backup.112/e10642/rcmxplat.htm#BRADV89986

 

 

RMAN-06091: no channel allocated for maintenance (of an appropriate type)

When I tried to delete obsolete backup, it shows following error.

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of delete command at 05/16/2011 14:41:39
RMAN-06091: no channel allocated for maintenance (of an appropriate type)


Solution :

Please refer
Encountered RMAN-03002 and RMAN-06091 when Deleting Obsolete Backups (Doc ID 567555.1)

Recover truncate table using RMAN tablespace point in time recovery

Here I’m go to demonstrate How do we recover truncate table using RMAN tablespace point in time recovery.

I hope This post may very user friendly for you without confusion 🙂

Step 1:  Create tablespace and allocate one user for this tablespace 

SQL> create tablespace rmantbs datafile 'c:\temp\rmnatbs01.dbf' size 100m;

Tablespace created.

SQL> create user rmantbs identified by rmantbs default tablespace rmantbs;

User created.

SQL> grant connect,resource to rmantbs;

Grant succeeded.

SQL> grant read,write on directory data_pump_dir to rmantbs;

Grant succeeded.

 

Step 2: Create another one tablespace and allocated another new user which one checking data lost will happen or not after TBPITR recovery done.

SQL> create tablespace rmantest datafile 'c:\temp\rmantest01.dbf' size 50m;

Tablespace created.

SQL> create user rmantest identified by rmantest default tablespace rmantest;

User created.

SQL> grant connect,resource to rmantest;

Grant succeeded.

Step 3: Create two table and insert few rows

SQL> set time on
21:12:02 SQL> conn rmantbs/rmantbs
Connected.
21:12:25 SQL> create table employee(empno number,empname varchar2(20));

Table created.

21:13:20 SQL> insert into employee values(001,'azar');

1 row created.

21:13:36 SQL> insert into employee values(002,'jabar');

1 row created.

21:13:45 SQL> insert into employee values(003,'kareem');

1 row created.

21:13:54 SQL> insert into employee values(004,'ajmal');

1 row created.

21:14:08 SQL> commit;

Commit complete.

21:14:11 SQL> create table empcity(cityname varchar2(20));

Table created.

21:14:41 SQL> insert into empcity values('riyadh');

1 row created.

21:14:53 SQL> commit;

Commit complete.

Step 4: create anothe one table for rmantest user which allocated rmantest tablespace.

:55 SQL> conn rmantest/rmantest
Connected.
21:15:01 SQL> create table a(empno number);

Table created.

21:15:14 SQL> insert into a values(001);

1 row created.

21:15:24 SQL> insert into a values(002);

1 row created.

21:15:29 SQL> insert into a values(003);

1 row created.

21:15:39 SQL> insert into a values(004);

1 row created.

21:15:42 SQL> commit;

Commit complete.

Step 5: Switch logfile

21:15:44 SQL> conn / as sysdba
Connected.
21:15:53 SQL> alter system switch logfile;

System altered.

Step 6: Backup database with archivelog

RMAN> backup database plus archivelog;
Starting backup at 25-APR-11
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=749251241
input archived log thread=1 sequence=3 RECID=2 STAMP=749332191
input archived log thread=1 sequence=4 RECID=3 STAMP=749333774
input archived log thread=1 sequence=5 RECID=4 STAMP=749333841
input archived log thread=1 sequence=6 RECID=5 STAMP=749333984
input archived log thread=1 sequence=7 RECID=6 STAMP=749338753
input archived log thread=1 sequence=8 RECID=7 STAMP=749342576
input archived log thread=1 sequence=9 RECID=8 STAMP=749342688
input archived log thread=1 sequence=10 RECID=9 STAMP=749417043
input archived log thread=1 sequence=11 RECID=10 STAMP=749423783
input archived log thread=1 sequence=12 RECID=11 STAMP=749423884
channel ORA_DISK_1: starting piece 1 at 25-APR-11
channel ORA_DISK_1: finished piece 1 at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BACKUPSET\2011_04_25\O1_MF_
ANNNN_TAG20110425T211805_6VCGPYCN_.BKP tag=TAG20110425T211805 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 25-APR-11

Starting backup at 25-APR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\APP\AZAR\ORADATA\RMANTBS\SYSTEM01.DBF
input datafile file number=00002 name=C:\APP\AZAR\ORADATA\RMANTBS\SYSAUX01.DBF
input datafile file number=00005 name=C:\TEMP\RMNATBS01.DBF
input datafile file number=00006 name=C:\TEMP\RMANTEST01.DBF
input datafile file number=00003 name=C:\APP\AZAR\ORADATA\RMANTBS\UNDOTBS01.DBF
input datafile file number=00004 name=C:\APP\AZAR\ORADATA\RMANTBS\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 25-APR-11
channel ORA_DISK_1: finished piece 1 at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BACKUPSET\2011_04_25\O1_MF_
NNNDF_TAG20110425T211821_6VCGQGL8_.BKP tag=TAG20110425T211821 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:55
Finished backup at 25-APR-11

Starting backup at 25-APR-11
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=13 RECID=12 STAMP=749424018
channel ORA_DISK_1: starting piece 1 at 25-APR-11
channel ORA_DISK_1: finished piece 1 at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BACKUPSET\2011_04_25\O1_MF_
ANNNN_TAG20110425T212018_6VCGV2GZ_.BKP tag=TAG20110425T212018 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 25-APR-11

Starting Control File and SPFILE Autobackup at 25-APR-11
piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\AUTOBACKUP\2011_04_25\O1_MF
_S_749424019_6VCGV4KX_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 25-APR-11

RMAN>

Step 7:  Note Current Timestamp before truncate table

21:16:23 SQL> select current_timestamp from dual;

CURRENT_TIMESTAMP
---------------------------------------------------------------------------
25-APR-11 09.21.30.293000 PM +03:00 21:21:30 SQL> conn rmantbs/rmantbs
Connected.
21:21:49 SQL> select * from employee;

     EMPNO EMPNAME
---------- --------------------
         1 azar
         2 jabar
         3 kareem
         4 ajmal

21:22:13 SQL> truncate table employee;

Table truncated.

Step 8: Insert some few rows for another one table which is usefull for whether data loss or not and also How do we preserve these data.

21:25:16 SQL> insert into empcity values('chennai');

1 row created.

21:27:14 SQL> insert into empcity values('trichy');

1 row created.

21:27:22 SQL> insert into empcity values('dammam');

1 row created.

21:27:33 SQL> conn rmantest/rmantest
Connected.
21:27:44 SQL> insert into a values(005);

1 row created.

21:27:53 SQL> commit;

Commit complete.

Step 9: Before you done tbpitr, you must check Determine and Resolved Dependencies

21:27:59 SQL> conn / as sysdba
Connected.
21:35:14 SQL> SELECT * FROM sys.ts_pitr_check WHERE(ts1_name = 'RMANTBS' AND ts2
_name != 'RMANTBS')  OR (ts1_name != 'RMANTBS' AND ts2_name = 'RMANTBS');

no rows selected

Step 10 : Determine Which Objects Will Not Be Recovered

For objects in tablespaces involved with the TSPITR, you’ll lose any transactions that were

created prior to the point to which you restore. If you need to preserve objects created after

the time to which you are going to restore, then you’ll need to use the Datapump or Export utility to save them.

After you have performed TSPITR, then you can import these objects.

21:36:47 SQL> SELECT owner, name, tablespace_name FROM ts_pitr_objects_to_be_dro
pped WHERE tablespace_name ='RMANTBS' AND creation_time > to_date('25-APR-11 09.
21.30','DD-MON-RRRR HH24:MI:SS');

OWNER                          NAME
------------------------------ ------------------------------
TABLESPACE_NAME
------------------------------
RMANTBS                        EMPLOYEE
RMANTBS

RMANTBS                        EMPCITY
RMANTBS

More details about See metalink ID TSPITR:How to check dependency of the objects and identifying objects that will be lost after TSPITR [ID 304308.1]

Step 11: Export the above two tables data for safe purpose.But Here Employee table not need, only EMPCITY table enough for export, However I exported two tables

C:\Users\Azar>expdp rmantbs/rmantbs directory=data_pump_dir dumpfile=datatbs.dmp
 logfile=datatbs.log tables=employee,empcity

Export: Release 11.2.0.1.0 - Production on Mon Apr 25 21:38:33 2011

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "RMANTBS"."SYS_EXPORT_TABLE_01":  rmantbs/******** directory=data_pump_
dir dumpfile=datatbs.dmp logfile=datatbs.log tables=employee,empcity
Estimate in progress using BLOCKS method...
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
Total estimation using BLOCKS method: 64 KB
Processing object type TABLE_EXPORT/TABLE/TABLE
. . exported "RMANTBS"."EMPCITY"                         5.062 KB       4 rows
. . exported "RMANTBS"."EMPLOYEE"                            0 KB       0 rows
Master table "RMANTBS"."SYS_EXPORT_TABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for RMANTBS.SYS_EXPORT_TABLE_01 is:
  C:\APP\AZAR\ADMIN\RMANTBS\DPDUMP\DATATBS.DMP
Job "RMANTBS"."SYS_EXPORT_TABLE_01" successfully completed at 21:38:53

 

Step 12: Recover Truncate table using TBPITR

RMAN> recover tablespace RMANTBS until time "to_date('25-APR-11 21:21:30','DD-MO
N-RRRR HH24:MI:SS')" auxiliary destination 'C:\TEMP\auxxtest';

Starting recover at 25-APR-11
using channel ORA_DISK_1
RMAN-05026: WARNING: presuming following set of tablespaces applies to specified
 point-in-time

List of tablespaces expected to have UNDO segments
Tablespace SYSTEM
Tablespace UNDOTBS1

Creating automatic instance, with SID='mbfF'
initialization parameters used for automatic instance:
db_name=RMANTBS
db_unique_name=mbfF_tspitr_RMANTBS
compatible=11.2.0.0.0
db_block_size=8192
db_files=200
sga_target=280M
processes=50
db_create_file_dest=C:\TEMP\auxxtest
log_archive_dest_1='location=C:\TEMP\auxxtest'
#No auxiliary parameter file used
starting up automatic instance RMANTBS

Oracle instance started

Total System Global Area     292278272 bytes

Fixed Size                     2175128 bytes
Variable Size                100667240 bytes
Database Buffers             184549376 bytes
Redo Buffers                   4886528 bytes
Automatic instance created
Running TRANSPORT_SET_CHECK on recovery set tablespaces
contents of Memory Script:
{
# set requested point in time
set until  time "to_date('25-APR-11 21:21:30','DD-MON-RRRR HH24:MI:SS')";
# restore the controlfile
restore clone controlfile;
# mount the controlfile
sql clone 'alter database mount clone database';
# archive current online log
sql 'alter system archive log current';
# avoid unnecessary autobackups for structural changes during TSPITR
sql 'begin dbms_backup_restore.AutoBackupFlag(FALSE); end;';
}
executing Memory Script

executing command: SET until clause

Starting restore at 25-APR-11
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=60 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: reading from backup piece C:\APP\AZAR\FLASH_RECOVERY_ARE
A\RMANTBS\AUTOBACKUP\2011_04_25\O1_MF_S_749424019_6VCGV4KX_.BKP
channel ORA_AUX_DISK_1: piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\AUT
OBACKUP\2011_04_25\O1_MF_S_749424019_6VCGV4KX_.BKP tag=TAG20110425T212019
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
output file name=C:\TEMP\AUXXTEST\RMANTBS\CONTROLFILE\O1_MF_6VCJBORG_.CTL
Finished restore at 25-APR-11

sql statement: alter database mount clone database

sql statement: alter system archive log current

sql statement: begin dbms_backup_restore.AutoBackupFlag(FALSE); end;

contents of Memory Script:
{
# set requested point in time
set until  time "to_date('25-APR-11 21:21:30','DD-MON-RRRR HH24:MI:SS')";
plsql <<<-- tspitr_2
declare
  sqlstatement       varchar2(512);
  offline_not_needed exception;
  pragma exception_init(offline_not_needed, -01539);
begin
  sqlstatement := 'alter tablespace '||  'RMANTBS' ||' offline immediate';
  krmicd.writeMsg(6162, sqlstatement);
  krmicd.execSql(sqlstatement);
exception
  when offline_not_needed then
    null;
end; >>>;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  2 to new;
set newname for clone tempfile  1 to new;
set newname for datafile  5 to
 "C:\TEMP\RMNATBS01.DBF";
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 3, 2, 5;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

sql statement: alter tablespace RMANTBS offline immediate

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME
renamed tempfile 1 to C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_TEMP_%U_.TMP in co
ntrol file

Starting restore at 25-APR-11
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00001 to C:\TEMP\AUXXTEST\RMANTBS\DAT
AFILE\O1_MF_SYSTEM_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00003 to C:\TEMP\AUXXTEST\RMANTBS\DAT
AFILE\O1_MF_UNDOTBS1_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00002 to C:\TEMP\AUXXTEST\RMANTBS\DAT
AFILE\O1_MF_SYSAUX_%U_.DBF
channel ORA_AUX_DISK_1: restoring datafile 00005 to C:\TEMP\RMNATBS01.DBF
channel ORA_AUX_DISK_1: reading from backup piece C:\APP\AZAR\FLASH_RECOVERY_ARE
A\RMANTBS\BACKUPSET\2011_04_25\O1_MF_NNNDF_TAG20110425T211821_6VCGQGL8_.BKP
channel ORA_AUX_DISK_1: piece handle=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\BAC
KUPSET\2011_04_25\O1_MF_NNNDF_TAG20110425T211821_6VCGQGL8_.BKP tag=TAG20110425T2
11821
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:26
Finished restore at 25-APR-11

datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=749425659 file name=C:\TEMP\AUXXTEST\RMANTBS\D
ATAFILE\O1_MF_SYSTEM_6VCJCP1B_.DBF
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=749425659 file name=C:\TEMP\AUXXTEST\RMANTBS\D
ATAFILE\O1_MF_UNDOTBS1_6VCJCP58_.DBF
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=749425659 file name=C:\TEMP\AUXXTEST\RMANTBS\D
ATAFILE\O1_MF_SYSAUX_6VCJCP53_.DBF

contents of Memory Script:
{
# set requested point in time
set until  time "to_date('25-APR-11 21:21:30','DD-MON-RRRR HH24:MI:SS')";
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  3 online";
sql clone "alter database datafile  2 online";
sql clone "alter database datafile  5 online";
# recover and open resetlogs
recover clone database tablespace  "RMANTBS", "SYSTEM", "UNDOTBS1", "SYSAUX" del
ete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online

sql statement: alter database datafile  3 online

sql statement: alter database datafile  2 online

sql statement: alter database datafile  5 online

Starting recover at 25-APR-11
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 13 is already on disk as file C:\APP\AZA
R\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_04_25\O1_MF_1_13_6VCGV25P_.ARC
archived log for thread 1 with sequence 14 is already on disk as file C:\APP\AZA
R\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_04_25\O1_MF_1_14_6VCJBXKV_.ARC
archived log file name=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_0
4_25\O1_MF_1_13_6VCGV25P_.ARC thread=1 sequence=13
archived log file name=C:\APP\AZAR\FLASH_RECOVERY_AREA\RMANTBS\ARCHIVELOG\2011_0
4_25\O1_MF_1_14_6VCJBXKV_.ARC thread=1 sequence=14
media recovery complete, elapsed time: 00:00:01
Finished recover at 25-APR-11

database opened

contents of Memory Script:
{
# make read only the tablespace that will be exported
sql clone 'alter tablespace  RMANTBS read only';
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
C:\TEMP\auxxtest''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
C:\TEMP\auxxtest''";
}
executing Memory Script

sql statement: alter tablespace  RMANTBS read only

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''C:\TEMP\auxx
test''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''C:\TEMP\auxx
test''

Performing export of metadata...
   EXPDP> Starting "SYS"."TSPITR_EXP_mbfF":
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   EXPDP> Master table "SYS"."TSPITR_EXP_mbfF" successfully loaded/unloaded
   EXPDP> **********************************************************************
********
   EXPDP> Dump file set for SYS.TSPITR_EXP_mbfF is:
   EXPDP>   C:\TEMP\AUXXTEST\TSPITR_MBFF_12962.DMP
   EXPDP> **********************************************************************
********
   EXPDP> Datafiles required for transportable tablespace RMANTBS:
   EXPDP>   C:\TEMP\RMNATBS01.DBF
   EXPDP> Job "SYS"."TSPITR_EXP_mbfF" successfully completed at 21:49:42
Export completed
contents of Memory Script:
{
# shutdown clone before import
shutdown clone immediate
# drop target tablespaces before importing them back
sql 'drop tablespace  RMANTBS including contents keep datafiles';
}
executing Memory Script

database closed
database dismounted
Oracle instance shut down

sql statement: drop tablespace  RMANTBS including contents keep datafiles

Performing import of metadata...
   IMPDP> Master table "SYS"."TSPITR_IMP_mbfF" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_mbfF":
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
   IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
   IMPDP> Job "SYS"."TSPITR_IMP_mbfF" successfully completed at 21:50:03
Import completed
contents of Memory Script:
{
# make read write and offline the imported tablespaces
sql 'alter tablespace  RMANTBS read write';
sql 'alter tablespace  RMANTBS offline';
# enable autobackups after TSPITR is finished
sql 'begin dbms_backup_restore.AutoBackupFlag(TRUE); end;';
}
executing Memory Script

sql statement: alter tablespace  RMANTBS read write

sql statement: alter tablespace  RMANTBS offline

sql statement: begin dbms_backup_restore.AutoBackupFlag(TRUE); end;

Removing automatic instance
Automatic instance removed
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_TEMP_6VCJGXY6_.T
MP deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\ONLINELOG\O1_MF_3_6VCJGTWP_.LOG
 deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\ONLINELOG\O1_MF_2_6VCJGST5_.LOG
 deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\ONLINELOG\O1_MF_1_6VCJGKK2_.LOG
 deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_SYSAUX_6VCJCP53_
.DBF deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_UNDOTBS1_6VCJCP5
8_.DBF deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\DATAFILE\O1_MF_SYSTEM_6VCJCP1B_
.DBF deleted
auxiliary instance file C:\TEMP\AUXXTEST\RMANTBS\CONTROLFILE\O1_MF_6VCJBORG_.CTL
 deleted
Finished recover at 25-APR-11

RMAN>

 Step 13 : After done it, Backup tablespace

RMAN>backup tablespace rmantbs;

Step 14: tablespace online

21:54:34 SQL> alter tablespace rmantbs online;

Tablespace altered.

Step 15:  Check whether truncate table recovered or not

:44 SQL> conn rmantbs/rmantbs;
Connected.
21:54:52 SQL> select * from employee;

     EMPNO EMPNAME
---------- --------------------
         1 azar
         2 jabar
         3 kareem
         4 ajmal

Now It was recovered.

Step 16: Now I’m going to check another table whether inserted data availble after done TBPITR time

21:55:01 SQL> select * from empcity;

CITYNAME
--------------------
riyadh

Not availble, So in this case I’m going to import this table data from dumpfile , this dumpfile taken before I do TBPITR

Step 17: Import table 

C:\Users\Azar>impdp rmantbs/rmantbs directory=data_pump_dir dumpfile=datatbs.dmp
 logfile=datatbsimp.log tables=empcity table_exists_action=append

Import: Release 11.2.0.1.0 - Production on Mon Apr 25 21:58:40 2011

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit
Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Master table "RMANTBS"."SYS_IMPORT_TABLE_01" successfully loaded/unloaded
Starting "RMANTBS"."SYS_IMPORT_TABLE_01":  rmantbs/******** directory=data_pump_
dir dumpfile=datatbs.dmp logfile=datatbsimp.log tables=empcity table_exists_acti
on=append
Processing object type TABLE_EXPORT/TABLE/TABLE
ORA-39152: Table "RMANTBS"."EMPCITY" exists. Data will be appended to existing t
able but all dependent metadata will be skipped due to table_exists_action of ap
pend
Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
. . imported "RMANTBS"."EMPCITY"                         5.062 KB       4 rows
Job "RMANTBS"."SYS_IMPORT_TABLE_01" completed with 1 error(s) at 21:58:42

21:55:09 SQL> conn rmantest/rmantest;
Connected.
21:55:28 SQL> select * from a;

     EMPNO
----------
         1
         2
         3
         4
         5

Step 18: And also I was checked , the other tablespace allocate table data consistent, Yes.

21:55:33 SQL> conn rmantbs/rmantbs;
Connected.
21:59:03 SQL> select * from empcity;

CITYNAME
--------------------
riyadh
riyadh
chennai
trichy
dammam

21:59:05 SQL>

Now Successfully Done It RMAN tablespace Point in time recovery.

 

 

 

 

Disaster Recovery:Restore database from one server to another server when different location

Here I just demonstrated How do we restore database from one server to another server when different location

Download PDF and Read It.

Right click this URL and Save as –> Location.

Disaster Recovery : Restore database from one Server to another Server when Different location

RMAN Configuring Tablespaces for Exclusion

In some cases you may want to exclude specified tablespace part of the regular backup schedule, as in these cases:

  •  A tablespace is easy to rebuild, so it is more cost-effective to rebuild it than back it up every day.
  • A tablespace contains temporary or test data that you do not need to back up.
  • A tablespace does not change often and therefore should be backed up on a different schedule from other backups.

Just a Example :

Step 1 : Create tablespace & User


SQL> create tablespace rman_ex datafile 'd:\backup\rman_ex01.dbf' size 50m;

Tablespace created.

SQL> create user rmanex identified by rmanex default tablespace rman_ex;

User created.

SQL> grant connect,resource to rmanex;

Grant succeeded.

SQL> conn rmanex/rmanex;
Connected.
SQL> create table a(empno number, city varchar2(20));

Table created.

SQL> insert into a values (001,'Riyadh');

1 row created.

SQL> insert into a values (002,'Mecca');

1 row created.

SQL> commit;

Commit complete.

Step 2: Configure tablespace Exclusion


SQL> $rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Tue Mar 8 09:30:17 2011

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

connected to target database: ACEME (DBID=4060208819)

RMAN> configure  exclude for tablespace rman_ex;

using target database control file instead of recovery catalog
Tablespace RMAN_EX will be excluded from future whole database backups
new RMAN configuration parameters are successfully stored.

Step 3: Backup Database , We can check here Whether that tablespace Include or Exclude.


RMAN> backup database;

Starting backup at 08-MAR-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=16 device type=DISK
file 5 is excluded from whole database backup
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\APP\MAZAR\ORADATA\ACEME\SYSTEM01.DBF
input datafile file number=00003 name=C:\APP\MAZAR\ORADATA\ACEME\UNDOTBS01.DBF
input datafile file number=00002 name=C:\APP\MAZAR\ORADATA\ACEME\SYSAUX01.DBF
input datafile file number=00004 name=C:\APP\MAZAR\ORADATA\ACEME\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 08-MAR-11
channel ORA_DISK_1: finished piece 1 at 08-MAR-11
piece handle=C:\APP\MAZAR\FLASH_RECOVERY_AREA\ACEME\BACKUPSET\2011_03_08\O1_MF_NNNDF_TAG20
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:56
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 08-MAR-11
channel ORA_DISK_1: finished piece 1 at 08-MAR-11
piece handle=C:\APP\MAZAR\FLASH_RECOVERY_AREA\ACEME\BACKUPSET\2011_03_08\O1_MF_NCSNF_TAG20
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-MAR-11.

Not Included Here.

Step 4: How do we take tablespace backup while configured exlcude option.


RMAN> backup database noexclude;

Starting backup at 08-MAR-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00001 name=C:\APP\MAZAR\ORADATA\ACEME\SYSTEM01.DBF
input datafile file number=00003 name=C:\APP\MAZAR\ORADATA\ACEME\UNDOTBS01.DBF
input datafile file number=00002 name=C:\APP\MAZAR\ORADATA\ACEME\SYSAUX01.DBF
input datafile file number=00005 name=D:\BACKUP\RMAN_EX01.DBF
input datafile file number=00004 name=C:\APP\MAZAR\ORADATA\ACEME\USERS01.DBF
channel ORA_DISK_1: starting piece 1 at 08-MAR-11
channel ORA_DISK_1: finished piece 1 at 08-MAR-11
piece handle=C:\APP\MAZAR\FLASH_RECOVERY_AREA\ACEME\BACKUPSET\2011_03_08\O1_MF_NNNDF_TAG20
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 08-MAR-11
channel ORA_DISK_1: finished piece 1 at 08-MAR-11
piece handle=C:\APP\MAZAR\FLASH_RECOVERY_AREA\ACEME\BACKUPSET\2011_03_08\O1_MF_NCSNF_TAG20
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-MAR-11

Step 5: Disable Configure Exclude method.


RMAN> configure exclude for tablespace rman_ex clear;

Tablespace RMAN_EX will be included in future whole database backups
old RMAN configuration parameters are successfully deleted

Ref : http://download.oracle.com/docs/cd/B28359_01/backup.111/b28270/rcmconfa.htm#i1015029

RMAN Recover database noredo commands

When our db running in noarchivelog mode, Online redolog file may failure occur during startup your db, how do you recover if you have a consistent cold backup avilable for your db ( No ArchiveLog Mode).

”  We can perform limited recovery of changes to a database running in NOARCHIVELOG mode by applying incremental backups. The incremental backups must be consistent, like all backups of a database run in NOARCHIVELOG mode, so you cannot back up the database when it is open.

Assume that you run database prod in NOARCHIVELOG mode with a recovery catalog. You shut down the database consistently and make a level 0 backup of database prod to tape on Sunday afternoon. You shut down the database consistently and make a level 1 differential incremental backup to tape at 3:00 a.m. on Wednesday and Friday.

On Saturday, a media failure destroys half of the datafiles as well as the online redo logs. Because the online logs are lost, you must specify the NOREDO option in the RECOVER command. Otherwise, RMAN searches for the redo logs after applying the Friday incremental backup and issues an error message when it does not find them. ”

Just a Example :

Step 1: Create user and table


Enter user-name: / as sysdba

Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> create tablespace testfor datafile 'c:\oracle\testfor01.dbf' size 50m;

Tablespace created.

SQL> create user testme identified by testme default tablespace testfor;

User created.

SQL> grant connect,resource to testme;

Grant succeeded.

SQL> conn testme/testme;
Connected.
SQL> create table test(emp varchar2(20));

Table created.

SQL> insert into test values('azar');

1 row created.

SQL> commit;

Commit complete.

Step 2 : Shutdown and Startup mount


SQL> conn / as sysdba
Connected.

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1247900 bytes
Variable Size              75498852 bytes
Database Buffers           88080384 bytes
Redo Buffers                2945024 bytes
Database mounted.

Step 3: I took RMAN Backup

SQL> host
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

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

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Feb 13 12:52:14 2011

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

connected to target database: TESTDB (DBID=2526327566, not open)
RMAN> backup incremental level 0 database;

Starting backup at 13-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental level 0 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSTEM01.D
BF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSAUX01.D
BF
input datafile fno=00005 name=C:\ORACLE\TESTFOR01.DBF
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\UNDOTBS01.
DBF
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\USERS01.DB
F
channel ORA_DISK_1: starting piece 1 at 13-FEB-11
channel ORA_DISK_1: finished piece 1 at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND0_TAG20110213T125556_6OHBODSD_.BKP tag=TAG20110213T125556 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 13-FEB-11

Starting Control File and SPFILE Autobackup at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\AUTOBACKUP\2011
_02_13\O1_MF_S_742999909_6OHBPTCT_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 13-FEB-11

RMAN> exit
Recovery Manager complete.

Step 4: I just added more rows for test table.

C:\Documents and Settings\Administrator>exit

SQL> alter database open;

Database altered.

SQL> conn testme/testme;
Connected.
SQL> insert into test values('kareem');

1 row created.

SQL> insert into test values('idrees');

1 row created.

SQL> insert into test values('jabar');

1 row created.

SQL> commit;

Commit complete.

SQL> conn / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1247900 bytes
Variable Size              75498852 bytes
Database Buffers           88080384 bytes
Redo Buffers                2945024 bytes
Database mounted.
SQL> host
Microsoft Windows XP [Version 5.1.2600]
(C) Copyright 1985-2001 Microsoft Corp.

Step 5:  Now I just took Incremantal backup

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

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Feb 13 12:59:41 2011

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

connected to target database: TESTDB (DBID=2526327566, not open)

RMAN> backup incremental level 1 database;

Starting backup at 13-FEB-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
channel ORA_DISK_1: starting incremental level 1 datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
input datafile fno=00001 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSTEM01.D
BF
input datafile fno=00003 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\SYSAUX01.D
BF
input datafile fno=00005 name=C:\ORACLE\TESTFOR01.DBF
input datafile fno=00002 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\UNDOTBS01.
DBF
input datafile fno=00004 name=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\USERS01.DB
F
channel ORA_DISK_1: starting piece 1 at 13-FEB-11
channel ORA_DISK_1: finished piece 1 at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND1_TAG20110213T125954_6OHBWTRJ_.BKP tag=TAG20110213T125954 commen
t=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 13-FEB-11

Starting Control File and SPFILE Autobackup at 13-FEB-11
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\AUTOBACKUP\2011
_02_13\O1_MF_S_743000354_6OHBXFQT_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 13-FEB-11

RMAN>

Step 6: Again I just added one row for TEST table


SQL> alter database open;

Database altered.

SQL> conn testme/testme;
Connected.
SQL> insert into test values('norecover');

1 row created.

SQL> commit;

Commit complete.

Step 7: Log group status


SQL> conn / as sysdba
Connected.
SQL> select group#,status,thread#,sequence#,first_change# from v$log;

    GROUP# STATUS              THREAD#  SEQUENCE# FIRST_CHANGE#
---------- ---------------- ---------- ---------- -------------
         1 CURRENT                   1          2        545486
         2 UNUSED                    1          0             0
         3 INACTIVE                  1          1        534907

Step 8: I just moved logile to another location


SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down. 

C:\oracle\product\10.2.0\oradata\testdb>move redo01.log c:\oracle\

SQL> startup mount
ORACLE instance started.

Total System Global Area  167772160 bytes
Fixed Size                  1247900 bytes
Variable Size              75498852 bytes
Database Buffers           88080384 bytes
Redo Buffers                2945024 bytes
Database mounted.
SQL> alter database open;
alter database open
*
ERROR at line 1:
ORA-00313: open failed for members of log group 1 of thread 1
ORA-00312: online log 1 thread 1:
'C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\REDO01.LOG'

SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.

Step 9: Now Time to recover using recover database NOREDO command.


RMAN> startup nomount

connected to target database (not started)
Oracle instance started

Total System Global Area     167772160 bytes

Fixed Size                     1247900 bytes
Variable Size                 75498852 bytes
Database Buffers              88080384 bytes
Redo Buffers                   2945024 bytes

RMAN> restore controlfile from autobackup;

Starting restore at 13-FEB-11
using channel ORA_DISK_1

recovery area destination: C:\oracle\product\10.2.0/flash_recovery_area
database name (or database unique name) used for search: TESTDB
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AR
EA\TESTDB\AUTOBACKUP\2011_02_13\O1_MF_S_743000354_6OHBXFQT_.BKP
channel ORA_DISK_1: control file restore from autobackup complete
output filename=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\CONTROL01.CTL
output filename=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\CONTROL02.CTL
output filename=C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\CONTROL03.CTL
Finished restore at 13-FEB-11

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

RMAN> restore database;

Starting restore at 13-FEB-11
Starting implicit crosscheck backup at 13-FEB-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 13-FEB-11

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

searching for all files in the recovery area
cataloging files...
cataloging done

List of Cataloged Files
=======================
File Name: C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\AUTOBACKUP\2011_0
2_13\O1_MF_S_743000354_6OHBXFQT_.BKP

using channel ORA_DISK_1

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

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

restoring datafile 00004 to C:\ORACLE\PRODUCT\10.2.0\ORADATA\TESTDB\USERS01.DBF
restoring datafile 00005 to C:\ORACLE\TESTFOR01.DBF
channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\10.2.0\FLASH_REC
OVERY_AREA\TESTDB\BACKUPSET\2011_02_13\O1_MF_NNND0_TAG20110213T125556_6OHBODSD_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND0_TAG20110213T125556_6OHBODSD_.BKP tag=TAG20110213T125556
channel ORA_DISK_1: restore complete, elapsed time: 00:01:16
Finished restore at 13-FEB-11

RMAN> recover database;

Starting recover at 13-FEB-11
using channel ORA_DISK_1
channel ORA_DISK_1: starting incremental datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
destination for restore of datafile 00001: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\SYSTEM01.DBF
destination for restore of datafile 00002: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\UNDOTBS01.DBF
destination for restore of datafile 00003: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\SYSAUX01.DBF
destination for restore of datafile 00004: C:\ORACLE\PRODUCT\10.2.0\ORADATA\TEST
DB\USERS01.DBF
destination for restore of datafile 00005: C:\ORACLE\TESTFOR01.DBF
channel ORA_DISK_1: reading from backup piece C:\ORACLE\PRODUCT\10.2.0\FLASH_REC
OVERY_AREA\TESTDB\BACKUPSET\2011_02_13\O1_MF_NNND1_TAG20110213T125954_6OHBWTRJ_.
BKP
channel ORA_DISK_1: restored backup piece 1
piece handle=C:\ORACLE\PRODUCT\10.2.0\FLASH_RECOVERY_AREA\TESTDB\BACKUPSET\2011_
02_13\O1_MF_NNND1_TAG20110213T125954_6OHBWTRJ_.BKP tag=TAG20110213T125954
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02

starting media recovery

unable to find archive log
archive log thread=1 sequence=2
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 02/13/2011 14:51:58
RMAN-06054: media recovery requesting unknown log: thread 1 seq 2 lowscn 547146

RMAN> recover database noredo;

Starting recover at 13-FEB-11
using channel ORA_DISK_1
Finished recover at 13-FEB-11

RMAN> alter database open resetlogs;

database opened

RMAN>

Now database Opened, I’m going to check Wheter my last added row avilable  (Step 6) or not because It added after taken incremental backup.


SQL> conn testme/testme;
Connected.
SQL> select * from test;

EMP
--------------------
azar
kareem
idrees
jabar

SQL>

Now There is no last added row avilable, because ” The recovered database reflects only changes up through the time of the Friday incremental backup. Because there are no archived redo logs, there is no way to recover changes made after the incremental backup ”

Ref :-

http://www.comp.dit.ie/btierney/oracle11gdoc/backup.111/b28273/rcmsynta030.htm#CHDHFBFI