Posted in Forgotten themes

Duplicating a CDB with PDB to different host

  1. on the source create a static listener and create tnsnames entries
[oracle@test admin]$ cat listener.ora
# listener.ora Network Configuration
File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER_RCLOUD =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.254)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER_RCLOUD =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = rCLOUD)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
      (SID_NAME = rCLOUD)
    )
  )

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = IPC)(KEY = LISTENER))
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.254)(PORT = 51521))
    )
  )

[oracle@test admin]$
[oracle@test admin]$ cat tnsnames.ora
# tnsnames.ora Network Configuration
File: /u01/app/oracle/product/12.1.0/dbhome_1/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

RCAT =
  (DESCRIPTION =
    (ADDRESS_LIST =
      (ADDRESS = (PROTOCOL = TCP)(HOST = test.example.com)(PORT = 1521))
    )
    (CONNECT_DATA =
      (SERVICE_NAME = rCAT)
    )
  )
rCLOUD=(DESCRIPTION=(CONNECT_DATA=(SID=rcloud))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.254)(PORT=1521)))
rCLOUD_dup=(DESCRIPTION=(CONNECT_DATA=(SID=rcloud))(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.253)(PORT=1521)))

LISTENER=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.254)(PORT=51521)))
LISTENER_RCLOUD=(DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.56.254)(PORT=1521)))

2. I register my local listeners (it’s new for me, we had always static listeners in the old work, but now I am more cool.

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> show parameter listener

NAME				     TYPE	 VALUE
------------------------------------ -----------
------------------------------
listener_networks		     string
local_listener			     string	 LISTENER, LISTENER_RCLOUD
remote_listener 		     string
SQL> 
  1. on the target host install a new oracle home…
  2. create an oratab entry
[oracle@test-r1 dbs]$ cat /etc/oratab
rCLOUD:/u01/app/oracle/product/12.1.0/dbhome_1:N

5. create a password file

cd $ORACLE_HOME/dbs
orapwd file=orapwrCLOUD

6. create an initrCLOUD.ora – I stringsed the spfile on the source database and copied the text simply, changed the control_files parameter and created audit_file_dest

[oracle@test-r1 dbs]$ mkdir -p /u01/app/oracle/admin/rCLOUD/adump
[oracle@test-r1 dbs]$ cat initrCLOUD.ora
*.audit_file_dest='/u01/app/oracle/admin/rCLOUD/adump'
*.audit_trail='db'
*.compatible='12.1.0.2.0'
*.control_files='/u01/app/oracle/oradata/RCLOUD/controlfile/control1.ctl'
*.db_block_size=8192
*.db_create_file_dest='/u01/app/oracle/oradata'
*.db_domain=''
*.db_name='rCLOUD'
*.db_recovery_file_dest='/u01/app/oracle/fast_recovery_area'
*.db_recovery_file_dest_size=4815m
*.db_securefile='PREFERRED'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=rCLOUDXDB)'
*.enable_pluggable_database=true
*.open_cursors=300
*.pga_aggregate_target=100m
*.processes=300
*.remote_login_passwordfile='EXCLUSIVE'
*.sga_target=400m
*.undo_tablespace='UNDOTBS1'

7. static listener for the rCLOUD duplicate and of course the tnsnames entries, I will not write it again.

LISTENER_RCLOUD =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = 192.168.56.253)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER_RCLOUD =
  (SID_LIST =
    (SID_DESC =
      (GLOBAL_DBNAME = rCLOUD)
      (ORACLE_HOME = /u01/app/oracle/product/12.1.0/dbhome_1)
      (SID_NAME = rCLOUD)
    )
  )
  1. Start the duplicate
[oracle@test-r1 dbs]$ rman target sys/oracle@rcloud auxiliary sys/oracle@rcloud_dup

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Jul 6 10:13:00
2016

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

connected to target database: RCLOUD (DBID=3718501809)
connected to auxiliary database: RCLOUD (not started)

RMAN> startup clone nomount

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area     419430400 bytes

Fixed Size                     2925120 bytes
Variable Size                264244672 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5459968 bytes

RMAN> duplicate target database to rCLOUD from active database using
compressed backupset ;

