Oct 10, 2016

Restore and Recover entire CDB in different host using Oracle 12c

We will discuss:
1) Complete CDB restore in different host
and..
2) Create new PDBs
3) Change all PDB passwords for container in one go
4) 12c Networking, Connecting PDBs via oracle client

About CDB and PDB:

Recovery of CDB, ROOT and PDB Database in 12c can be performed at the CDB container level (with ALL PDBs), ROOT or as at the individual PDB level. For the recovery at the CDB level, obviously the backups for ALL the PDBs must be present. Conversely it does not matter whether the backups, were taken at the CDB level (with all PDBs) or backups performed for individual PDBs. RMAN will automatically choose the appropriate backup sets to recover some or all the databases, as instructed. Let’s look at how a recovery of a CDB and PDB can be performed in Oracle 12C, multi-tenant environment.

1) Complete CDB restore in different host

Source : 192.168.1.17 – hostname : uatdb1
Target : 192.168.1.18 – hostname : uatdb2 ( software installed only)

$ export ORACLE_HOME=/u01/oracle/app/product/12.1.0.2/dbhome_1
$ export PATH=$ORACLE_HOME/bin:$PATH
$ export ORACLE_SID=CDB

List the Pluggable databases- Source

$export ORACLE_SID=CDB
$ sqlplus / as sysdba
SQL> select DBID,NAME,OPEN_MODE from v$pdbs;

      DBID NAME                           OPEN_MODE
---------- ------------------------------ ----------
1401480341 PDB$SEED                       READ ONLY
 202699746 PDB1                           READ WRITE
  24383494 SALESPDB                       READ WRITE
2563786999 PDB2                           READ WRITE

OR
SQL> show pdbs

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 SALESPDB                       READ WRITE NO
         5 PDB2                           READ WRITE NO
SQL>

Take backup of Container Database (CDB):

[oracle@uatdb1 ~]$ rman target /

RMAN> backup database plus archivelog;

Starting backup at 07-OCT-2016 13:51:51
current log archived
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=17 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=28 RECID=1 STAMP=924467464
input archived log thread=1 sequence=29 RECID=2 STAMP=924473335
input archived log thread=1 sequence=30 RECID=3 STAMP=924507007
input archived log thread=1 sequence=31 RECID=4 STAMP=924518991
input archived log thread=1 sequence=32 RECID=5 STAMP=924526780
input archived log thread=1 sequence=33 RECID=6 STAMP=924526948
input archived log thread=1 sequence=34 RECID=7 STAMP=924546618
input archived log thread=1 sequence=35 RECID=8 STAMP=924559473
input archived log thread=1 sequence=36 RECID=9 STAMP=924579215
input archived log thread=1 sequence=37 RECID=10 STAMP=924604282
input archived log thread=1 sequence=38 RECID=11 STAMP=924616313
channel ORA_DISK_1: starting piece 1 at 07-OCT-2016 13:51:55
channel ORA_DISK_1: finished piece 1 at 07-OCT-2016 13:52:02
piece handle=/u10/EXAM/fast_recovery_area/CDB/backupset/2016_10_07/o1_mf_annnn_TAG20161007T135154_czgps3md_.bkp tag=TAG20161007T135154 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:07
Finished backup at 07-OCT-2016 13:52:02

