Monday 27 January 2014

Cross-platform, cross-version tablespace transport (11g Windows to 12c Unix)



In 12c, RMAN can restore a Windows db backupset to a Unix environment.
The backupset can come from an earlier db version – 10g and later are supported.

For instance, a 11g tablespace backup, plus a transportable tablespace metadata dump file can be taken to a 12c database – from another platform - as long as endian format is same.

RMAN has new functionality to restore foreign tables/tablespaces/databases.
Foreign tables/tablespaces/databases are those which do not belong to the target database. The foreign objects may have come from another platform also.

The steps below are for a cross-platform, cross-version restore of a sample tablespace.
The technique used is a cross-platform restore followed by a transportable tablespace plug-in operation.

Source: Oracle Database 11g Enteprise Edition/Windows 2003 64 bit.
Destination: Oracle Database 12c Enterprise Edition/ Oracle Enterprise Linux 2.6.
Source schema: demo_user
Source tablespace name:ts_demo
Destination schema: salesadmin

Step 1 -  Check tablespace containment at the 11g source database.

Identify the tablespace and make sure it is self-contained and resolve containment issues, if any.
Run the dbms_tts.transport_set_check program and query the transport_set_violations view.
The view should not list any violations.


SQL>

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.3.0
Connected as SYS

 
SQL> begin
  2    dbms_tts.transport_set_check(ts_list => 'TS_DEMO');
  3  end;
  4  /

PL/SQL procedure successfully completed

SQL> select * from transport_set_violations;

VIOLATIONS
--------------------------------------------------------------------------------

SQL>
    

Step 2 - Make the tablespace read only and back it up as a backupset using RMAN at the 11g source.


Make the tablespace read only for doing a transportable tablespace operation.
Back up the tablespace using rman as a backupset. 


RMAN> SQL 'ALTER TABLESPACE TS_DEMO READ ONLY';
using target database control file instead of recovery catalog
sql statement: ALTER TABLESPACE TS_DEMO READ ONLY
RMAN> backup as compressed backupset tablespace TS_DEMO;
RMAN> backup as compressed backupset tablespace ts_demo format 'c:\temp\bkup_ts_demo.bck';
Starting backup at 27-JAN-14
using channel ORA_DISK_1
piece handle=C:\TEMP\BKUP_TS_DEMO.BCK tag=TAG20140127T154617 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 27-JAN-14
RMAN> EXIT
 

 Step 3  - Create a Data Pump transportable metadata dump file for plug-in to the 12c source.

  • Tablespace should be read only for this operation else it will fail.
  • Tablespace can be marked read-write after the dumpfile is created

C:\...Desktop> expdp system/oracle@demodb11g dumpfile=tts.dmp transport_tablespaces=TS_DEMO
Export: Release 11.2.0.3.0 - Production on Mon Jan 27 15:48:06 2014
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01":  system/********@demodb11g dumpfile=tts.dmp transport_tablespaces=TS_DEMO
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Master table "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully loaded/unloaded
******************************************************************************
Dump file set for SYSTEM.SYS_EXPORT_TRANSPORTABLE_01 is:
  D:\ORACLE11G\11.2.0.3\RDBMS\LOG\TTS.DMP
******************************************************************************
Job "SYSTEM"."SYS_EXPORT_TRANSPORTABLE_01" successfully completed at 15:48:35
Optionally change the tablespace back to read-write

 
Step 4 - Copy the backupset from #2 and the data pump file from #3 to the 12c destination.

Step 5 - At the destination create the users that own the tablespace objects (or remap to existing user later).

Step 6 - At 12c destination, start up RMAN, connect to the desired container and ensure its open read-write

Step 7 - Restore the backupset to the target using the RESTORE FROM PLATFORM command.


RESTORE FROM PLATFORM
 'Microsoft Windows x86 64-bit'
  All Foreign datafiles
   Format'/u01/app/oracle/oradata/CDB1/salespdb/ts_plugin_11g_%u.dbf'
    FROM BACKUPSET '/u01/app/oracle/oradata/tmp/BKUP_TS_DEMO.BCK';
RMAN> RESTORE FROM PLATFORM
 'Microsoft Windows x86 64-bit'
  All Foreign datafiles
   Format'/u01/app/oracle/oradata/CDB1/salespdb/ts_plugin_11g_%u.dbf'
    FROM BACKUPSET '/u01/app/oracle/oradata/tmp/BKUP_TS_DEMO.BCK';
2> 3> 4> 5>
Starting restore at 27-JAN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=28 device type=DISK
channel ORA_DISK_1: restoring foreign file 23 to /u01/app/oracle/oradata/CDB1/salespdb/ts_plugin_11g_i8ov4m25.dbf
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:26
Finished restore at 27-JAN-14
RMAN> exit

Note the name of the file(s) RMAN restores the tablespaces to, for use in the data pump plug-in command. Also note that the command specified ALL FOREIGN DATAFILES.
To control restore location, the file name pattern specified was: '/u01/app/oracle/oradata/CDB1/salespdb/ts_plugin_11g_%u.dbf'
The above RMAN restored the tablespace to this location
/u01/app/oracle/oradata/CDB1/salespdb/ts_plugin_11g_i8ov4m25.dbf

Step 8 - Create data pump directory object - in the target container

  • Connect to the desired container as system

  • Create the directory. 


[oracle@laboms ~]$ sqlplus system/oracle@salespdb
SQL*Plus: Release 12.1.0.1.0 Production on Thu Jan 23 14:55:09 2014
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Last Successful login time: Thu Jan 23 2014 14:54:45 +08:00
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options
SQL> select sys_context('USERENV','CON_NAME') from dual;
SYS_CONTEXT('USERENV','CON_NAME')
-------------------------------------------------------------------------------
SALESPDB
SQL> create directory dpdir as '/u01/app/oracle/oradata/tmp';
Directory created.
SQL>