Starting Duplicate Db at 06-JUL-16
using target database control file instead of recovery catalog allocated channel:
ORA_AUX_DISK_1 channel
ORA_AUX_DISK_1: SID=22 device type=DISK current log archived

contents of Memory Script:
{
   sql clone "alter system set  db_name =  ''RCLOUD'' comment=  ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =  ''RCLOUD'' comment=  ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone from service  'rcloud' using compressed backupset
   primary controlfile;
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RCLOUD'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''RCLOUD'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     419430400 bytes

Fixed Size                     2925120 bytes
Variable Size                264244672 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5459968 bytes

Starting restore at 06-JUL-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=22 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: restoring control file
dbms_backup_restore.restoreCancel() failed Oracle instance started

Total System Global Area     419430400 bytes

Fixed Size                     2925120 bytes
Variable Size                264244672 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5459968 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =  ''RCLOUD'' comment=  ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile";
   shutdown clone immediate;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RCLOUD'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile

Oracle instance shut down
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of Duplicate Db command at 07/06/2016 10:14:11
RMAN-05501: aborting duplication of target database
RMAN-03015: error occurred in stored script Memory Script
ORA-19660: some files in the backup set could not be verified
ORA-19661: datafile 0 could not be verified
ORA-19849: error while reading backup piece from service rcloud
ORA-19504: failed to create file
"/u01/app/oracle/oradata/RCLOUD/controlfile/control1.ctl"
ORA-27040: file create error, unable to create file
Linux-x86_64 Error: 2: No such file or directory Additional information: 1

RMAN> 

Recovery Manager complete.

9. Fix the problems simply with creating all directories that you have defined in the initrCLOUD.ora

[oracle@test-r1 dbs]$ mkdir -p /u01/app/oracle/oradata/RCLOUD/controlfile/
[oracle@test-r1 dbs]$ rman target sys/oracle@rcloud auxiliary sys/oracle@rcloud_dup

Recovery Manager: Release 12.1.0.2.0 - Production on Wed Jul 6 10:14:41
2016

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

connected to target database: RCLOUD (DBID=3718501809) connected to auxiliary database (not started)

RMAN> startup clone nomount ;

Oracle instance started

Total System Global Area     419430400 bytes

Fixed Size                     2925120 bytes
Variable Size                264244672 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5459968 bytes

RMAN> duplicate target database to rCLOUD from active database using
compressed backupset ;

Starting Duplicate Db at 06-JUL-16
using target database control file instead of recovery catalog allocated channel: ORA_AUX_DISK_1 channel
ORA_AUX_DISK_1: SID=22 device type=DISK current log archived

contents of Memory Script:
{
   sql clone "alter system set  db_name =  ''RCLOUD'' comment=  ''Modified by RMAN duplicate'' scope=spfile";
   sql clone "alter system set  db_unique_name =  ''RCLOUD'' comment=  ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone from service  'rcloud' using compressed backupset
   primary controlfile;
   alter clone database mount;
}
executing Memory Script

sql statement: alter system set  db_name =  ''RCLOUD'' comment= ''Modified by RMAN duplicate'' scope=spfile

sql statement: alter system set  db_unique_name =  ''RCLOUD'' comment= ''Modified by RMAN duplicate'' scope=spfile

Oracle instance shut down

Oracle instance started

Total System Global Area     419430400 bytes

Fixed Size                     2925120 bytes
Variable Size                264244672 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5459968 bytes

Starting restore at 06-JUL-16
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=22 device type=DISK

channel ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network
 backup set from service rcloud channel
ORA_AUX_DISK_1: restoring control file channel
ORA_AUX_DISK_1: restore
complete, elapsed time: 00:00:01 output file name=/u01/app/oracle/oradata/RCLOUD/controlfile/control1.ctl
Finished restore at 06-JUL-16

database mounted

contents of Memory Script:
{
   set newname for clone datafile  1 to new;
   set newname for clone datafile  2 to new;
   set newname for clone datafile  3 to new;
   set newname for clone datafile  4 to new;
   set newname for clone datafile  5 to new;
   set newname for clone datafile  6 to new;
   set newname for clone datafile  17 to new;
   set newname for clone datafile  18 to new;
   set newname for clone datafile  19 to new;
   restore
   from service  'rcloud'   using compressed backupset
   clone database
   ;
   sql 'alter system archive log current'; } executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 06-JUL-16
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud 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/RCLOUD/datafile/o1_mf_system_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00002 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00005 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_undotbs1_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00017 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:07 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00018 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:25 channel
ORA_AUX_DISK_1: starting datafile backup set restore channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set channel
ORA_AUX_DISK_1: restoring datafile 00019 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_%u_.dbf
channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 06-JUL-16

sql statement: alter system archive log current current log archived

contents of Memory Script:
{
   restore clone force from service  'rcloud' using compressed backupset
   archivelog from scn  1115044;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 06-JUL-16
using channel ORA_AUX_DISK_1

channel ORA_AUX_DISK_1: starting archived log restore to default destination channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: restoring archived log archived log thread=1 sequence=58 channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 channel
ORA_AUX_DISK_1: starting archived log restore to default destination channel
ORA_AUX_DISK_1: using compressed network backup set from service rcloud channel
ORA_AUX_DISK_1: restoring archived log archived log thread=1 sequence=59 channel
ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01 Finished restore at 06-JUL-16

datafile 1 switched to datafile copy
input datafile copy RECID=10 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_cqshk7ct_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=11 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_cqshkplg_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=12 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshky20_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=13 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshldy5_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=14 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_undotbs1_cqshlvxh_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=15 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshlyqc_.dbf
datafile 17 switched to datafile copy
input datafile copy RECID=16 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_cqshm08g_.dbf
datafile 18 switched to datafile copy
input datafile copy RECID=17 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshm7ts_.dbf
datafile 19 switched to datafile copy
input datafile copy RECID=18 STAMP=916481827 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshmzy1_.dbf

contents of Memory Script:
{
   set until scn  1115151;
   recover
   clone database
    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 06-JUL-16
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 58
is already on disk as file /u01/app/oracle/fast_recovery_area/RCLOUD/archivelog/2016_07_06/o1_mf_1_58_cqshn1dn_.arc
archived log for thread 1 with sequence 59
 is already on disk as file /u01/app/oracle/fast_recovery_area/RCLOUD/archivelog/2016_07_06/o1_mf_1_59_cqshn2g2_.arc
archived log file
name=/u01/app/oracle/fast_recovery_area/RCLOUD/archivelog/2016_07_06/o1_mf_1_58_cqshn1dn_.arc
thread=1 sequence=58 archived log file name=/u01/app/oracle/fast_recovery_area/RCLOUD/archivelog/2016_07_06/o1_mf_1_59_cqshn2g2_.arc
thread=1 sequence=59
media recovery complete, elapsed time: 00:00:00
Finished recover at 06-JUL-16
Oracle instance started

Total System Global Area     419430400 bytes

Fixed Size                     2925120 bytes
Variable Size                264244672 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5459968 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =  ''RCLOUD'' comment=  ''Reset to original value by RMAN'' scope=spfile";
   sql clone "alter system reset  db_unique_name scope=spfile"; } executing Memory Script

sql statement: alter system set  db_name =  ''RCLOUD'' comment= ''Reset to original value by RMAN'' scope=spfile

sql statement: alter system reset  db_unique_name scope=spfile Oracle instance started

Total System Global Area     419430400 bytes

Fixed Size                     2925120 bytes
Variable Size                264244672 bytes
Database Buffers             146800640 bytes
Redo Buffers                   5459968 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "RCLOUD" RESETLOGS ARCHIVELOG
  MAXLOGFILES     16
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES     8
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1  SIZE 50 M ,
  GROUP   2  SIZE 50 M ,
  GROUP   3  SIZE 50 M
 DATAFILE
  '/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_cqshk7ct_.dbf',
  '/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_cqshkplg_.dbf',
  '/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_system_cqshm08g_.dbf'
 CHARACTER SET AL32UTF8

contents of Memory Script:
{
   set newname for clone tempfile  1 to new;
   set newname for clone tempfile  2 to new;
   set newname for clone tempfile  3 to new;
   switch clone tempfile all;
   catalog clone datafilecopy
"/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshky20_.dbf",
 "/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshldy5_.dbf", 

"/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_undotbs1_cqshlvxh_.dbf",
 "/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshlyqc_.dbf",
 "/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshm7ts_.dbf",
 "/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshmzy1_.dbf";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 2 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_temp_%u_.tmp in control file
 renamed tempfile 3 to /u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_temp_%u_.tmp in control file

cataloged datafile copy
datafile copy file
name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshky20_.dbf
RECID=1 STAMP=916481845
cataloged datafile copy
datafile copy file
name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshldy5_.dbf
RECID=2 STAMP=916481845
cataloged datafile copy
datafile copy file
name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_undotbs1_cqshlvxh_.dbf RECID=3
STAMP=916481845 cataloged datafile copy datafile copy file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshlyqc_.dbf
RECID=4 STAMP=916481845
cataloged datafile copy
datafile copy file
name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshm7ts_.dbf
RECID=5 STAMP=916481845
cataloged datafile copy
datafile copy file
name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshmzy1_.dbf
RECID=6 STAMP=916481845

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=916481845 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshky20_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=916481845 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshldy5_.dbf
datafile 5 switched to datafile copy
input datafile copy RECID=3 STAMP=916481845 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_undotbs1_cqshlvxh_.dbf
datafile 6 switched to datafile copy
input datafile copy RECID=4 STAMP=916481845 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshlyqc_.dbf
datafile 18 switched to datafile copy
input datafile copy RECID=5 STAMP=916481845 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_sysaux_cqshm7ts_.dbf
datafile 19 switched to datafile copy
input datafile copy RECID=6 STAMP=916481845 file name=/u01/app/oracle/oradata/RCLOUD/datafile/o1_mf_users_cqshmzy1_.dbf

contents of Memory Script:
{
   Alter clone database open resetlogs;
}
executing Memory Script

database opened

contents of Memory Script:
{
   sql clone "alter pluggable database all open"; }
executing Memory Script

sql statement: alter pluggable database all open
Finished Duplicate Db at 06-JUL-16

3be10b9

Advertisements
Posted in Forgotten themes

Restoring a PDB causes problems

I am reading the documentation again and I don’t understand why I cannot restore a tablespace in a PDB

[oracle@hackbook ~]$ rman target sys@"(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=rcat))(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.2.15)(PORT=1521)))"

Recovery Manager: Release 12.1.0.2.0 - Production on Tue Jul 5 14:56:13 2016

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

target database Password: 
connected to target database: CCLOUD1 (DBID=1191441626, not open)

RMAN> report schema ;

using target database control file instead of recovery catalog
Report of database schema for database with db_unique_name CLOUDDB1

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
7    260      SYSTEM               NO      /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_system_cqfldc9b_.dbf
8    605      SYSAUX               NO      /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_sysaux_cqfldcrv_.dbf
9    5        USERS                NO      /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_users_cqfljdqg_.dbf
10   10       CORRUPTION           NO      /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corrupti_cqnms1yb_.dbf

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
3    20       TEMP                 32767       /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_temp_cqfldctf_.dbf

RMAN> restore tablespace CORRUPTION ;

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "corruption": expecting one of: "root, double-quoted-string, identifier, single-quoted-string"
RMAN-01007: at line 1 column 20 file: standard input

RMAN> restore datafile 10 ;

Starting restore at 05-JUL-16
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=22 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 datafile 00010 to /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corrupti_cqnms1yb_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oradata/fra/CLOUDDB1/36994AC799462E62E0530F02000AFF86/backupset/2016_07_04/o1_mf_nnndf_TAG20160704T140801_cqnnh3n8_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oradata/fra/CLOUDDB1/36994AC799462E62E0530F02000AFF86/backupset/2016_07_04/o1_mf_nnndf_TAG20160704T140801_cqnnh3n8_.bkp tag=TAG20160704T140801
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 05-JUL-16

RMAN> recover datafile 10 ;

Starting recover at 05-JUL-16
using channel ORA_DISK_1

starting media recovery

archived log for thread 1 with sequence 171 is already on disk as file /u01/app/oradata/fra/CLOUDDB1/archivelog/2016_07_05/o1_mf_1_171_cqpyfdmo_.arc
archived log for thread 1 with sequence 172 is already on disk as file /u01/app/oradata/fra/CLOUDDB1/archivelog/2016_07_05/o1_mf_1_172_cqpyfdcm_.arc
archived log for thread 1 with sequence 173 is already on disk as file /u01/app/oradata/fra/CLOUDDB1/archivelog/2016_07_05/o1_mf_1_173_cqpyfdk7_.arc
archived log for thread 1 with sequence 1 is already on disk as file /u01/app/oradata/fra/CLOUDDB1/archivelog/2016_07_05/o1_mf_1_1_cqq9x4j3_.arc
archived log file name=/u01/app/oradata/fra/CLOUDDB1/archivelog/2016_07_05/o1_mf_1_171_cqpyfdmo_.arc thread=1 sequence=171
archived log file name=/u01/app/oradata/fra/CLOUDDB1/archivelog/2016_07_05/o1_mf_1_172_cqpyfdcm_.arc thread=1 sequence=172
archived log file name=/u01/app/oradata/fra/CLOUDDB1/archivelog/2016_07_05/o1_mf_1_173_cqpyfdk7_.arc thread=1 sequence=173
media recovery complete, elapsed time: 00:00:01
Finished recover at 05-JUL-16

RMAN> 
Posted in Forgotten themes

Corrupting a PDB datafile – strange world

Corruption is bad, noone would like to restore blocks especially if you don’t check your backups correctly (backup check logical database). What would happen if you do not have valid backups and the blocks cannot be recovered. I would be sad and skipping corrupt blocks which have data is not a real solution, I think.

SQL> startup
ORACLE instance started.

Total System Global Area  524288000 bytes
Fixed Size		    2926320 bytes
Variable Size		  381683984 bytes
Database Buffers	  134217728 bytes
Redo Buffers		    5459968 bytes
show pDatabase mounted.
dbs
Database opened.
SQL> 
    CON_ID CON_NAME			  OPEN MODE  RESTRICTED
---------- ------------------------------ ---------- ----------
	 2 PDB$SEED			  READ ONLY  NO
	 3 RCAT 			  MOUNTED
SQL> alter pluggable database all open ;


Pluggable database altered.

SQL> alter session set container = rcat ;

Session altered.

SQL> create tablespace corruption datafile size 10m ;

Tablespace created.

SQL> create user jano identified by jano quota unlimited on corruption default tablespace corruption ;

User created.

SQL> grant connect, resource to jano ;

Grant succeeded.

[oracle@hackbook admin]$ sqlplus jano/jano@"(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=rcat))(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.2.15)(PORT=1521)))"

SQL*Plus: Release 12.1.0.2.0 Production on Mon Jul 4 14:05:04 2016

Copyright (c) 1982, 2014, 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> create table test as select level id from dual connect by level <=500 ;

Table created.

SQL> create index testidx on test(id) ;

Index created.

[oracle@hackbook admin]$ rman target=/

Recovery Manager: Release 12.1.0.2.0 - Production on Mon Jul 4 14:06:56 2016

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

connected to target database: CCLOUD1 (DBID=1191441626)

RMAN> CONFIGURE BACKUP OPTIMIZATION ON ;

new RMAN configuration parameters:
CONFIGURE BACKUP OPTIMIZATION ON;
new RMAN configuration parameters are successfully stored

RMAN> backup as compressed backupset database ;  
...
piece handle=/u01/app/oradata/fra/CLOUDDB1/3693C164563139E1E0530F02000A55ED/backupset/2016_07_04/o1_mf_nn
ndf_TAG20160704T140801_cqnnjjxq_.bkp tag=TAG20160704T140801 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:46
Finished backup at 04-JUL-16

Starting Control File and SPFILE Autobackup at 04-JUL-16
piece handle=/u01/app/oradata/fra/CLOUDDB1/autobackup/2016_07_04/o1_mf_s_916323039_cqnnl05p_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 04-JUL-16

RMAN> 

[oracle@hackbook ~]$ sqlplus / as sysdba @corrupt.sql

SQL*Plus: Release 12.1.0.2.0 Production on Mon Jul 4 14:31:36 2016

Copyright (c) 1982, 2014, 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


dd of=/u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corrupti_cqnms1yb_.dbf bs=8192 conv=notrunc seek=131 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt  EOF

[oracle@hackbook ~]$ dd of=/u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corrupti_cqnms1yb_.dbf bs=8192 conv=notrunc seek=131 << EOF
> CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt  EOF
> EOF
0+1 records in
0+1 records out
117 bytes (117 B) copied, 0.0115306 s, 10.1 kB/s
[oracle@hackbook ~]$ 
[oracle@hackbook ~]$ 
[oracle@hackbook ~]$ 
[oracle@hackbook ~]$ sqlplus jano/jano@"(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=rcat))(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.2.15)(PORT=1521)))"

SQL*Plus: Release 12.1.0.2.0 Production on Mon Jul 4 14:32:04 2016

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

Last Successful login time: Mon Jul 04 2016 14:22:35 +02:00

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> select * from test ;
select * from test
       *
ERROR at line 1:
ORA-01578: ORACLE data block corrupted (file # 10, block # 131)
ORA-01110: data file 10:
'/u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corru
pti_cqnms1yb_.dbf'

[oracle@hackbook ~]$ rman target=/

Recovery Manager: Release 12.1.0.2.0 - Production on Mon Jul 4 14:32:26 2016

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

connected to target database: CCLOUD1 (DBID=1191441626)

RMAN> validate database ;
....
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
10   FAILED 0              55           1281            2009247   
  File Name: /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corrupti_cqnms1yb_.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              0               
  Index      0              3               
  Other      1              1222            

[oracle@hackbook ~]$ sqlplus / as sysdba @corrupt.sql

SQL*Plus: Release 12.1.0.2.0 Production on Mon Jul 4 14:34:26 2016

Copyright (c) 1982, 2014, 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


dd of=/u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corrupti_cqnms1yb_.dbf bs=8192 conv=notrunc seek=131 << EOF
CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT corrupt CORRUPT CORRUPT CORRUPT CORRUPT corrupt corrupt  EOF


SQL> select * from v$database_block_corruption ;

	10	  131	       1		  0 CORRUPT	       0

SQL> alter database datafile 10 offline ;
alter database datafile 10 offline
*
ERROR at line 1:
ORA-01516: nonexistent log file, data file, or temporary file "10"

What is this??????????????????????

SQL> alter session set container=rcat ;

Session altered.

SQL> alter database datafile 10 offline ;

Database altered.

[oracle@hackbook ~]$ rman target=/

Recovery Manager: Release 12.1.0.2.0 - Production on Mon Jul 4 14:35:45 2016

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

connected to target database: CCLOUD1 (DBID=1191441626)

RMAN> restore datafile 10 ;

Starting restore at 04-JUL-16
using channel ORA_DISK_1

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 00010 to /u01/app/oradata/CLOUDDB1/36994AC799462E62E0530F02000AFF86/datafile/o1_mf_corrupti_cqnms1yb_.dbf
channel ORA_DISK_1: reading from backup piece /u01/app/oradata/fra/CLOUDDB1/36994AC799462E62E0530F02000AFF86/backupset/2016_07_04/o1_mf_nnndf_TAG20160704T140801_cqnnh3n8_.bkp
channel ORA_DISK_1: piece handle=/u01/app/oradata/fra/CLOUDDB1/36994AC799462E62E0530F02000AFF86/backupset/2016_07_04/o1_mf_nnndf_TAG20160704T140801_cqnnh3n8_.bkp tag=TAG20160704T140801
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 04-JUL-16

RMAN> recover datafile 10 ;

Starting recover at 04-JUL-16
using channel ORA_DISK_1

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

Finished recover at 04-JUL-16

Here I already know that I can offline the datafile only from the PDB

[oracle@hackbook ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.1.0.2.0 Production on Mon Jul 4 14:36:41 2016

Copyright (c) 1982, 2014, 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> alter session set container=rcat ;

Session altered.

SQL> alter database datafile 10 online ;

Database altered.

[oracle@hackbook ~]$ sqlplus jano/jano@"(DESCRIPTION=(CONNECT_DATA=(SERVICE_NAME=rcat))(ADDRESS=(PROTOCOL=TCP)(HOST=10.0.2.15)(PORT=1521)))"

SQL*Plus: Release 12.1.0.2.0 Production on Mon Jul 4 14:37:24 2016

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

Last Successful login time: Mon Jul 04 2016 14:32:04 +02:00

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> select * from test ;

	ID
----------
	 1
	 2
	 3
	 4
	 5
	 6


So what have we learned? we have to switch to the PDB when taking a file offline…