Starting backup at 07-OCT-2016 13:52:02
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=/u10/EXAM/ORADATA/CDB/system01.dbf
input datafile file number=00003 name=/u10/EXAM/ORADATA/CDB/sysaux01.dbf
input datafile file number=00004 name=/u10/EXAM/ORADATA/CDB/undotbs01.dbf
input datafile file number=00006 name=/u10/EXAM/ORADATA/CDB/users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-OCT-2016 13:52:03
channel ORA_DISK_1: finished piece 1 at 07-OCT-2016 13:52:28
piece handle=/u10/EXAM/fast_recovery_area/CDB/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpscc9_.bkp tag=TAG20161007T135202 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=00012 name=/u10/EXAM/ORADATA/CDB/salespdb/sysaux01.dbf
input datafile file number=00011 name=/u10/EXAM/ORADATA/CDB/salespdb/system01.dbf
input datafile file number=00013 name=/u10/EXAM/ORADATA/CDB/salespdb/sales01.dbf
channel ORA_DISK_1: starting piece 1 at 07-OCT-2016 13:52:28
channel ORA_DISK_1: finished piece 1 at 07-OCT-2016 13:52:43
piece handle=/u10/EXAM/fast_recovery_area/CDB/3E09A4600B4CDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpt4nq_.bkp tag=TAG20161007T135202 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00009 name=/u10/EXAM/ORADATA/CDB/pdb1/sysaux01.dbf
input datafile file number=00008 name=/u10/EXAM/ORADATA/CDB/pdb1/system01.dbf
input datafile file number=00010 name=/u10/EXAM/ORADATA/CDB/pdb1/pdb1_users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-OCT-2016 13:52:43
channel ORA_DISK_1: finished piece 1 at 07-OCT-2016 13:53:08
piece handle=/u10/EXAM/fast_recovery_area/CDB/3E08803B3049DDBBE053110112AC46EF/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgptmyp_.bkp tag=TAG20161007T135202 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=00015 name=/u10/EXAM/ORADATA/CDB/pdb2/sysaux01.dbf
input datafile file number=00014 name=/u10/EXAM/ORADATA/CDB/pdb2/system01.dbf
input datafile file number=00016 name=/u10/EXAM/ORADATA/CDB/pdb2/pdb1_users01.dbf
channel ORA_DISK_1: starting piece 1 at 07-OCT-2016 13:53:09
channel ORA_DISK_1: finished piece 1 at 07-OCT-2016 13:53:24
piece handle=/u10/EXAM/fast_recovery_area/CDB/3E09A4600B4EDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvfc2_.bkp tag=TAG20161007T135202 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00007 name=/u10/EXAM/ORADATA/CDB/pdbseed/sysaux01.dbf
input datafile file number=00005 name=/u10/EXAM/ORADATA/CDB/pdbseed/system01.dbf
channel ORA_DISK_1: starting piece 1 at 07-OCT-2016 13:53:24
channel ORA_DISK_1: finished piece 1 at 07-OCT-2016 13:53:39
piece handle=/u10/EXAM/fast_recovery_area/CDB/3E07F6ABA9E6D2BCE053110112ACF374/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvwmd_.bkp tag=TAG20161007T135202 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 07-OCT-2016 13:53:39

Starting backup at 07-OCT-2016 13:53:39
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=39 RECID=12 STAMP=924616420
channel ORA_DISK_1: starting piece 1 at 07-OCT-2016 13:53:40
channel ORA_DISK_1: finished piece 1 at 07-OCT-2016 13:53:41
piece handle=/u10/EXAM/fast_recovery_area/CDB/backupset/2016_10_07/o1_mf_annnn_TAG20161007T135340_czgpwdtw_.bkp tag=TAG20161007T135340 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 07-OCT-2016 13:53:41

Starting Control File and SPFILE Autobackup at 07-OCT-2016 13:53:42
piece handle=/u10/EXAM/fast_recovery_area/CDB/autobackup/2016_10_07/o1_mf_s_924616422_czgpwj40_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 07-OCT-2016 13:53:45
RMAN>

Restore to Target - software installed only:

Prepare the Target database:

Create the directory structures as shown in pfile along with datafile paths.

e.g.,
$ mkdir /u10/EXAM/ORADATA/CDB
$ mkdir /u10/EXAM/ORADATA/CDB/pdbseed
$ mkdir /u10/EXAM/ORADATA/CDB/pdb1
$ mkdir /u10/EXAM/ORADATA/CDB/salespdb
$ mkdir /u10/EXAM/ORADATA/CDB/pdb2
$ mkdir –p /u01/oracle/app/admin/CDB/adump
$ mkdir –p /u10/EXAM/ORADATA/CDB
$ mkdir –p /u10/EXAM/fast_recovery_area/CDB

-- Create pfile :

*.audit_file_dest='/u01/oracle/app/admin/CDB/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/u10/EXAM/ORADATA/CDB/control01.ctl','/u10/EXAM/fast_recovery_area/CDB/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='CDB'
*.db_recovery_file_dest='/u10/EXAM/fast_recovery_area'
*.db_recovery_file_dest_size=10737418240
*.diagnostic_dest='/u01/oracle/app'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=CDBXDB)'
*.enable_pluggable_database=true
*.memory_target=2729m
*.open_cursors=300
*.processes=500
*.remote_login_passwordfile='EXCLUSIVE'
*.undo_tablespace='UNDOTBS1'