Step 9 - Plug in the tablespace using Data Pump's transportable tablespace mode.

Data pump parameters used: 
Username/password    system/oracle@salespdb – connect to PDB not root
Directory            Dpdir (maps to location where the metadata dump is stored)
Remap_schema         Demo_user:hr 
                     Demo_user’s tables will be mapped to destination HR user
Transport_datafiles  The rman-restord file
                             /u01/app/oracle/oradata/CDB1/salespdb/ts_plugin_11g_4fouq10i.dbf
Exclude    OBJECT_GRANT,TRIGGER (do not import grants/triggers)


$ impdp system/oracle@salespdb directory=dpdir dumpfile=TTS.DMP remap_schema=demo:hr transport_datafiles=/u01/app/oracle/oradata/CDB1/salespdb/ts_plugin_11g_i8ov4m25.dbf exclude=OBJECT_GRANT,TRIGGERImport: Release 12.1.0.1.0 - Production on Mon Jan 27 16:24:06 2014
Copyright (c) 1982, 2013, Oracle and/or its affiliates.  All rights reserved.
Connected to: Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options
Master table "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully loaded/unloaded
Source TSTZ version is 14 and target TSTZ version is 18.
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01":  system/********@salespdb directory=dpdir dumpfile=TTS.DMP
remap_schema=demo_user:hr transport_datafiles=/u01/app/oracle/oradata/CDB1/salespdb
/ts_plugin_11g_i8ov4m25.dbf
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Mon Jan 27 16:24:31 2014 elapsed 0 00:00:22

Step 10 - Inspect the imported tablespace and its contents.

SQL> select TABLE_NAME, TABLESPACE_NAME from cdb_tables where owner='HR'
SQL> /

TABLE_NAME           TABLESPACE_NAME
-------------------- --------------------
MERCHANT             TS_DEMO
REWARDS              TS_DEMO
SETTLEMENT           TS_DEMO
TXN                  TS_DEMO
TXNDETAIL            TS_DEMO
TRIAL                TS_DEMO
STAGING              TS_DEMO

7 rows selected.


Sunday 26 January 2014

Restoring a 12c container database after loss of all datafiles, spfiles and control files.










Restoring a container database after loss of all of its files.
 
The restore will be done using a multisection image copy backup.

Oracle database 12c has a multisection image copy backup feature - which allows multiple sections of a huge datafile to be backed up in parallel but still producing a single output file per datafile.
In 11g, the multisection backup feature existed, but it created a multipart backupset and not an image copy.Image copies are much faster to restore and recover than backupsets – they are duplicates of the data files ( though they are larger).In this demonstration, we will use a multisection image copy backup and a controlfile autobackup to restore a fully destroyed multitenant container database.

Scenario:

The platform is Red Hat Linux 5 64 bit, running Oracle 12c release 1.
A CDB existed called CDB1, it had these tenant databases. It needs to be restored.

PDB$SEED – the seed database.
SALESPDB
SALESTEST
MARKETING
EXNONCDB

The CDB was operating in noarchivelog mode, and a backup had been taken in mount mode.
The CDB had been backed up using the multisection image copy backup feature, control file and spfile are also backed up due to the controlfile autobackup feature.
The spfile, password file, and the directory tree containing the CDB files and folders have all been deleted. There are no archived logs or online logs to apply and there is no media recovery to do.

This exercise will demonstrate recovery of the cdb after complete loss of all the datafiles, controlfiles and redo log files.

 1. Create a temp init.ora file containing these settings

DB_NAME=CDB1
CONTROL_FILES='/u01/app/oracle/oradata/cdb1/control1.ctl','/u01/app/oracle/oradata/cdb1/control2.ctl';
ENABLE_PLUGGABLE_DATABASE=TRUE;

2. Create a password file using orapwd, if you also lost the password file.

3. Retrieve the original database's dbid

If not using an fra, its part of the controlfile autobackup file name --> 802949696
  /u01/app/oracle/product/12.1.0/dbhome_1/dbs/c-802949696-20140105-00

4. Start up rman

[oracle@laboms cdb1]$ export ORACLE_SID=CDB1
[oracle@laboms cdb1]$ rman target /

Recovery Manager: Release 12.1.0.1.0 - Production on Wed Jan 8 08:16:32 2014

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

connected to target database (not started)


5. Startup the instance in nomount mode using the pfile created in step 1.
RMAN> startup nomount pfile='init.ora';


Oracle instance started

Total System Global Area     229683200 bytes

Fixed Size                     2286800 bytes
Variable Size                171969328 bytes
Database Buffers              50331648 bytes
Redo Buffers                   5095424 bytes

6. Set the DBID, restore the spfile from the controlfile autobackup.
RMAN> SET DBID 802949696;

executing command: SET DBID

RMAN> set controlfile autobackup format for device type disk to '/u01/app/oracle/product/12.1.0/dbhome_1/dbs/%F';

executing command: SET CONTROLFILE AUTOBACKUP FORMAT

RMAN> restore spfile from autobackup;

Starting restore at 08-JAN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=12 device type=DISK

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140108
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140107
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140106
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140105
channel ORA_DISK_1: AUTOBACKUP found: /u01/app/oracle/product/12.1.0/dbhome_1/dbs/c-802949696-20140105-00
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /u01/app/oracle/product/12.1.0/dbhome_1/dbs/c-802949696-20140105-00
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 08-JAN-14



7. Start up the database using the restored spfile.
RMAN> startup force nomount;