--Export Home and Path

$ export ORACLE_HOME=/u01/oracle/app/product/12.1.0.2/dbhome_1
$ export PATH=$ORACLE_HOME/bin:$PATH
$ export ORACLE_SID=CDB
$ echo $ORACLE_HOME
/u01/oracle/app/product/12.1.0.2/dbhome_1
$ ls
initCDB.ora  init.ora

-- Start the database in nomout state

$ sqlplus / as sysdba
SQL> startup nomount pfile='initCDB.ora';
ORACLE instance started.

-- Move the backup prices and archivelogs from source to target
-- Restore control file

$ pwd
/u10/12c_backup/CDB/autobackup/2016_10_07
[oracle@uatdb2 2016_10_07]$

[oracle@uatdb2 2016_10_07]$ rman target /

RMAN> restore controlfile from '/u10/12c_backup/CDB/autobackup/2016_10_07/o1_mf_s_924616422_czgpwj40_.bkp';

Starting restore at 07-OCT-16
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: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
output file name=/u10/EXAM/ORADATA/CDB/control01.ctl
output file name=/u10/EXAM/fast_recovery_area/CDB/control02.ctl
Finished restore at 07-OCT-16

RMAN>

-- Mount the target system

RMAN> alter database mount;

Statement processed
released channel: ORA_DISK_1

RMAN>


-- Start Restore and Recover:

]$ pwd
/u10/12c_backup/
$ chmod –R 775 CDB
$cd CDB
$pwd
RMAN> catalog start with '/u10/12c_backup/CDB';

Starting implicit crosscheck backup at 07-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=12 device type=DISK
Crosschecked 14 objects
Finished implicit crosscheck backup at 07-OCT-16

Starting implicit crosscheck copy at 07-OCT-16
using channel ORA_DISK_1
Finished implicit crosscheck copy at 07-OCT-16

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

searching for all files that match the pattern /u10/12c_backup/CDB

List of Files Unknown to the Database
=====================================
File Name: /u10/12c_backup/CDB/autobackup/2016_10_07/o1_mf_s_924616422_czgpwj40_.bkp
File Name: /u10/12c_backup/CDB/3E09A4600B4CDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpt4nq_.bkp
File Name: /u10/12c_backup/CDB/3E08803B3049DDBBE053110112AC46EF/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgptmyp_.bkp
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_39_czgpwd65_.arc
File Name: /u10/12c_backup/CDB/3E09A4600B4EDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvfc2_.bkp
File Name: /u10/12c_backup/CDB/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpscc9_.bkp
File Name: /u10/12c_backup/CDB/backupset/2016_10_07/o1_mf_annnn_TAG20161007T135340_czgpwdtw_.bkp
File Name: /u10/12c_backup/CDB/3E07F6ABA9E6D2BCE053110112ACF374/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvwmd_.bkp

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

List of Cataloged Files
=======================
File Name: /u10/12c_backup/CDB/autobackup/2016_10_07/o1_mf_s_924616422_czgpwj40_.bkp
File Name: /u10/12c_backup/CDB/3E09A4600B4CDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpt4nq_.bkp
File Name: /u10/12c_backup/CDB/3E08803B3049DDBBE053110112AC46EF/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgptmyp_.bkp
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_39_czgpwd65_.arc
File Name: /u10/12c_backup/CDB/3E09A4600B4EDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvfc2_.bkp
File Name: /u10/12c_backup/CDB/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpscc9_.bkp
File Name: /u10/12c_backup/CDB/backupset/2016_10_07/o1_mf_annnn_TAG20161007T135340_czgpwdtw_.bkp
File Name: /u10/12c_backup/CDB/3E07F6ABA9E6D2BCE053110112ACF374/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvwmd_.bkp

RMAN>

-- Now start restore the Database

RMAN> restore database;

Starting restore at 07-OCT-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=12 device type=DISK

skipping datafile 1; already restored to file /u10/EXAM/ORADATA/CDB/system01.dbf
skipping datafile 3; already restored to file /u10/EXAM/ORADATA/CDB/sysaux01.dbf
skipping datafile 4; already restored to file /u10/EXAM/ORADATA/CDB/undotbs01.dbf
skipping datafile 6; already restored to file /u10/EXAM/ORADATA/CDB/users01.dbf
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 datafile 00011 to /u10/EXAM/ORADATA/CDB/salespdb/system01.dbf
channel ORA_DISK_1: restoring datafile 00012 to /u10/EXAM/ORADATA/CDB/salespdb/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00013 to /u10/EXAM/ORADATA/CDB/salespdb/sales01.dbf
channel ORA_DISK_1: reading from backup piece /u10/12c_backup/CDB/3E09A4600B4CDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpt4nq_.bkp
channel ORA_DISK_1: piece handle=/u10/12c_backup/CDB/3E09A4600B4CDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpt4nq_.bkp tag=TAG20161007T135202
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
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 datafile 00008 to /u10/EXAM/ORADATA/CDB/pdb1/system01.dbf
channel ORA_DISK_1: restoring datafile 00009 to /u10/EXAM/ORADATA/CDB/pdb1/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00010 to /u10/EXAM/ORADATA/CDB/pdb1/pdb1_users01.dbf
channel ORA_DISK_1: reading from backup piece /u10/12c_backup/CDB/3E08803B3049DDBBE053110112AC46EF/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgptmyp_.bkp
channel ORA_DISK_1: piece handle=/u10/12c_backup/CDB/3E08803B3049DDBBE053110112AC46EF/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgptmyp_.bkp tag=TAG20161007T135202
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
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 datafile 00014 to /u10/EXAM/ORADATA/CDB/pdb2/system01.dbf
channel ORA_DISK_1: restoring datafile 00015 to /u10/EXAM/ORADATA/CDB/pdb2/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00016 to /u10/EXAM/ORADATA/CDB/pdb2/pdb1_users01.dbf
channel ORA_DISK_1: reading from backup piece /u10/12c_backup/CDB/3E09A4600B4EDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvfc2_.bkp
channel ORA_DISK_1: piece handle=/u10/12c_backup/CDB/3E09A4600B4EDB6BE053110112ACCC54/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvfc2_.bkp tag=TAG20161007T135202
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
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 datafile 00005 to /u10/EXAM/ORADATA/CDB/pdbseed/system01.dbf
channel ORA_DISK_1: restoring datafile 00007 to /u10/EXAM/ORADATA/CDB/pdbseed/sysaux01.dbf
channel ORA_DISK_1: reading from backup piece /u10/12c_backup/CDB/3E07F6ABA9E6D2BCE053110112ACF374/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvwmd_.bkp
channel ORA_DISK_1: piece handle=/u10/12c_backup/CDB/3E07F6ABA9E6D2BCE053110112ACF374/backupset/2016_10_07/o1_mf_nnndf_TAG20161007T135202_czgpvwmd_.bkp tag=TAG20161007T135202
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:15
Finished restore at 07-OCT-16

RMAN>

-- Now recover the database

RMAN> recover database;

Starting recover at 07-OCT-16
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 39 is already on disk as file /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_39_czgpwd65_.arc
archived log file name=/u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_39_czgpwd65_.arc thread=1 sequence=39
unable to find archived log
archived log thread=1 sequence=40
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/07/2016 14:37:21
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 40 and starting SCN of 2009009

-- Do more recovery

RMAN> catalog start with '/u10/12c_backup/CDB/archivelog/2016_10_07';

searching for all files that match the pattern /u10/12c_backup/CDB/archivelog/2016_10_07

List of Files Unknown to the Database
=====================================
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_43_czgs511n_.arc
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_41_czgs4xcm_.arc
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_42_czgs501k_.arc
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_40_czgs4wbm_.arc

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

List of Cataloged Files
=======================
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_43_czgs511n_.arc
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_41_czgs4xcm_.arc
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_42_czgs501k_.arc
File Name: /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_40_czgs4wbm_.arc

RMAN> recover database;

Starting recover at 07-OCT-16
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 40 is already on disk as file /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_40_czgs4wbm_.arc
archived log for thread 1 with sequence 41 is already on disk as file /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_41_czgs4xcm_.arc
archived log for thread 1 with sequence 42 is already on disk as file /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_42_czgs501k_.arc
archived log for thread 1 with sequence 43 is already on disk as file /u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_43_czgs511n_.arc
archived log file name=/u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_40_czgs4wbm_.arc thread=1 sequence=40
archived log file name=/u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_41_czgs4xcm_.arc thread=1 sequence=41
archived log file name=/u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_42_czgs501k_.arc thread=1 sequence=42
archived log file name=/u10/12c_backup/CDB/archivelog/2016_10_07/o1_mf_1_43_czgs511n_.arc thread=1 sequence=43
unable to find archived log
archived log thread=1 sequence=44
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 10/07/2016 14:40:36
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence 44 and starting SCN of 2010643