Oracle instance started

Total System Global Area    1570009088 bytes

Fixed Size                     2288776 bytes
Variable Size               1342178168 bytes
Database Buffers             218103808 bytes
Redo Buffers                   7438336 bytes


8. Restore the controlfile from the backup;
RMAN> restore controlfile from autobackup;

Starting restore at 08-JAN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK

channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140108
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140107
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140106
channel ORA_DISK_1: looking for AUTOBACKUP on day: 20140105
channel ORA_DISK_1: AUTOBACKUP found: /u01/app/oracle/product/12.1.0/dbhome_1/dbs/c-802949696-20140105-00
channel ORA_DISK_1: restoring control file from AUTOBACKUP /u01/app/oracle/product/12.1.0/dbhome_1/dbs/c-802949696-20140105-00
channel ORA_DISK_1: control file restore from AUTOBACKUP complete
output file name=/u01/app/oracle/oradata/cdb1/control1.ctl
output file name=/u01/app/oracle/oradata/cdb1/control2.ctl
Finished restore at 08-JAN-14


9. Mount the database.
RMAN> alter database mount;
Statement processed
released channel: ORA_DISK_1


10. Examine the controlfile metadata, to make sure restore destination folders exist (optional).

RMAN> report schema;

RMAN-06139: WARNING: control file is not current for REPORT SCHEMA
Report of database schema for database with db_unique_name CDB1

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    0        SYSTEM               ***     /u01/app/oracle/oradata/cdb1/system.ora
2    0        PDB$SEED:SYSTEM      ***     /u01/app/oracle/oradata/cdb1/seed/system.ora
3    0        SYSAUX               ***     /u01/app/oracle/oradata/cdb1/sysaux.ora
4    0        PDB$SEED:SYSAUX      ***     /u01/app/oracle/oradata/cdb1/seed/sysaux.ora
5    0        UNDOTBS              ***     /u01/app/oracle/oradata/cdb1/undo.ora
6    0        USERS                ***     /u01/app/oracle/oradata/cdb1/users.ora
7    0        PDB$SEED:USERS       ***     /u01/app/oracle/oradata/cdb1/seed/users.ora
23   0        SALESPDB:SYSTEM      ***     /u01/app/oracle/oradata/cdb1/salespdb/system.ora
24   0        SALESPDB:SYSAUX      ***     /u01/app/oracle/oradata/cdb1/salespdb/sysaux.ora
25   0        SALESPDB:USERS       ***     /u01/app/oracle/oradata/cdb1/salespdb/users.ora
26   0        SALESPDB:SALES       ***     /u01/app/oracle/oradata/cdb1/salespdb/sales.ora
32   0        SALESTEST:SYSTEM     ***     /u01/app/oracle/oradata/cdb1/salestest/system.ora
33   0        SALESTEST:SYSAUX     ***     /u01/app/oracle/oradata/cdb1/salestest/sysaux.ora
34   0        SALESTEST:USERS      ***     /u01/app/oracle/oradata/cdb1/salestest/users.ora
35   0        SALESTEST:TS_SALESTEST ***     /u01/app/oracle/oradata/cdb1/salestest/ts_salestest.ora
36   0        MARKETING:SYSTEM     ***     /u01/app/oracle/oradata/cdb1/marketing/system.ora
37   0        MARKETING:SYSAUX     ***     /u01/app/oracle/oradata/cdb1/marketing/sysaux.ora
38   0        MARKETING:USERS      ***     /u01/app/oracle/oradata/cdb1/marketing/users.ora
39   0        MARKETING:TS_SALESTEST ***     /u01/app/oracle/oradata/cdb1/marketing/ts_marketing.ora
50   0        EXNONCDB:SYSTEM      ***     /u01/app/oracle/oradata/cdb1/exnoncdb/system.ora
51   0        EXNONCDB:SYSAUX      ***     /u01/app/oracle/oradata/cdb1/exnoncdb/sysaux.ora
52   0        EXNONCDB:USERS       ***     /u01/app/oracle/oradata/cdb1/exnoncdb/users.ora
53   0        EXNONCDB:ILMTBS      ***     /u01/app/oracle/oradata/cdb1/exnoncdb/ilmts.ora
54   0        EXNONCDB:LOW_COST_STORE ***     /u01/app/oracle/oradata/cdb1/exnoncdb/lowcostts.ora

List of Temporary Files
=======================

File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    20       TEMP                 32767       /u01/app/oracle/oradata/cdb1/temp.ora
2    20       PDB$SEED:TEMP        32767       /u01/app/oracle/oradata/cdb1/seed/temp.ora
3    20       SALESPDB:TEMP        32767       /u01/app/oracle/oradata/cdb1/salespdb/temp.ora
4    20       SALESTEST:TEMP       32767       /u01/app/oracle/oradata/cdb1/salestest/temp.ora
5    15       SALESPDB:TEMPSALES   15          /u01/app/oracle/oradata/cdb1/salespdb/tempsales.ora
6    20       MARKETING:TEMP       32767       /u01/app/oracle/oradata/cdb1/marketing/temp.ora
7    20       EXNONCDB:TEMP        32767       /u01/app/oracle/oradata/cdb1/exnoncdb/temp.ora



11. Create any missing destinations
In the case of the example these folders were created under /u01/app/oracle/oradata/cdb1

seed
salespdb
salestest
marketing
exnoncdb
audit




12. Restore the database (note below that the rman is using input datafilecopy - indicates that an image copy is being used for restore).

RMAN> restore database;

Starting restore at 08-JAN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK

channel ORA_DISK_1: restoring datafile 00001
input datafile copy RECID=2 STAMP=836068929 file name=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/data_D-CDB1_I-802949696_TS-SYSTEM_FNO-1_05otapi1
destination for restore of datafile 00001: /u01/app/oracle/oradata/cdb1/system.ora
...
...
...
channel ORA_DISK_1: restoring datafile 00054
input datafile copy RECID=22 STAMP=836069342 file name=/u01/app/oracle/product/12.1.0/dbhome_1/dbs/data_D-CDB1_I-802949696_TS-LOW_COST_STORE_FNO-54_1cotaput
destination for restore of datafile 00054: /u01/app/oracle/oradata/cdb1/exnoncdb/lowcostts.ora
channel ORA_DISK_1: copied datafile copy of datafile 00054
output file name=/u01/app/oracle/oradata/cdb1/exnoncdb/lowcostts.ora RECID=0 STAMP=0
Finished restore at 08-JAN-14



13. Open the database with resetlogs
RMAN> alter database open resetlogs;

Statement processed


14. Exit rman and examine the db in SqlPlus
RMAN> exit


Recovery Manager complete.


[oracle@laboms cdb1]$ sqlplus sys/oracle@CDB1 as sysdba

SQL*Plus: Release 12.1.0.1.0 Production on Wed Jan 8 09:45:17 2014

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options

SQL> select pdb_name from cdb_pdbs;

PDB_NAME
--------------------------------------------------------------------------------
PDB$SEED
MARKETING
SALESTEST
SALESPDB
EXNONCDB


Restore a table's specific partition to a specific point in time

The ability to restore a specific Table/partition is new in 12c.

The procedures are analogous to the tablespace Point In Time recovery (PITR) of 11g.
Table/partition point-in-time restore can be considered an evolution of tablespace PITR.
This procedure is indicated for cases where:
  • Only a few tables need PITR but they are in a tablespace which contains many other tables.
  • Execution of DDL on the table or the lack of UNDO prevents use of FLASHBACK TABLE.

 About table/partition PITR

  • Available for CDBs and non-cdbs.
  • Uses an auxiliary instance to recover the specified tables to specified point.
  • Uses available backups/archive logs to achieve PITR.
  • Uses a data pump dump to optionally export the recovered tablespace or tables back to the target database.

Scenario

A CDB called CDB1 contains a PDB called SALESPDB.
The PDB has a partitioned table called sales.
This is a point-in-time recovery to a specific SCN, 495664950.

It has these partitions.

SQL> select table_owner, table_name, partition_name
from dba_tab_partitions where table_name='SALES';
  2 
TABLE_OWNER          TABLE_NAME           PARTITION_NAME
-------------------- -------------------- --------------------
SALESADMIN           SALES                P2010
SALESADMIN           SALES                P2011
SALESADMIN           SALES                P2012
SALESADMIN           SALES                P2013

SQL> select count(*) from salesadmin.sales partition(p2010);

  COUNT(*)
----------
       364

It will be recovered as a new table named P2010, to another tablespace called TS_RECOVERY.

The partition P2010 will be truncated at the below SCN, to simulate the data loss.


SQL> select current_scn from v$database;

CURRENT_SCN
-----------
  495664950
 


SQL> alter table salesadmin.sales truncate partition p2010;

Table truncated.
 


Using RMAN to restore the table


The RMAN syntax for the point-in-time recovery of the table partition is :

recover table salesadmin.sales:p2010
   of pluggable database salespdb
    until scn 495664950
    remap tablespace salespdb:ts_recov
     auxiliary destination '/u01/app/oracle/oradata/tmp';


controlfile backup checkpoint scn   : 1470397
restore point scn                            : 495664950
partition restore target tablespace : TS_RECOV
partition restore target schema      : SALESADMIN
partition restore destination table  : P2010



Precautions:
  • Ensure backups of cdb, controlfile, are available for an scn earlier than recovery point.
  • Ensure that archive logs are available to recover data upto the desired point.
  • Ensure enough disk space is available for auxiliary instance and the recovery operation.
  • Ensure that table owner has enough quota in destination tablespace for the restored partitions.
  • An auxiliary destination must be specified otherwise the command will fail.


The main steps executed in the rman-generated memory scripts are

  1. Auxiliary instance creation and startup in nomount mode
  2. Memory script to restore a suitable controlfile from a backup and mount it
  3. Restoring the system files of the CDB and PDB – auxiliary set (system,sysaux,undo)
  4. Memory script to perform media recovery of the auxiliary set to scn 495664950.
  5. Restart the auxiliary instance with an spfile and mount it.
  6. Restore datafile 9, which contains the actual user data which needs to be recovered
  7. Performing media recovery on the auxiliary data files and opens the auxiliary instance.
  8. Open the PDB, create data pump directory objects in target as well as auxiliary.
  9. Shut down the auxiliary instance and start export/import job.
  10. The remainder of the document shows the RMAN recover table session highlights its actions

The remainder of the document shows the RMAN recover table session highlights its actions

Recovery Manager: Release 12.1.0.1.0 - Production on Mon Jan 27 12:24:19 2014

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

connected to target database: CDB1 (DBID=801127382)

RMAN> recover table salesadmin.sales:p2010
   of pluggable database salespdb
    until scn 495664950
    remap tablespace salespdb:ts_recov
     auxiliary destination '/u01/app/oracle/oradata/tmp';
2> 3> 4> 5>

Auxiliary instance creation and startup in nomount mode


Starting recover at 27-JAN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=27 device type=DISK
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='kxnv'

initialization parameters used for automatic instance:
db_name=CDB1
db_unique_name=kxnv_pitr_salespdb_CDB1
compatible=12.1.0.0.0
db_block_size=8192
db_files=200
sga_target=1G
processes=80
diagnostic_dest=/u01/app/oracle
db_16k_cache_size=128M
db_create_file_dest=/u01/app/oracle/oradata/tmp
log_archive_dest_1='location=/u01/app/oracle/oradata/tmp'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used