RMAN>

-- Verify the status in the Target Host

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       MOUNTED
         3 PDB1                           MOUNTED
         4 SALESPDB                       MOUNTED
         5 PDB2                           MOUNTED
SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
CDB       MOUNTED

SQL>

-- Now open the container database with RESETLOG.

SQL> alter database open resetlogs;

Database altered.

SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           MOUNTED
         4 SALESPDB                       MOUNTED
         5 PDB2                           MOUNTED

-- Now you can open your pdbs also.

SQL> alter pluggable database PDB1 open;

Pluggable database altered.

SQL> show pdbs; 

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 SALESPDB                       MOUNTED
         5 PDB2                           MOUNTED
SQL> alter pluggable database PDB2 open;

Pluggable database altered.

SQL> alter pluggable database SALESPDB open;

Pluggable database altered.


SQL> show pdbs;

    CON_ID CON_NAME                       OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
         2 PDB$SEED                       READ ONLY  NO
         3 PDB1                           READ WRITE NO
         4 SALESPDB                       READ WRITE NO
         5 PDB2                           READ WRITE NO
SQL>


2) Create new PDBs

Create Pluggable database via scripts with different options:

$export ORACLE_SID=CDB
SQL> select name,open_mode from v$database;
NAME      OPEN_MODE
--------- --------------------
CDB       READ WRITE

SQL> CREATE PLUGGABLE DATABASE salespdb ADMIN USER salesadmin IDENTIFIED BY salesadmin
  DEFAULT TABLESPACE sales 
    DATAFILE '/u10/EXAM/ORADATA/CDB/salespdb/sales01.dbf' SIZE 250M AUTOEXTEND ON
  PATH_PREFIX = '/u10/EXAM/ORADATA/CDB/salespdb/'
  FILE_NAME_CONVERT = ('/u10/EXAM/ORADATA/CDB/pdbseed/', '/u10/EXAM/ORADATA/CDB/salespdb/');

Pluggable database created.

SQL> select DBID,NAME,OPEN_MODE from v$pdbs;

      DBID NAME                           OPEN_MODE
---------- ------------------------------ ----------
1401480341 PDB$SEED                       READ ONLY
 202699746 PDB1                           READ WRITE
  24383494 SALESPDB                       MOUNTED

SQL>

--- Now open the sales pdb:

SQL> ALTER PLUGGABLE DATABASE salespdb OPEN;

Pluggable database altered.

SQL> select DBID,NAME,OPEN_MODE from v$pdbs;

      DBID NAME                           OPEN_MODE
---------- ------------------------------ ----------
1401480341 PDB$SEED                       READ ONLY
 202699746 PDB1                           READ WRITE
  24383494 SALESPDB                       READ WRITE

SQL>

-- Clone pdb2 from exting pdb1:

CREATE PLUGGABLE DATABASE pdb2 FROM pdb1
FILE_NAME_CONVERT=(‘/u10/EXAM/ORADATA/CDB/pdb1/’,’/u10/EXAM/ORADATA/CDB/pdb2/’);

Example:
SQL> CREATE PLUGGABLE DATABASE pdb2 FROM pdb1
FILE_NAME_CONVERT=('/u10/EXAM/ORADATA/CDB/pdb1/','/u10/EXAM/ORADATA/CDB/pdb2/');

Pluggable database created.

SQL>
SQL> select DBID,NAME,OPEN_MODE from v$pdbs;

      DBID NAME                           OPEN_MODE
---------- ------------------------------ ----------
1401480341 PDB$SEED                       READ ONLY
 202699746 PDB1                           READ WRITE
  24383494 SALESPDB                       READ WRITE
2563786999 PDB2                           MOUNTED

SQL> alter pluggable database pdb2 open;
Pluggable database altered.

SQL> select DBID,NAME,OPEN_MODE from v$pdbs;

      DBID NAME                           OPEN_MODE
---------- ------------------------------ ----------
1401480341 PDB$SEED                       READ ONLY
 202699746 PDB1                           READ WRITE
  24383494 SALESPDB                       READ WRITE