starting up automatic instance CDB1

Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                251659520 bytes
Database Buffers             809500672 bytes
Redo Buffers                   5480448 bytes
Automatic instance created


Memory script to restore a suitable controlfile from a backup and mount it


contents of Memory Script:
{
# set requested point in time
set until  scn 495664950;
# 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';
}
executing Memory Script

executing command: SET until clause

Starting restore at 27-JAN-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=75 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 /u01/app/oracle/fast_recovery_area/CDB1/autobackup/2014_01_27/o1_mf_s_837947651_9gcmr5xn_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/autobackup/2014_01_27/o1_mf_s_837947651_9gcmr5xn_.bkp tag=TAG20140127T111411
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u01/app/oracle/oradata/tmp/CDB1/controlfile/o1_mf_9gcqw1mm_.ctl
Finished restore at 27-JAN-14

sql statement: alter database mount clone database

sql statement: alter system archive log current

Restoring the system files of the CDB and PDB - auxiliary set only (system,sysaux,undo)


contents of Memory Script:
{
# set requested point in time
set until  scn 495664950;
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  5 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  7 to new;
set newname for clone datafile  8 to new;
set newname for clone tempfile  1 to new;
set newname for clone tempfile  3 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 5, 3, 7, 8;
switch clone datafile all;
}
executing Memory Script
executing command: SET until clause
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
renamed tempfile 1 to /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 27-JAN-14
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 /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/backupset/2014_01_27/o1_mf_nnndf_TAG20140127T110930_9gcmhckh_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/backupset/2014_01_27/o1_mf_nnndf_TAG20140127T110930_9gcmhckh_.bkp tag=TAG20140127T110930
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:46
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 00007 to /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/E8B1D5DF593A7F63E0436801A8C0DFEC/backupset/2014_01_27/o1_mf_nnndf_TAG20140127T110930_9gcmln77_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E8B1D5DF593A7F63E0436801A8C0DFEC/backupset/2014_01_27/o1_mf_nnndf_TAG20140127T110930_9gcmln77_.bkp tag=TAG20140127T110930
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:15
Finished restore at 27-JAN-14

datafile 1 switched to datafile copy
input datafile copy RECID=13 STAMP=837952121 file name=/u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_system_9gcqw98r_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=837952121 file name=/u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_undotbs1_9gcqw96p_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=15 STAMP=837952121 file name=/u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_sysaux_9gcqw98n_.dbf
datafile 7 switched to datafile copy
input datafile copy RECID=16 STAMP=837952121 file name=/u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_system_9gcr1gbf_.dbf
datafile 8 switched to datafile copy
input datafile copy RECID=17 STAMP=837952121 file name=/u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_sysaux_9gcr1gbd_.dbf

Memory script to perform media recovery of the auxiliary set data files to scn 495664950


contents of Memory Script:
{
# set requested point in time
set until  scn 495664950;
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  5 online";
sql clone "alter database datafile  3 online";
sql clone 'SALESPDB' "alter database datafile
 7 online";
sql clone 'SALESPDB' "alter database datafile
 8 online";
# recover and open database read only
recover clone database tablespace  "SYSTEM", "UNDOTBS1", "SYSAUX", "SALESPDB":"SYSTEM", "SALESPDB":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  1 online
sql statement: alter database datafile  5 online
sql statement: alter database datafile  3 online
sql statement: alter database datafile  7 online
sql statement: alter database datafile  8 online

Starting recover at 27-JAN-14
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 237 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2014_01_27/o1_mf_1_237_9gcn8mqb_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2014_01_27/o1_mf_1_237_9gcn8mqb_.arc thread=1 sequence=237
media recovery complete, elapsed time: 00:00:01
Finished recover at 27-JAN-14

sql statement: alter database open read only

 

Restart the auxiliary instance with an spfile and mount it.


contents of Memory Script:
{
sql clone 'alter pluggable database  SALESPDB open read only';
}
executing Memory Script

sql statement: alter pluggable database  SALESPDB open read only

contents of Memory Script:
{
   sql clone "create spfile from memory";
   shutdown clone immediate;
   startup clone nomount;
   sql clone "alter system set  control_files =
  ''/u01/app/oracle/oradata/tmp/CDB1/controlfile/o1_mf_9gcqw1mm_.ctl'' comment=
 ''RMAN set'' scope=spfile";
   shutdown clone immediate;
   startup clone nomount;
# mount database
sql clone 'alter database mount clone database';
}
executing Memory Script
sql statement: create spfile from memory
database closed
database dismounted
Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                255853824 bytes
Database Buffers             805306368 bytes
Redo Buffers                   5480448 bytes

sql statement: alter system set  control_files =   ''/u01/app/oracle/oradata/tmp/CDB1/controlfile/o1_mf_9gcqw1mm_.ctl'' comment= ''RMAN set'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1068937216 bytes

Fixed Size                     2296576 bytes
Variable Size                255853824 bytes
Database Buffers             805306368 bytes
Redo Buffers                   5480448 bytes

sql statement: alter database mount clone database


Restore datafile 9, which contains the actual user data which needs to be recovered


contents of Memory Script:
{
# set requested point in time
set until  scn 495664950;
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile  9 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  9;
switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 27-JAN-14
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=11 device type=DISK

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 00009 to /u01/app/oracle/oradata/tmp/KXNV_PITR_SALESPDB_CDB1/datafile/o1_mf_salespdb_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece /u01/app/oracle/fast_recovery_area/CDB1/E8B1D5DF593A7F63E0436801A8C0DFEC/backupset/2014_01_27/o1_mf_nnndf_TAG20140127T110930_9gcmln77_.bkp
channel ORA_AUX_DISK_1: piece handle=/u01/app/oracle/fast_recovery_area/CDB1/E8B1D5DF593A7F63E0436801A8C0DFEC/backupset/2014_01_27/o1_mf_nnndf_TAG20140127T110930_9gcmln77_.bkp tag=TAG20140127T110930
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07
Finished restore at 27-JAN-14

datafile 9 switched to datafile copy
input datafile copy RECID=19 STAMP=837952172 file name=/u01/app/oracle/oradata/tmp/KXNV_PITR_SALESPDB_CDB1/datafile/o1_mf_salespdb_9gcr55b5_.dbf


Performing media recovery on the auxiliary data files and open the aux CDB database


contents of Memory Script:
{
# set requested point in time
set until  scn 495664950;
# online the datafiles restored or switched
sql clone 'SALESPDB' "alter database datafile
 9 online";
# recover and open resetlogs
recover clone database tablespace  "SALESPDB":"SALESPDB", "SYSTEM", "UNDOTBS1", "SYSAUX", "SALESPDB":"SYSTEM", "SALESPDB":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  9 online

Starting recover at 27-JAN-14
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 237 is already on disk as file /u01/app/oracle/fast_recovery_area/CDB1/archivelog/2014_01_27/o1_mf_1_237_9gcn8mqb_.arc
archived log file name=/u01/app/oracle/fast_recovery_area/CDB1/archivelog/2014_01_27/o1_mf_1_237_9gcn8mqb_.arc thread=1 sequence=237
media recovery complete, elapsed time: 00:00:00
Finished recover at 27-JAN-14

database opened

Opening the auxiliary instance PDB


contents of Memory Script:
{
sql clone 'alter pluggable database  SALESPDB open';
}
executing Memory Script

sql statement: alter pluggable database  SALESPDB open

Creating the directory objects in the target and auxiliary instance

contents of Memory Script:
{
# create directory for datapump import
sql 'SALESPDB' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata/tmp''";
# create directory for datapump export
sql clone 'SALESPDB' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/u01/app/oracle/oradata/tmp''";
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata/tmp''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/u01/app/oracle/oradata/tmp''

Exporting the recovered data to a .dmp file

Performing export of tables...
   EXPDP> Starting "SYS"."TSPITR_EXP_kxnv_Ewvl": 
   EXPDP> Estimate in progress using BLOCKS method...
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   EXPDP> Total estimation using BLOCKS method: 8 MB
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   EXPDP> . . exported "SALESADMIN"."SALES":"P2010"                12.62 KB     364 rows
   EXPDP> Master table "SYS"."TSPITR_EXP_kxnv_Ewvl" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_kxnv_Ewvl is:
   EXPDP>   /u01/app/oracle/oradata/tmp/tspitr_kxnv_86390.dmp
   EXPDP> Job "SYS"."TSPITR_EXP_kxnv_Ewvl" successfully completed at Mon Jan 27 12:30:59 2014 elapsed 0 00:00:41
Export completed


contents of Memory Script:
{
# shutdown clone before import
shutdown clone abort
}
executing Memory Script

Oracle instance shut down

Importing the data back to the target database according to the remaps specified


Performing import of tables...
   IMPDP> Master table "SYS"."TSPITR_IMP_kxnv_fnzi" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_kxnv_fnzi": 
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   IMPDP> . . imported "SALESADMIN"."SALES_P2010"                  12.62 KB     364 rows
   IMPDP> Job "SYS"."TSPITR_IMP_kxnv_fnzi" successfully completed at Mon Jan 27 12:31:16 2014 elapsed 0 00:00:09
Import completed


Cleaning up the auxiliary instance

Removing automatic instance
Automatic instance removed
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_temp_9gcr4b9f_.tmp deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_temp_9gcr3xfk_.tmp deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/KXNV_PITR_SALESPDB_CDB1/onlinelog/o1_mf_2_9gcr5jkh_.log deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/KXNV_PITR_SALESPDB_CDB1/onlinelog/o1_mf_1_9gcr5fxm_.log deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/KXNV_PITR_SALESPDB_CDB1/datafile/o1_mf_salespdb_9gcr55b5_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_sysaux_9gcr1gbd_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_system_9gcr1gbf_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_sysaux_9gcqw98n_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_undotbs1_9gcqw96p_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/datafile/o1_mf_system_9gcqw98r_.dbf deleted
auxiliary instance file /u01/app/oracle/oradata/tmp/CDB1/controlfile/o1_mf_9gcqw1mm_.ctl deleted
auxiliary instance file tspitr_kxnv_86390.dmp deleted
Finished recover at 27-JAN-14

RMAN>
   
 

The restore operation leaves the recovered partition in a table named SALES_P2010 by default, leaving the original table and rest of the database as-is.


[oracle@laboms ~]$ sqlplus salesadmin/oracle@SALESPDB

SQL*Plus: Release 12.1.0.1.0 Production on Mon Jan 27 13:15:01 2014

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

Last Successful login time: Mon Jan 27 2014 13:04:07 +08:00

Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics, Real Application Testing
and Unified Auditing options

SQL> select count(*) from salesadmin.sales_p2010;

  COUNT(*)
----------
       364

SQL> select count(*) from salesadmin.sales partition(p2010);

  COUNT(*)
----------
         0

SQL>




Cross platform database transport

RMAN cross platform transport can transport specific tablespaces or the entire database.

Cross platform tablespace transport
RMAN CONVERT DATAFILE is used to transport tablespaces to the destinaton platform.
The CONVERT DATAFILE command is required to achieve transformation of the datafile to the destination endian format. After the CONVERT, the Oracle transportable tablespace feature used to plug in the tablespaces at the destination.

Cross platform database transport
RMAN converts the entire database – but the destination endian format should be the same  as source. For cases where destination endian format differs, tablespace transport is required.

Topics:
Using RMAN to back up the entire database to a specific platform
Using RMAN to restore the database at the target platform

Environment:
Oracle Database 12c Enterprise Edition, little endian
Source: Oracle Enterprise Linux 64bit
Destination: Windows 7 64bit

Using new BACKUP syntax, a cross-platform backup can be created for a specific target platform ( BACKUP TO PLATFORM) at the source itself, or, alternatively, the conversion can be done at the destination (BACKUP FOR TRANSPORT).


Scenario:
A CDB named CDB2 running on Linux. It has one PDB, called HRPDB.



SQL> select pdb_name from cdb_pdbs;

    PDB_NAME
    -----------
    PDB$SEED
    HRPDB


The above CDB will be transported to the Windows platform using RMAN.

Steps:
  1. Perform pre-transport checks to ensure the database can be transported.
  2. Backup the database at the source (platform conversion occurs here for this example)
  3. Copy the generated backup sets to the destination using ftp
  4. Configure a pfile and set up the windows service at the destination using oradim.
  5. Start up the instance using the pfile and restore the backups at the destination
  6. Script a controlfile, create it and mount the database.
  7. Open the database with resetlogs.
  8. Optionally , back up the new database.

Step 1 - Pre-transport checks

The database should be checked with the dbms_tdb.check_db procedure call first.
The database should be opened in read-only mode first.
This procedure accepts a destination platform name as its argument and returns a boolean to indicate whether or not the database can be transported to the target platform. For example the database can be checked with a pl/sql block as shown below:

SQL> ed
Wrote file afiedt.buf

1 DECLARE
2 db_ready BOOLEAN;
3 BEGIN
4 db_ready :=
5 DBMS_TDB.CHECK_DB('Microsoft Windows x86 64-bit');
6 if (db_ready) then
7 dbms_output.put_line('db is ready');
8 else
9 dbms_output.put_line('db is not ready');
10 end if;
11* END;
SQL> /

db is ready


Step 2 - Back up the database using BACKUP TO PLATFORM...

The RMAN BACKUP TO PLATFORM <platform> DATABASE command creates a platform-specific database backup.
 
RMAN> backup to platform 'Microsoft Windows x86 64-bit' database        
2>      format '/u01/app/oracle/oradata/tmp/%U';

The target platform name specified in the BACKUP command above can be retrieved from
v$trasportable_platform using a query such as :

 1  select platform_id, platform_name from v$transportable_platform
  2* where platform_name like '%Windows%'
SQL> /

PLATFORM_ID PLATFORM_NAME
----------- --------------------------------------------------
          7 Microsoft Windows IA (32-bit)
          8 Microsoft Windows IA (64-bit)
         12 Microsoft Windows x86 64-bit

Note:
Cross-platform backups such as this one are not cataloged.
Cross-platform controlfile backups are not supported.
The platform conversion is being done at source database itself.

For example, in the rman session below, a CDB is being backed up to Windows platform:

RMAN created 3 backupsets, one per container, output files are shown in bold.



RMAN> backup to platform  
2>      'Microsoft Windows x86 64-bit'
3>     database format '/u01/app/oracle/oradata/%U';

Starting backup at 25-JAN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=11 device type=DISK
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/u01/app/oracle/oradata/cdb2/undo.ora
input datafile file number=00001 name=/u01/app/oracle/oradata/cdb2/system.ora
input datafile file number=00003 name=/u01/app/oracle/oradata/cdb2/sysaux.ora
input datafile file number=00006 name=/u01/app/oracle/oradata/cdb2/users.ora
channel ORA_DISK_1: starting piece 1 at 25-JAN-14
channel ORA_DISK_1: finished piece 1 at 25-JAN-14

piece handle=/u01/app/oracle/oradata/01ouvobi_1_1 tag=TAG20140125T192642 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:01:06
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=/u01/app/oracle/oradata/cdb2/hrpdb/system.ora
input datafile file number=00018 name=/u01/app/oracle/oradata/cdb2/hrpdb/sysaux.ora
input datafile file number=00019 name=/u01/app/oracle/oradata/cdb2/hrpdb/users.ora
input datafile file number=00020 name=/u01/app/oracle/oradata/cdb2/hrpdb/hr.ora
channel ORA_DISK_1: starting piece 1 at 25-JAN-14
channel ORA_DISK_1: finished piece 1 at 25-JAN-14

piece handle=/u01/app/oracle/oradata/02ouvodk_1_1 tag=TAG20140125T192642 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00002 name=/u01/app/oracle/oradata/cdb2/seed/system.ora
input datafile file number=00004 name=/u01/app/oracle/oradata/cdb2/seed/sysaux.ora
input datafile file number=00007 name=/u01/app/oracle/oradata/cdb2/seed/users.ora
channel ORA_DISK_1: starting piece 1 at 25-JAN-14
channel ORA_DISK_1: finished piece 1 at 25-JAN-14

piece handle=/u01/app/oracle/oradata/03ouvoed_1_1 tag=TAG20140125T192642 comment=NONE

channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 25-JAN-14

RMAN>


RMAN created 3 backupsets, one per container.

Step 3 - Copy the backupsets to the destination

The next step is to copy the four backupsets to the Windows server using ftp. For this example, the backupsets were copied to the c:\temp folder. Select a location for the files to be restored. It will be c:\temp\cdb2 for this example.

Step 4 - Configure pfile and a Windows database service for the new db instance.

Create new service on windows using this command:
   oradim -new -sid CDB2
Create a password file for the new instance using orapwd
   orapwd password=oracle file=PWDCDB2.ORA
Create a temp parameter file init.ora containing these lines.
   DB_NAME=CDB2
   ENABLE_PLUGGABLE_DATABASE=TRUE
   DB_CREATE_FILE_DEST='C:\temp\CDB2'
   CONTROL_FILES='c:\temp\CDB2\control1.ctl','c:\temp\CDB2\control2.ctl'
Ensure that the Oracle listener, and the new oradim-created Windows service are up.

 

Step 5 - Start up the instance and use RMAN to restore at the destination

Start up rman, connect to the new instance as target and restore the backupsets as shown. RMAN output is edited for clarity. 

RMAN> startup nomount  pfile='c:\temp\init.ora';
Oracle instance started
Total System Global Area     275615744 bytes
Fixed Size                     2401624 bytes
Variable Size                218106536 bytes
Database Buffers              50331648 bytes
Redo Buffers                   4775936 bytes
RMAN> restore all foreign datafiles to new
2>      from backupset 'c:\temp\03ouvoed_1_1';

Starting restore at 26-JAN-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=429 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring all foreign files in backup piece
channel ORA_DISK_1: reading from backup piece c:\temp\03ouvoed_1_1
channel ORA_DISK_1: restoring foreign file 2 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8M4RSP_.DBF
channel ORA_DISK_1: restoring foreign file 4 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8M4RT0_.DBF
channel ORA_DISK_1: restoring foreign file 7 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_USERS_9G8M4RTB_.DBF
channel ORA_DISK_1: foreign piece handle=c:\temp\03ouvoed_1_1
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:26
Finished restore at 26-JAN-14


Repeat the step for the other two backupsets as shown.

RMAN> restore all foreign datafiles to new
2>      from backupset 'c:\temp\02ouvodk_1_1';

...
channel ORA_DISK_1: restoring foreign file 17 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8M91VY_.DBF
channel ORA_DISK_1: restoring foreign file 18 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8M9203_.DBF
channel ORA_DISK_1: restoring foreign file 19 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_USERS_9G8M920M_.DBF
channel ORA_DISK_1: restoring foreign file 20 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SALES_9G8M920M_.DBF


RMAN> restore all foreign datafiles to new
2>      from backupset 'c:\temp\01ouvobi_1_1';
...
channel ORA_DISK_1: reading from backup piece c:\temp\01ouvobi_1_1
channel ORA_DISK_1: restoring foreign file 5 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_UNDOTBS_9G8MD5NK_.DBF
channel ORA_DISK_1: restoring foreign file 1 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8MD5RG_.DBF
channel ORA_DISK_1: restoring foreign file 3 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8MD5RG_.DBF
channel ORA_DISK_1: restoring foreign file 6 to C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_USERS_9G8MD5RY_.DBF


Step 6 - Script a CREATE CONTROLFILE command, create it at the destination.

The next step is to create the controlfile.
Using the RMAN restore output, create a script to do a CREATE CONTROLFILE. The controlfile datafile section should list all the restored datafiles. The CREATE CONTROLFILE statement should be scripted with care.


RESETLOGS will be needed as the online log files are not transported.  The database will be mounted automatically after the statement runs.
 
For example:
RMAN> CREATE CONTROLFILE DATABASE "CDB2" RESETLOGS  NOARCHIVELOG
2> maxlogfiles 2
3> maxdatafiles 50
4> LOGFILE
5>   GROUP 1 'c:\app\oracle\oradata\cdb2\redo1.ora'  SIZE 50M,
6>   GROUP 2 'c:\app\oracle\oradata\cdb2\redo2.ora'  SIZE 50M
7> DATAFILE
8> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_SALES_9G8Q8DVX_.DBF',
9> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8Q3GF3_.DBF',
10> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8Q8DSS_.DBF',
11> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8QCBTQ_.DBF',
12> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8Q3GBF_.DBF',
13> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8Q8DQF_.DBF',
14> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8QCBTG_.DBF',
15> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_UNDOTBS_9G8Q3G92_.DBF',
16> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_USERS_9G8Q3GFD_.DBF',
17> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_USERS_9G8Q8DVO_.DBF',
18> 'C:\temp\cdb2\CDB2\DATAFILE\O1_MF_USERS_9G8QCC3L_.DBF'
19> CHARACTER SET AL32UTF8
20> ;
Statement processed
released channel: ORA_DISK_1

Step 7 - Open the new destination database with resetlogs

Open the database with RESETLOGS and examine file structure from SqlPlus

RMAN> alter database open resetlogs;

Statement processed

SQL> select b.pdb_name, substr(a.name,1,60) name from v$datafile a
  2      join cdb_pdbs b on (a.con_id=b.con_id) order by b.pdb_name;

PDB_NAME   NAME
---------- -------------------------------------------------------------------
HRPDB      C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8Q3GF3_.DBF
HRPDB      C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_UNDOTBS_9G8Q3G92_.DBF
HRPDB      C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_USERS_9G8Q3GFD_.DBF
HRPDB      C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8Q3GBF_.DBF
PDB$SEED   C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSAUX_9G8Q3GF3_.DBF
PDB$SEED   C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_UNDOTBS_9G8Q3G92_.DBF
PDB$SEED   C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_USERS_9G8Q3GFD_.DBF
PDB$SEED   C:\TEMP\CDB2\CDB2\DATAFILE\O1_MF_SYSTEM_9G8Q3GBF_.DBF

8 rows selected.