2563786999 PDB2                           READ WRITE

SQL>

3) Change all PDB passwords for container in one go:

How to change Pluggable DB's SYS password?

-- To set a common password for SYS and SYSTEM users across all PDBs

SQL> alter user SYS identified by oracle container=all;
User altered.

SQL> select name,open_mode from v$database;

NAME      OPEN_MODE
--------- --------------------
CDB       READ WRITE
SQL>

-- Switch to different container

SQL> alter session set container = PDB1;
Session altered.

SQL> show con_name  
CON_NAME
------------------------------
PDB1

SQL> alter session set container = PDB2;
Session altered.

SQL> show con_name

CON_NAME
------------------------------
PDB2
SQL>

4) 12c Networking, Connecting PDBs via oracle client

Connecting to individual PDB via Oracle Client:
-- Configure / Create listener in server

LISTENER1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = eh-uatdb1)(PORT = 1521))
  )

SID_LIST_LISTENER1 =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = CDB)
      (ORACLE_HOME = /u01/oracle/app/product/12.1.0.2/dbhome_1)
      (SID_NAME = CDB)
    )
    (SID_DESC =
      (SID_NAME = pdb1)
      (ORACLE_HOME = /u01/oracle/app/product/12.1.0.2/dbhome_1)
    )
   (SID_DESC =
      (SID_NAME = pdb2)
      (ORACLE_HOME = /u01/oracle/app/product/12.1.0.2/dbhome_1)
    )
   (SID_DESC =
      (SID_NAME = salespdb)
      (ORACLE_HOME = /u01/oracle/app/product/12.1.0.2/dbhome_1)
    )
   (SID_DESC =
      (SID_NAME = hrpdb)
      (ORACLE_HOME = /u01/oracle/app/product/12.1.0.2/dbhome_1)
    )
  )

ADR_BASE_LISTENER1 = /u01/oracle/app

[oracle@eh-uatdb1 admin]$


-- Configure tnsnames.ora in client:
CDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.17)(PORT = 1522))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = CDB)
    )
  )

HRPDB =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.17)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = HRPDB)
    )
  )

pdb1 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.17)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb1)
    )
  )

pdb2 =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.17)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = pdb2)
    )
  )

salespdb =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 172.18.1.17)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = salespdb)
    )
  )


-- Sample connection:

C:\> sqlplus sys/oracle@pdb1 as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Fri Oct 7 17:27:57 2016
Copyright (c) 1982, 2010, Oracle.  All rights reserved.
Connected to:
Oracle Database 12c Enterprise Edition Release 12.1.0.2.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options


SQL>

2 comments:

  1. Nice article, this post is very helpful. Thanks...

    If you want to recover lost photos from the Sony digital camera then download the Sony Photo Recovery Software.

    ReplyDelete
  2. Hi Gouranga,

    Good day.

    Thanks for sharing this blog, it really make Oracle DB movement very simpler.

    Need your help in copying the CBD & PDB to new host, we are using Oracle version 19c.

    We have requirement of copying the CDB and PDB from Azure to GCP vm, using rman i have taken the bkp of CBD and PDB and copied the same to GCP VM.
    I was referring to the blog : http://facedba.blogspot.com/2016/10/restore-and-recovery-of-complete-cdb-in.html

    Was not sure on below steps.

    -- Create pfile :
    I am not able get the below values.

    *.audit_trail='db'
    *.compatible='12.1.0.2.0'
    *.control_files='/u10/EXAM/ORADATA/CDB/control01.ctl','/u10/EXAM/fast_recovery_area/CDB/control02.ctl'
    *.dispatchers='(PROTOCOL=TCP) (SERVICE=CDBXDB)'
    *.undo_tablespace='UNDOTBS1'

    --Export Home and Path

    $ echo $ORACLE_HOME
    /u01/oracle/app/product/12.1.0.2/dbhome_1
    $ ls
    initCDB.ora init.ora

    Do we need to create empty initCDB.ora & init.ora file and below sql cmd.

    -- Start the database in nomout state

    $ sqlplus / as sysdba
    SQL> startup nomount pfile='initCDB.ora';
    ORACLE instance started.a

    Could you please help me on providing some additional information for restoring CDB & PDB to new server.

    Thanks
    Sanjeev

    ReplyDelete

Translate >>