Oracle 12C Duplicating a Database to a Remote Host by Using Backup-based Duplication

不连接目标数据库和恢复目录使用备份来将RAC CDB复制成单实例CDB数据库操作如下
1.检查源RAC CDB(jy)的参数文件,数据文件,联机日志文件,控制文件,归档日志文件的存储目录

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- --------------------------------------------
spfile                               string      +DATA/JY/PARAMETERFILE/spfile.303.961976713

RMAN> report schema;

Report of database schema for database with db_unique_name JY

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    840      SYSTEM               YES     +DATA/JY/DATAFILE/system.317.962209603
3    2340     SYSAUX               NO      +DATA/JY/DATAFILE/sysaux.298.962209605
4    1015     UNDOTBS1             YES     +DATA/JY/DATAFILE/undotbs1.277.962209605
5    250      PDB$SEED:SYSTEM      NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
6    340      PDB$SEED:SYSAUX      NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
7    5        USERS                NO      +DATA/JY/DATAFILE/users.301.962209605
8    100      PDB$SEED:UNDOTBS1    NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
9    1350     UNDOTBS2             YES     +DATA/JY/DATAFILE/undotbs2.312.962209605
10   270      JYPDB:SYSTEM         YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
11   590      JYPDB:SYSAUX         NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
12   205      JYPDB:UNDOTBS1       YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
13   310      JYPDB:UNDO_2         YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
14   1267     JYPDB:USERS          NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
15   100      JYPDB:TEST           NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
16   260      TESTPDB:SYSTEM       YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
17   550      TESTPDB:SYSAUX       NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
18   245      TESTPDB:UNDOTBS1     YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
19   100      TESTPDB:UNDO_2       YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
20   5        TESTPDB:USERS        NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
21   100      TESTPDB:TEST         NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    144      TEMP                 32767       +DATA/JY/TEMPFILE/temp.299.961976339
2    64       PDB$SEED:TEMP        32767       +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/TEMPFILE/temp.297.962209865
3    137      JYPDB:TEMP           32767       +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/TEMPFILE/temp.276.962210519
4    135      TESTPDB:TEMP         32767       +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.258.962469435

SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------------------------------
control_files                        string      +DATA/JY/CONTROLFILE/current.272.961976315


SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/JY/ONLINELOG/group_2.302.961976321
+DATA/JY/ONLINELOG/group_1.261.961976319
+DATA/JY/ONLINELOG/group_3.263.961976697
+DATA/JY/ONLINELOG/group_4.262.961976705


SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +TEST/arch
Oldest online log sequence     127
Next log sequence to archive   128
Current log sequence           128

2.对源RAC CDB数据库创建RMAN备份,这里将远程主机的目录/ora_backup通过nfs挂载到源主机的/ora_backup目录这样可以避免对备份文件进行复制操作

[oracle@jytest1 ~]$ rman target/ catalog rco/abcd@jypdb_173

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jan 24 19:47:12 2018

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

connected to target database: JY (DBID=979425723)
connected to recovery catalog database

RMAN> run
2> {
3> backup as compressed backupset database format '/ora_backup/jy_%u_%d_%t_%s_%p'  plus archivelog format '/ora_backup/arch_%d_%T_%U';
4> backup current controlfile format'/ora_backup/%d_%s.ctl';
5> backup spfile format '/ora_backup/spf%d_%s.ora';
6> }


Starting backup at 24-JAN-18
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=385 instance=jy1 device type=DISK
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=2 sequence=141 RECID=320 STAMP=966188816
input archived log thread=1 sequence=161 RECID=321 STAMP=966188818
input archived log thread=2 sequence=142 RECID=323 STAMP=966188832
input archived log thread=1 sequence=162 RECID=322 STAMP=966188829
input archived log thread=1 sequence=163 RECID=325 STAMP=966188842
input archived log thread=2 sequence=143 RECID=324 STAMP=966188842
input archived log thread=2 sequence=144 RECID=327 STAMP=966189268
input archived log thread=1 sequence=164 RECID=326 STAMP=966189266
input archived log thread=1 sequence=165 RECID=328 STAMP=966189274
input archived log thread=2 sequence=145 RECID=329 STAMP=966189274
input archived log thread=1 sequence=166 RECID=330 STAMP=966192976
input archived log thread=2 sequence=146 RECID=331 STAMP=966192977
input archived log thread=1 sequence=167 RECID=333 STAMP=966193374
input archived log thread=2 sequence=147 RECID=332 STAMP=966193373
input archived log thread=2 sequence=148 RECID=334 STAMP=966193380
input archived log thread=1 sequence=168 RECID=335 STAMP=966193380
input archived log thread=1 sequence=169 RECID=336 STAMP=966207796
input archived log thread=2 sequence=149 RECID=338 STAMP=966208644
input archived log thread=1 sequence=170 RECID=337 STAMP=966208634
input archived log thread=1 sequence=171 RECID=339 STAMP=966208856
input archived log thread=2 sequence=150 RECID=340 STAMP=966208857
input archived log thread=1 sequence=172 RECID=341 STAMP=966209350
input archived log thread=2 sequence=151 RECID=342 STAMP=966209350
input archived log thread=1 sequence=173 RECID=344 STAMP=966209356
input archived log thread=2 sequence=152 RECID=343 STAMP=966209356
input archived log thread=2 sequence=153 RECID=346 STAMP=966246980
input archived log thread=1 sequence=174 RECID=345 STAMP=966246243
input archived log thread=1 sequence=175 RECID=347 STAMP=966271688
input archived log thread=2 sequence=154 RECID=349 STAMP=966282445
input archived log thread=1 sequence=176 RECID=348 STAMP=966282440
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/arch_JY_20180124_78spgj6g_1_1 tag=TAG20180124T194727 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
Finished backup at 24-JAN-18

Starting backup at 24-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/JY/DATAFILE/sysaux.298.962209605
input datafile file number=00009 name=+DATA/JY/DATAFILE/undotbs2.312.962209605
input datafile file number=00004 name=+DATA/JY/DATAFILE/undotbs1.277.962209605
input datafile file number=00001 name=+DATA/JY/DATAFILE/system.317.962209603
input datafile file number=00007 name=+DATA/JY/DATAFILE/users.301.962209605
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/jy_79spgj9s_JY_966282556_233_1 tag=TAG20180124T194913 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:55
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
input datafile file number=00011 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
input datafile file number=00013 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
input datafile file number=00010 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
input datafile file number=00012 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
input datafile file number=00015 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/jy_7aspgjfb_JY_966282731_234_1 tag=TAG20180124T194913 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:15
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00016 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00018 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00019 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00021 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00020 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/jy_7bspgjhn_JY_966282807_235_1 tag=TAG20180124T194913 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:05
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
input datafile file number=00005 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
input datafile file number=00008 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/jy_7cspgjjo_JY_966282872_236_1 tag=TAG20180124T194913 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/jy_7dspgjlg_JY_966282928_237_1 tag=TAG20180124T194913 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-JAN-18

Starting backup at 24-JAN-18
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=177 RECID=351 STAMP=966282933
input archived log thread=2 sequence=155 RECID=350 STAMP=966282933
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/arch_JY_20180124_7espgjln_1_1 tag=TAG20180124T195535 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-JAN-18

Starting backup at 24-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current control file in backup set
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/JY_239.ctl tag=TAG20180124T195540 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 24-JAN-18

Starting backup at 24-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 24-JAN-18
channel ORA_DISK_1: finished piece 1 at 24-JAN-18
piece handle=/ora_backup/spfJY_240.ora tag=TAG20180124T195549 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 24-JAN-18

在目标主机的/ora_backup目录中查看生成的RMAN备份文件
[root@shard1 ora_backup]# ls -lrt
total 1646052
-rw-r-----. 1 oracle 1006 473020928 Jan 24 13:45 arch_JY_20180124_78spgj6g_1_1
-rw-r-----. 1 oracle 1006 615038976 Jan 24 13:48 jy_79spgj9s_JY_966282556_233_1
-rw-r-----. 1 oracle 1006 213581824 Jan 24 13:49 jy_7aspgjfb_JY_966282731_234_1
-rw-r-----. 1 oracle 1006 190742528 Jan 24 13:50 jy_7bspgjhn_JY_966282807_235_1
-rw-r-----. 1 oracle 1006 171524096 Jan 24 13:51 jy_7cspgjjo_JY_966282872_236_1
-rw-r-----. 1 oracle 1006   1163264 Jan 24 13:51 jy_7dspgjlg_JY_966282928_237_1
-rw-r-----. 1 oracle 1006    392192 Jan 24 13:51 arch_JY_20180124_7espgjln_1_1
-rw-r-----. 1 oracle 1006  19972096 Jan 24 13:51 JY_239.ctl
-rw-r-----. 1 oracle 1006    114688 Jan 24 13:51 spfJY_240.ora

3.在目标主机上创建存储目标数据库(dupjy)相关数据库文件的目录,目标主机上的/u01/app/oracle/oradata/dupjy目录用来存储数据库的数据文件,控制文件,联机重做日志文件),/u01/app/oracle/arch/dupjy目录用来存储数据库的归档重做日志文件。

4.将源数据库的密码文件复制到目标主机的相应目录中并修改为目标数据库(dupjy)对应的文件名

[grid@jytest1 ~]$ srvctl config database -db jy
Database unique name: jy
Database name: jy
Oracle home: /u01/app/oracle/product/12.2.0/db
Oracle user: oracle
Spfile: +DATA/JY/PARAMETERFILE/spfile.303.961976713
Password file: +DATA/JY/PASSWORD/pwdjy.274.961976109
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: jy1,jy2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

[grid@jytest1 ~]$ asmcmd cp  +DATA/JY/PASSWORD/pwdjy.274.961976109 /home/grid/pwddupjy
copying +DATA/JY/PASSWORD/pwdjy.274.961976109 -> /home/grid/pwddupjy


[oracle@shard1 dbs]# scp grid@10.138.130.171:/home/grid/pwddupjy /u01/app/oracle/product/12.2.0/db/dbs/
The authenticity of host '10.138.130.171 (10.138.130.171)' can't be established.
ECDSA key fingerprint is 7a:62:58:8b:77:98:52:94:d6:d5:0c:c4:6c:87:a6:7f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.171' (ECDSA) to the list of known hosts.
grid@10.138.130.171's password:
pwddupjy

[oracle@shard1 dbs]$ mv pwddupjy orapwdupjy

5.使用源数据库的spfile文件来创建目标数据库要使用的spfile文件
在源数据库中执行下面的命令来创建pfile参数文件

SQL> create pfile from spfile;

File created.

[root@shard1 ~]# scp oracle@10.138.130.171:/u01/app/oracle/product/12.2.0/db/dbs/initjy1.ora /u01/app/oracle/product/12.2.0/db/dbs/
grid@10.138.130.171's password:
initjy1.ora

             100% 1731     1.7KB/s   00:00
[root@shard1 ~]#


[oracle@shard1 dbs]$ cat initdupjy.ora
*.audit_file_dest='/u01/app/oracle/admin/dupjy/adump'
*.cluster_database=false
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/dupjy/control01.ctl'
*.db_block_size=8192
*.db_name='dupjy'
*.diagnostic_dest='/u01/app/oracle'
*.enable_pluggable_database=true
*.open_cursors=300
*.pga_aggregate_target=1g
*.processes=2000
*.remote_login_passwordfile='exclusive'
*.sga_max_size=2147483648
*.sga_target=2147483648
db_file_name_convert=

('+DATA/JY/DATAFILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATA

FILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/','/u01/app/oracle/oradata/dupjy/')
log_file_name_convert=('+DATA/JY/ONLINELOG/','/u01/app/oracle/oradata/dupjy/')



[oracle@shard1 dbs]$ export ORACLE_SID=dupjy
[oracle@shard1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 19:06:00 2018

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

Connected to an idle instance.

SQL> startup nomount pfile='/u01/app/oracle/product/12.2.0/db/dbs/initdupjy.ora'
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes

SQL> create spfile from pfile='/u01/app/oracle/product/12.2.0/db/dbs/initdupjy.ora';

File created.

6.使用spfile参数文件来启动目标数据库实例(辅助实例dupjy)

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes


SQL> show parameter spfile

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- -----------------------------------------------------
spfile                               string                 /u01/app/oracle/product/12.2.0/db/dbs/spfiledupjy.ora

7.给目标数据库配置静态监听

[oracle@shard1 admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = shard1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = dupjy)
      (ORACLE_HOME = /u01/app/oracle/product/12.2.0/db)
      (GLOBAL_DBNAME=dupjy)
    )
  )


[oracle@shard1 admin]$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-JAN-2018 20:30:34

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/12.2.0/db/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/shard1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=shard1)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=shard1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                18-JAN-2018 20:30:34
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/shard1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=shard1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "dupjy" has 1 instance(s).
  Instance "dupjy", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully



8.在目标主机上配置tns,用来通过网络服务名来连接源数据库与目标数据库

[oracle@shard1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

JY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.171)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jy)
    )
  )

DUPJY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.180)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dupjy)
    )
  )

9.在目标主机上测试是否可以通过使用网络服务名来连接源数据库与目标数据库

[oracle@shard1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 21:02:53 2018

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

SQL> conn / as sysdba
Connected.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@shard1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 21:04:51 2018

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

SQL> conn sys/abcd@dupjy as sysdba
Connected.
SQL> conn sys/abcd@jy as sysdba
Connected.

10.在源主机上配置目标数据库的tns名

[oracle@jytest1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.


JY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = jytest-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jy)
    )
  )



DUPJY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.180)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dupjy)
      (UR = A)
    )
  )

11.在源主机上测试能否可以使用网络服务名来连接源数据库与目标数据库

[oracle@jytest1 admin]$ sqlplus /nolog
SQL*Plus: Release 12.2.0.1.0 Production on Fri Jan 19 03:16:59 2018

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

SQL> conn sys/abcd@jy as sysdba
Connected.
SQL> conn sys/abcd@dupjy as sysdba
Connected.

12.使用备份来复制RAC CDB为单实例CDB(dupjy),执行duplicate命令,如果没有配置自动通道,那么至少手动分配一个辅助实例。如果是使用PFILE参数文件启动辅助实例需要指定pfile参数文件,且pfile参数文件必须存储在运行RMAN执行复制的主机上。复制命令没有指定数据库名。使用database关键字而不指定数据库名,duplicate将从备份中获得数据库名和DBID。如果在backup location目录中一个数据库有多个备份将会显示错误。使用backup子句来识别没有目标数据库和恢复目录的复制类型。until time选项用来指定恢复目标时间,它是唯一能与backup location子句一起使用的选项。因为副本数据库和原数据库文件的文件名相同所以要指定nofilenamecheck选项:

[oracle@shard1 ora_backup]$ rman auxiliary sys/abcd@dupjy

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jan 24 17:13:28 2018

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

connected to auxiliary database: JY (not mounted)

RMAN> run
2> {
3> set newname for database to '/u01/app/oracle/oradata/dupjy/%b';
4> duplicate database 'JY' to 'dupjy'
5> logfile group 1 ('/u01/app/oracle/oradata/dupjy/group_1.261.961976319') size 200M reuse,
6> group 2 ('/u01/app/oracle/oradata/dupjy/group_2.302.961976321')  size 200M reuse,
7> group 3 ('/u01/app/oracle/oradata/dupjy/group_3.263.961976697')  size 200M reuse,
8> group 4 ('/u01/app/oracle/oradata/dupjy/group_4.262.961976705')  size 200M reuse
9> backup location '/ora_backup';
10> }

executing command: SET NEWNAME

Starting Duplicate Db at 24-JAN-18

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''JY'' comment=
 ''Modified by RMAN duplicate'' scope=spfile";
   shutdown clone immediate;
   startup clone force nomount
   restore clone primary controlfile from  '/ora_backup/JY_239.ctl';
   alter clone database mount;
}
executing Memory Script

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

Oracle instance shut down

Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes

Starting restore at 24-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2269 device type=DISK

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/dupjy/control01.ctl
Finished restore at 24-JAN-18

database mounted
released channel: ORA_AUX_DISK_1
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2269 device type=DISK

contents of Memory Script:
{
   set until scn  15999223;
   sql clone 'alter database flashback off';
   set newname for datafile  1 to
 "/u01/app/oracle/oradata/dupjy/system.317.962209603";
   set newname for datafile  3 to
 "/u01/app/oracle/oradata/dupjy/sysaux.298.962209605";
   set newname for datafile  4 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605";
   set newname for datafile  5 to
 "/u01/app/oracle/oradata/dupjy/system.256.962209675";
   set newname for datafile  6 to
 "/u01/app/oracle/oradata/dupjy/sysaux.270.962209675";
   set newname for datafile  7 to
 "/u01/app/oracle/oradata/dupjy/users.301.962209605";
   set newname for datafile  8 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675";
   set newname for datafile  9 to
 "/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605";
   set newname for datafile  10 to
 "/u01/app/oracle/oradata/dupjy/system.271.962209649";
   set newname for datafile  11 to
 "/u01/app/oracle/oradata/dupjy/sysaux.316.962209649";
   set newname for datafile  12 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649";
   set newname for datafile  13 to
 "/u01/app/oracle/oradata/dupjy/undo_2.268.962209649";
   set newname for datafile  14 to
 "/u01/app/oracle/oradata/dupjy/users.278.962209649";
   set newname for datafile  15 to
 "/u01/app/oracle/oradata/dupjy/test.275.962210609";
   set newname for datafile  16 to
 "/u01/app/oracle/oradata/dupjy/system.260.962469409";
   set newname for datafile  17 to
 "/u01/app/oracle/oradata/dupjy/sysaux.259.962469409";
   set newname for datafile  18 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409";
   set newname for datafile  19 to
 "/u01/app/oracle/oradata/dupjy/undo_2.266.962469409";
   set newname for datafile  20 to
 "/u01/app/oracle/oradata/dupjy/users.267.962469409";
   set newname for datafile  21 to
 "/u01/app/oracle/oradata/dupjy/test.269.962469409";
   restore
   clone database
   ;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database flashback off

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

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

executing command: SET NEWNAME

executing command: SET NEWNAME

Starting restore at 24-JAN-18
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/dupjy/system.317.962209603
channel ORA_AUX_DISK_1: restoring datafile 00003 to /u01/app/oracle/oradata/dupjy/sysaux.298.962209605
channel ORA_AUX_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
channel ORA_AUX_DISK_1: restoring datafile 00007 to /u01/app/oracle/oradata/dupjy/users.301.962209605
channel ORA_AUX_DISK_1: restoring datafile 00009 to /u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
channel ORA_AUX_DISK_1: reading from backup piece /ora_backup/jy_79spgj9s_JY_966282556_233_1
channel ORA_AUX_DISK_1: piece handle=/ora_backup/jy_79spgj9s_JY_966282556_233_1 tag=TAG20180124T194913
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:02:25
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 00010 to /u01/app/oracle/oradata/dupjy/system.271.962209649
channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/dupjy/sysaux.316.962209649
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
channel ORA_AUX_DISK_1: restoring datafile 00013 to /u01/app/oracle/oradata/dupjy/undo_2.268.962209649
channel ORA_AUX_DISK_1: restoring datafile 00014 to /u01/app/oracle/oradata/dupjy/users.278.962209649
channel ORA_AUX_DISK_1: restoring datafile 00015 to /u01/app/oracle/oradata/dupjy/test.275.962210609
channel ORA_AUX_DISK_1: reading from backup piece /ora_backup/jy_7aspgjfb_JY_966282731_234_1
channel ORA_AUX_DISK_1: piece handle=/ora_backup/jy_7aspgjfb_JY_966282731_234_1 tag=TAG20180124T194913
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
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 00016 to /u01/app/oracle/oradata/dupjy/system.260.962469409
channel ORA_AUX_DISK_1: restoring datafile 00017 to /u01/app/oracle/oradata/dupjy/sysaux.259.962469409
channel ORA_AUX_DISK_1: restoring datafile 00018 to /u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
channel ORA_AUX_DISK_1: restoring datafile 00019 to /u01/app/oracle/oradata/dupjy/undo_2.266.962469409
channel ORA_AUX_DISK_1: restoring datafile 00020 to /u01/app/oracle/oradata/dupjy/users.267.962469409
channel ORA_AUX_DISK_1: restoring datafile 00021 to /u01/app/oracle/oradata/dupjy/test.269.962469409
channel ORA_AUX_DISK_1: reading from backup piece /ora_backup/jy_7bspgjhn_JY_966282807_235_1
channel ORA_AUX_DISK_1: piece handle=/ora_backup/jy_7bspgjhn_JY_966282807_235_1 tag=TAG20180124T194913
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
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 00005 to /u01/app/oracle/oradata/dupjy/system.256.962209675
channel ORA_AUX_DISK_1: restoring datafile 00006 to /u01/app/oracle/oradata/dupjy/sysaux.270.962209675
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
channel ORA_AUX_DISK_1: reading from backup piece /ora_backup/jy_7cspgjjo_JY_966282872_236_1
channel ORA_AUX_DISK_1: piece handle=/ora_backup/jy_7cspgjjo_JY_966282872_236_1 tag=TAG20180124T194913
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36
Finished restore at 24-JAN-18

contents of Memory Script:
{
   switch clone datafile all;
}
executing Memory Script

datafile 1 switched to datafile copy
input datafile copy RECID=21 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/system.317.962209603
datafile 3 switched to datafile copy
input datafile copy RECID=22 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=23 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 5 switched to datafile copy
input datafile copy RECID=24 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/system.256.962209675
datafile 6 switched to datafile copy
input datafile copy RECID=25 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 7 switched to datafile copy
input datafile copy RECID=26 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/users.301.962209605
datafile 8 switched to datafile copy
input datafile copy RECID=27 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=28 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 10 switched to datafile copy
input datafile copy RECID=29 STAMP=966273552 file name=/u01/app/oracle/oradata/dupjy/system.271.962209649
datafile 11 switched to datafile copy
input datafile copy RECID=30 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=31 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=32 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=33 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 15 switched to datafile copy
input datafile copy RECID=34 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/test.275.962210609
datafile 16 switched to datafile copy
input datafile copy RECID=35 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/system.260.962469409
datafile 17 switched to datafile copy
input datafile copy RECID=36 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409
datafile 18 switched to datafile copy
input datafile copy RECID=37 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
datafile 19 switched to datafile copy
input datafile copy RECID=38 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409
datafile 20 switched to datafile copy
input datafile copy RECID=39 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/users.267.962469409
datafile 21 switched to datafile copy
input datafile copy RECID=40 STAMP=966273553 file name=/u01/app/oracle/oradata/dupjy/test.269.962469409

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

executing command: SET until clause

Starting recover at 24-JAN-18
using channel ORA_AUX_DISK_1

starting media recovery

channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=177
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=155
channel ORA_AUX_DISK_1: reading from backup piece /ora_backup/arch_JY_20180124_7espgjln_1_1
channel ORA_AUX_DISK_1: piece handle=/ora_backup/arch_JY_20180124_7espgjln_1_1 tag=TAG20180124T195535
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_177_961976319.dbf thread=1 sequence=177
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_155_961976319.dbf thread=2 sequence=155
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_177_961976319.dbf RECID=1 STAMP=966273556
channel clone_default: deleting archived log(s)
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_155_961976319.dbf RECID=2 STAMP=966273556
media recovery complete, elapsed time: 00:00:02
Finished recover at 24-JAN-18
Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes

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

sql statement: alter system set  db_name =  ''DUPJY'' comment= ''Reset to original value by RMAN'' scope=spfile
Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPJY" RESETLOGS ARCHIVELOG
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/u01/app/oracle/oradata/dupjy/group_1.261.961976319' ) SIZE 200 M  REUSE,
  GROUP   2 ( '/u01/app/oracle/oradata/dupjy/group_2.302.961976321' ) SIZE 200 M  REUSE,
  GROUP   3 ( '/u01/app/oracle/oradata/dupjy/group_3.263.961976697' ) SIZE 200 M  REUSE,
  GROUP   4 ( '/u01/app/oracle/oradata/dupjy/group_4.262.961976705' ) SIZE 200 M  REUSE
 DATAFILE
  '/u01/app/oracle/oradata/dupjy/system.317.962209603',
  '/u01/app/oracle/oradata/dupjy/system.256.962209675',
  '/u01/app/oracle/oradata/dupjy/system.271.962209649',
  '/u01/app/oracle/oradata/dupjy/system.260.962469409'
 CHARACTER SET ZHS16GBK


contents of Memory Script:
{
   set newname for tempfile  1 to
 "/u01/app/oracle/oradata/dupjy/temp.299.961976339";
   set newname for tempfile  2 to
 "/u01/app/oracle/oradata/dupjy/temp.297.962209865";
   set newname for tempfile  3 to
 "/u01/app/oracle/oradata/dupjy/temp.276.962210519";
   set newname for tempfile  4 to
 "/u01/app/oracle/oradata/dupjy/temp.258.962469435";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/app/oracle/oradata/dupjy/sysaux.298.962209605",
 "/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605",
 "/u01/app/oracle/oradata/dupjy/sysaux.270.962209675",
 "/u01/app/oracle/oradata/dupjy/users.301.962209605",
 "/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675",
 "/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605",
 "/u01/app/oracle/oradata/dupjy/sysaux.316.962209649",
 "/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649",
 "/u01/app/oracle/oradata/dupjy/undo_2.268.962209649",
 "/u01/app/oracle/oradata/dupjy/users.278.962209649",
 "/u01/app/oracle/oradata/dupjy/test.275.962210609",
 "/u01/app/oracle/oradata/dupjy/sysaux.259.962469409",
 "/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409",
 "/u01/app/oracle/oradata/dupjy/undo_2.266.962469409",
 "/u01/app/oracle/oradata/dupjy/users.267.962469409",
 "/u01/app/oracle/oradata/dupjy/test.269.962469409";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /u01/app/oracle/oradata/dupjy/temp.299.961976339 in control file
renamed tempfile 2 to /u01/app/oracle/oradata/dupjy/temp.297.962209865 in control file
renamed tempfile 3 to /u01/app/oracle/oradata/dupjy/temp.276.962210519 in control file
renamed tempfile 4 to /u01/app/oracle/oradata/dupjy/temp.258.962469435 in control file

cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605 RECID=1 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605 RECID=2 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675 RECID=3 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.301.962209605 RECID=4 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675 RECID=5 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605 RECID=6 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649 RECID=7 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649 RECID=8 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649 RECID=9 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.278.962209649 RECID=10 STAMP=966273582
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.275.962210609 RECID=11 STAMP=966273583
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409 RECID=12 STAMP=966273583
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409 RECID=13 STAMP=966273583
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409 RECID=14 STAMP=966273583
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.267.962469409 RECID=15 STAMP=966273583
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.269.962469409 RECID=16 STAMP=966273583

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 7 switched to datafile copy
input datafile copy RECID=4 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/users.301.962209605
datafile 8 switched to datafile copy
input datafile copy RECID=5 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=6 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 11 switched to datafile copy
input datafile copy RECID=7 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=8 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=9 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=10 STAMP=966273582 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 15 switched to datafile copy
input datafile copy RECID=11 STAMP=966273583 file name=/u01/app/oracle/oradata/dupjy/test.275.962210609
datafile 17 switched to datafile copy
input datafile copy RECID=12 STAMP=966273583 file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409
datafile 18 switched to datafile copy
input datafile copy RECID=13 STAMP=966273583 file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
datafile 19 switched to datafile copy
input datafile copy RECID=14 STAMP=966273583 file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409
datafile 20 switched to datafile copy
input datafile copy RECID=15 STAMP=966273583 file name=/u01/app/oracle/oradata/dupjy/users.267.962469409
datafile 21 switched to datafile copy
input datafile copy RECID=16 STAMP=966273583 file name=/u01/app/oracle/oradata/dupjy/test.269.962469409

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 24-JAN-18

13.检查源RAC CDB(jy)是否被成功复制成单实例CDB(dupjy)


SQL> alter session set container=testpdb;

Session altered.

SQL> select count(*) from jy.t1;

  COUNT(*)
----------
        39

SQL> select table_name,tablespace_name from dba_tables where owner='JY';

TABLE_NAME                                                                                                                       TABLESPACE_NAME
-------------------------------------------------------------------------------------------------------------------------------- ------------------------------
T1

从上面的输出结果可以看到已经将源RAC CDB数据库复制成为单实例CDB数据库就已经操作完成了。

Oracle 12c RMAN Duplicating a Subset of the Source Database Tablespaces

使用RMAN对CDB中的部分表空间进行复制的操作如下
1.检查源RAC CDB(jy)的参数文件,数据文件,联机日志文件,控制文件,归档日志文件的存储目录

SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- --------------------------------------------
spfile                               string      +DATA/JY/PARAMETERFILE/spfile.303.961976713

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/JY/DATAFILE/system.317.962209603
+DATA/JY/DATAFILE/sysaux.298.962209605
+DATA/JY/DATAFILE/undotbs1.277.962209605
+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
+DATA/JY/DATAFILE/users.301.962209605
+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
+DATA/JY/DATAFILE/undotbs2.312.962209605
+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409


SQL> show parameter control_files

NAME                                 TYPE        VALUE
------------------------------------ ----------- -------------------------------------------
control_files                        string      +DATA/JY/CONTROLFILE/current.272.961976315


SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
+DATA/JY/ONLINELOG/group_2.302.961976321
+DATA/JY/ONLINELOG/group_1.261.961976319
+DATA/JY/ONLINELOG/group_3.263.961976697
+DATA/JY/ONLINELOG/group_4.262.961976705


SQL> archive log list
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            +TEST/arch
Oldest online log sequence     127
Next log sequence to archive   128
Current log sequence           128

2.查询整个CDB中的表空间名称,在复制整个CDB数据库时跳过JYPDB:TEST表空间

[oracle@jytest1 ~]$ rman target sys/abcd@jy catalog rco/abcd@jypdb_173

Recovery Manager: Release 12.2.0.1.0 - Production on Sat Jan 20 00:47:19 2018

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

connected to target database: JY (DBID=979425723)
connected to recovery catalog database

RMAN> report schema;

Report of database schema for database with db_unique_name JY

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    840      SYSTEM               YES     +DATA/JY/DATAFILE/system.317.962209603
3    2210     SYSAUX               NO      +DATA/JY/DATAFILE/sysaux.298.962209605
4    570      UNDOTBS1             YES     +DATA/JY/DATAFILE/undotbs1.277.962209605
5    250      PDB$SEED:SYSTEM      NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
6    340      PDB$SEED:SYSAUX      NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
7    5        USERS                NO      +DATA/JY/DATAFILE/users.301.962209605
8    100      PDB$SEED:UNDOTBS1    NO      +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
9    150      UNDOTBS2             YES     +DATA/JY/DATAFILE/undotbs2.312.962209605
10   270      JYPDB:SYSTEM         YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
11   590      JYPDB:SYSAUX         NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
12   100      JYPDB:UNDOTBS1       YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
13   100      JYPDB:UNDO_2         YES     +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
14   1267     JYPDB:USERS          NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
15   100      JYPDB:TEST           NO      +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
16   260      TESTPDB:SYSTEM       YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
17   550      TESTPDB:SYSAUX       NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
18   100      TESTPDB:UNDOTBS1     YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
19   100      TESTPDB:UNDO_2       YES     +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
20   5        TESTPDB:USERS        NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
21   100      TESTPDB:TEST         NO      +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    144      TEMP                 32767       +DATA/JY/TEMPFILE/temp.299.961976339
2    64       PDB$SEED:TEMP        32767       +DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/TEMPFILE/temp.297.962209865
3    137      JYPDB:TEMP           32767       +DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/TEMPFILE/temp.276.962210519
4    135      TESTPDB:TEMP         32767       +DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.258.962469435


3.在目标主机上创建存储目标数据库(dupjy)相关数据库文件的目录,目标主机上的/u01/app/oracle/oradata/dupjy目录用来存储数据库的数据文件,控制文件,联机重做日志文件),/u01/app/oracle/arch/dupjy目录用来存 储数据库的归档重做日志文件。

4.将源数据库的密码文件复制到目标主机的相应目录中并修改为目标数据库(dupjy)对应的文件名

[grid@jytest1 ~]$ srvctl config database -db jy
Database unique name: jy
Database name: jy
Oracle home: /u01/app/oracle/product/12.2.0/db
Oracle user: oracle
Spfile: +DATA/JY/PARAMETERFILE/spfile.303.961976713
Password file: +DATA/JY/PASSWORD/pwdjy.274.961976109
Domain:
Start options: open
Stop options: immediate
Database role: PRIMARY
Management policy: AUTOMATIC
Server pools:
Disk Groups: DATA
Mount point paths:
Services:
Type: RAC
Start concurrency:
Stop concurrency:
OSDBA group: dba
OSOPER group: oper
Database instances: jy1,jy2
Configured nodes: jytest1,jytest2
CSS critical: no
CPU count: 0
Memory target: 0
Maximum memory: 0
Default network number for database services:
Database is administrator managed

[grid@jytest1 ~]$ asmcmd cp  +DATA/JY/PASSWORD/pwdjy.274.961976109 /home/grid/pwddupjy
copying +DATA/JY/PASSWORD/pwdjy.274.961976109 -> /home/grid/pwddupjy


[oracle@shard1 dbs]# scp grid@10.138.130.171:/home/grid/pwddupjy /u01/app/oracle/product/12.2.0/db/dbs/
The authenticity of host '10.138.130.171 (10.138.130.171)' can't be established.
ECDSA key fingerprint is 7a:62:58:8b:77:98:52:94:d6:d5:0c:c4:6c:87:a6:7f.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.171' (ECDSA) to the list of known hosts.
grid@10.138.130.171's password:
pwddupjy

[oracle@shard1 dbs]$ mv pwddupjy orapwdupjy

5.使用源数据库的spfile文件来创建目标数据库要使用的spfile文件
在源数据库中执行下面的命令来创建pfile参数文件

SQL> create pfile from spfile;

File created.

[root@shard1 ~]# scp oracle@10.138.130.171:/u01/app/oracle/product/12.2.0/db/dbs/initjy1.ora /u01/app/oracle/product/12.2.0/db/dbs/
grid@10.138.130.171's password:
initjy1.ora                                                                                                                                                                                                100% 1731     1.7KB/s   00:00
[root@shard1 ~]#


[oracle@shard1 dbs]$ cat initdupjy.ora
*.audit_file_dest='/u01/app/oracle/admin/dupjy/adump'
*.cluster_database=false
*.compatible='12.2.0'
*.control_files='/u01/app/oracle/oradata/dupjy/control01.ctl'
*.db_block_size=8192
*.db_name='dupjy'
*.diagnostic_dest='/u01/app/oracle'
*.enable_pluggable_database=true
*.open_cursors=300
*.pga_aggregate_target=1g
*.processes=2000
*.remote_login_passwordfile='exclusive'
*.sga_max_size=2147483648
*.sga_target=2147483648
*.log_archive_dest_1='location=/u01/app/oracle/oradata/arch_dupjy'
db_file_name_convert= ('+DATA/JY/DATAFILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATA FILE/','/u01/app/oracle/oradata/dupjy/','+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/','/u01/app/oracle/oradata/dupjy/')
log_file_name_convert=('+DATA/JY/ONLINELOG/','/u01/app/oracle/oradata/dupjy/')



[oracle@shard1 dbs]$ export ORACLE_SID=dupjy
[oracle@shard1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 19:06:00 2018

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

Connected to an idle instance.

SQL> startup nomount pfile='/u01/app/oracle/product/12.2.0/db/dbs/initdupjy.ora'
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes

SQL> create spfile from pfile='/u01/app/oracle/product/12.2.0/db/dbs/initdupjy.ora';

File created.

6.使用spfile参数文件来启动目标数据库实例(辅助实例dupjy)

SQL> shutdown immediate
ORA-01507: database not mounted


ORACLE instance shut down.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes


SQL> show parameter spfile

NAME                                 TYPE                   VALUE
------------------------------------ ---------------------- -----------------------------------------------------
spfile                               string                 /u01/app/oracle/product/12.2.0/db/dbs/spfiledupjy.ora

7.给目标数据库配置静态监听

[oracle@shard1 admin]$ vi listener.ora
# listener.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
# Generated by Oracle configuration tools.

LISTENER =
  (DESCRIPTION_LIST =
    (DESCRIPTION =
      (ADDRESS = (PROTOCOL = TCP)(HOST = shard1)(PORT = 1521))
      (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521))
    )
  )

SID_LIST_LISTENER =
  (SID_LIST =
    (SID_DESC =
      (SID_NAME = dupjy)
      (ORACLE_HOME = /u01/app/oracle/product/12.2.0/db)
      (GLOBAL_DBNAME=dupjy)
    )
  )


[oracle@shard1 admin]$ lsnrctl start

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 18-JAN-2018 20:30:34

Copyright (c) 1991, 2016, Oracle.  All rights reserved.

Starting /u01/app/oracle/product/12.2.0/db/bin/tnslsnr: please wait...

TNSLSNR for Linux: Version 12.2.0.1.0 - Production
System parameter file is /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
Log messages written to /u01/app/oracle/diag/tnslsnr/shard1/listener/alert/log.xml
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=shard1)(PORT=1521)))
Listening on: (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=TCP)(HOST=shard1)(PORT=1521)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                18-JAN-2018 20:30:34
Uptime                    0 days 0 hr. 0 min. 0 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/oracle/product/12.2.0/db/network/admin/listener.ora
Listener Log File         /u01/app/oracle/diag/tnslsnr/shard1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=shard1)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=EXTPROC1521)))
Services Summary...
Service "dupjy" has 1 instance(s).
  Instance "dupjy", status UNKNOWN, has 1 handler(s) for this service...
The command completed successfully



8.在目标主机上配置tns,用来通过网络服务名来连接源数据库与目标数据库

[oracle@shard1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.

JY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.171)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jy)
    )
  )

DUPJY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.180)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dupjy)
    )
  )

9.在目标主机上测试是否可以通过使用网络服务名来连接源数据库与目标数据库

[oracle@shard1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 21:02:53 2018

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

SQL> conn / as sysdba
Connected.
SQL> startup nomount
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size             570428704 bytes
Database Buffers         1560281088 bytes
Redo Buffers                7979008 bytes
SQL> exit
Disconnected from Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
[oracle@shard1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Thu Jan 18 21:04:51 2018

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

SQL> conn sys/abcd@dupjy as sysdba
Connected.
SQL> conn sys/abcd@jy as sysdba
Connected.

10.在源主机上配置目标数据库的tns名

[oracle@jytest1 admin]$ vi tnsnames.ora
# tnsnames.ora Network Configuration File: /u01/app/oracle/product/12.2.0/db/network/admin/tnsnames.ora
# Generated by Oracle configuration tools.


JY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = jytest-scan)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jy)
    )
  )



DUPJY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.180)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dupjy)
      (UR = A)
    )
  )

11.在源主机上测试能否可以使用网络服务名来连接源数据库与目标数据库

[oracle@jytest1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Fri Jan 19 03:16:59 2018

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

SQL> conn sys/xxzx7817600@jy as sysdba
Connected.
SQL> conn sys/xxzx7817600@dupjy as sysdba
Connected.

12.执行数据库复制(跳过源CDB中的JYPDB:TEST表空间)

[oracle@jytest1 ~]$ rman target sys/abcd@jy catalog rco/abcd@jypdb_173 auxiliary sys/abcd@dupjy

Recovery Manager: Release 12.2.0.1.0 - Production on Sat Jan 20 01:14:06 2018

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

connected to target database: JY (DBID=979425723)
connected to recovery catalog database
connected to auxiliary database: DUPJY (not mounted)


RMAN> duplicate target database to dupjy SKIP TABLESPACE JYPDB:'TEST' from active database nofilenamecheck using compressed backupset;

Starting Duplicate Db at 20-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=10 device type=DISK
current log archived

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

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

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

Oracle instance shut down

Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size                788532512 bytes
Database Buffers            1342177280 bytes
Redo Buffers                   7979008 bytes

Starting restore at 20-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2269 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 jy
channel ORA_AUX_DISK_1: restoring control file
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:06
output file name=/u01/app/oracle/oradata/dupjy/control01.ctl
Finished restore at 20-JAN-18

database mounted
Checking that duplicated tablespaces are self-contained
Datafile 15 skipped by request
RMAN-05529: warning: DB_FILE_NAME_CONVERT resulted in invalid ASM names; names changed to disk group only.

contents of Memory Script:
{
   sql clone 'alter database flashback off';
   set newname for datafile  1 to
 "/u01/app/oracle/oradata/dupjy/system.317.962209603";
   set newname for datafile  3 to
 "/u01/app/oracle/oradata/dupjy/sysaux.298.962209605";
   set newname for datafile  4 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605";
   set newname for datafile  5 to
 "/u01/app/oracle/oradata/dupjy/system.256.962209675";
   set newname for datafile  6 to
 "/u01/app/oracle/oradata/dupjy/sysaux.270.962209675";
   set newname for datafile  7 to
 "/u01/app/oracle/oradata/dupjy/users.301.962209605";
   set newname for datafile  8 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675";
   set newname for datafile  9 to
 "/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605";
   set newname for datafile  10 to
 "/u01/app/oracle/oradata/dupjy/system.271.962209649";
   set newname for datafile  11 to
 "/u01/app/oracle/oradata/dupjy/sysaux.316.962209649";
   set newname for datafile  12 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649";
   set newname for datafile  13 to
 "/u01/app/oracle/oradata/dupjy/undo_2.268.962209649";
   set newname for datafile  14 to
 "/u01/app/oracle/oradata/dupjy/users.278.962209649";
   set newname for datafile  16 to
 "/u01/app/oracle/oradata/dupjy/system.260.962469409";
   set newname for datafile  17 to
 "/u01/app/oracle/oradata/dupjy/sysaux.259.962469409";
   set newname for datafile  18 to
 "/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409";
   set newname for datafile  19 to
 "/u01/app/oracle/oradata/dupjy/undo_2.266.962469409";
   set newname for datafile  20 to
 "/u01/app/oracle/oradata/dupjy/users.267.962469409";
   set newname for datafile  21 to
 "/u01/app/oracle/oradata/dupjy/test.269.962469409";
   restore
   from  nonsparse   from service
 'jy'   using compressed backupset
   clone database
   skip forever tablespace  "JYPDB":"TEST"   ;
   sql 'alter system archive log current';
}
executing Memory Script

sql statement: alter database flashback off

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

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

executing command: SET NEWNAME

Starting restore at 20-JAN-18
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 jy
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/dupjy/system.317.962209603
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/sysaux.298.962209605
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:36
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/undotbs1.277.962209605
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 jy
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/dupjy/system.256.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/sysaux.270.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:36
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/users.301.962209605
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 jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00008 to /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/undotbs2.312.962209605
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 jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00010 to /u01/app/oracle/oradata/dupjy/system.271.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00011 to /u01/app/oracle/oradata/dupjy/sysaux.316.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00012 to /u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00013 to /u01/app/oracle/oradata/dupjy/undo_2.268.962209649
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 jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00014 to /u01/app/oracle/oradata/dupjy/users.278.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:26
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00016 to /u01/app/oracle/oradata/dupjy/system.260.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:16
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/sysaux.259.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/undotbs1.265.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
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/dupjy/undo_2.266.962469409
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 jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00020 to /u01/app/oracle/oradata/dupjy/users.267.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00021 to /u01/app/oracle/oradata/dupjy/test.269.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 20-JAN-18

sql statement: alter system archive log current
current log archived

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

Starting restore at 20-JAN-18
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 jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=146
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 jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=1 sequence=147
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=121
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 jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=122
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
channel ORA_AUX_DISK_1: starting archived log restore to default destination
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: restoring archived log
archived log thread=2 sequence=123
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 20-JAN-18

datafile 1 switched to datafile copy
input datafile copy RECID=23 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/system.317.962209603
datafile 3 switched to datafile copy
input datafile copy RECID=24 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=25 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 5 switched to datafile copy
input datafile copy RECID=26 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/system.256.962209675
datafile 6 switched to datafile copy
input datafile copy RECID=27 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 7 switched to datafile copy
input datafile copy RECID=28 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/users.301.962209605
datafile 8 switched to datafile copy
input datafile copy RECID=29 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=30 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 10 switched to datafile copy
input datafile copy RECID=31 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/system.271.962209649
datafile 11 switched to datafile copy
input datafile copy RECID=32 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=33 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=34 STAMP=965848768 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=35 STAMP=965848769 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 16 switched to datafile copy
input datafile copy RECID=36 STAMP=965848769 file name=/u01/app/oracle/oradata/dupjy/system.260.962469409
datafile 17 switched to datafile copy
input datafile copy RECID=37 STAMP=965848769 file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409
datafile 18 switched to datafile copy
input datafile copy RECID=38 STAMP=965848769 file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
datafile 19 switched to datafile copy
input datafile copy RECID=39 STAMP=965848769 file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409
datafile 20 switched to datafile copy
input datafile copy RECID=40 STAMP=965848769 file name=/u01/app/oracle/oradata/dupjy/users.267.962469409
datafile 21 switched to datafile copy
input datafile copy RECID=41 STAMP=965848769 file name=/u01/app/oracle/oradata/dupjy/test.269.962469409

contents of Memory Script:
{
   set until scn  13197051;
   recover
   clone database
   skip forever tablespace  "JYPDB":"TEST"    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 20-JAN-18
using channel ORA_AUX_DISK_1

Executing: alter database datafile 15 offline drop
starting media recovery

archived log for thread 1 with sequence 146 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_146_961976319.dbf
archived log for thread 1 with sequence 147 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_147_961976319.dbf
archived log for thread 2 with sequence 122 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_122_961976319.dbf
archived log for thread 2 with sequence 123 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_123_961976319.dbf
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_146_961976319.dbf thread=1 sequence=146
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_122_961976319.dbf thread=2 sequence=122
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_123_961976319.dbf thread=2 sequence=123
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_147_961976319.dbf thread=1 sequence=147
media recovery complete, elapsed time: 00:00:04
Finished recover at 20-JAN-18
Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size                788532512 bytes
Database Buffers            1342177280 bytes
Redo Buffers                   7979008 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name =
 ''DUPJY'' 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 =  ''DUPJY'' 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    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size                788532512 bytes
Database Buffers            1342177280 bytes
Redo Buffers                   7979008 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUPJY" RESETLOGS ARCHIVELOG
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '/u01/app/oracle/oradata/dupjy/group_1.261.961976319' ) SIZE 200 M  REUSE,
  GROUP   2 ( '/u01/app/oracle/oradata/dupjy/group_2.302.961976321' ) SIZE 200 M  REUSE
 DATAFILE
  '/u01/app/oracle/oradata/dupjy/system.317.962209603',
  '/u01/app/oracle/oradata/dupjy/system.256.962209675',
  '/u01/app/oracle/oradata/dupjy/system.271.962209649',
  '/u01/app/oracle/oradata/dupjy/system.260.962469409'
 CHARACTER SET ZHS16GBK

sql statement: ALTER DATABASE ADD LOGFILE

  INSTANCE 'i2'
  GROUP   3 ( '/u01/app/oracle/oradata/dupjy/group_3.263.961976697' ) SIZE 200 M  REUSE,
  GROUP   4 ( '/u01/app/oracle/oradata/dupjy/group_4.262.961976705' ) SIZE 200 M  REUSE

contents of Memory Script:
{
   set newname for tempfile  1 to
 "+DATA";
   set newname for tempfile  2 to
 "+DATA";
   set newname for tempfile  3 to
 "+DATA";
   set newname for tempfile  4 to
 "+DATA";
   switch clone tempfile all;
   catalog clone datafilecopy  "/u01/app/oracle/oradata/dupjy/sysaux.298.962209605",
 "/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605",
 "/u01/app/oracle/oradata/dupjy/sysaux.270.962209675",
 "/u01/app/oracle/oradata/dupjy/users.301.962209605",
 "/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675",
 "/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605",
 "/u01/app/oracle/oradata/dupjy/sysaux.316.962209649",
 "/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649",
 "/u01/app/oracle/oradata/dupjy/undo_2.268.962209649",
 "/u01/app/oracle/oradata/dupjy/users.278.962209649",
 "/u01/app/oracle/oradata/dupjy/sysaux.259.962469409",
 "/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409",
 "/u01/app/oracle/oradata/dupjy/undo_2.266.962469409",
 "/u01/app/oracle/oradata/dupjy/users.267.962469409",
 "/u01/app/oracle/oradata/dupjy/test.269.962469409";
   switch clone datafile all;
}
executing Memory Script

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to +DATA in control file
renamed tempfile 2 to +DATA in control file
renamed tempfile 3 to +DATA in control file
renamed tempfile 4 to +DATA in control file

cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605 RECID=1 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605 RECID=2 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675 RECID=3 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.301.962209605 RECID=4 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675 RECID=5 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605 RECID=6 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649 RECID=7 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649 RECID=8 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649 RECID=9 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.278.962209649 RECID=10 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409 RECID=11 STAMP=965848805
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409 RECID=12 STAMP=965848806
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409 RECID=13 STAMP=965848806
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.267.962469409 RECID=14 STAMP=965848806
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.269.962469409 RECID=15 STAMP=965848806

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 7 switched to datafile copy
input datafile copy RECID=4 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/users.301.962209605
datafile 8 switched to datafile copy
input datafile copy RECID=5 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=6 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 11 switched to datafile copy
input datafile copy RECID=7 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=8 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=9 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=10 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 17 switched to datafile copy
input datafile copy RECID=11 STAMP=965848805 file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409
datafile 18 switched to datafile copy
input datafile copy RECID=12 STAMP=965848806 file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
datafile 19 switched to datafile copy
input datafile copy RECID=13 STAMP=965848806 file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409
datafile 20 switched to datafile copy
input datafile copy RECID=14 STAMP=965848806 file name=/u01/app/oracle/oradata/dupjy/users.267.962469409
datafile 21 switched to datafile copy
input datafile copy RECID=15 STAMP=965848806 file name=/u01/app/oracle/oradata/dupjy/test.269.962469409

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
Dropping offline and skipped tablespaces
Executing: drop tablespace "TEST" including contents cascade constraints
Finished Duplicate Db at 20-JAN-18

12.检查目标数据库中是否不存在表空间jypdb:test

[oracle@shard1 arch_dupjy]$ export ORACLE_SID=dupjy
[oracle@shard1 arch_dupjy]$ rman target/

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Jan 19 19:21:01 2018

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

connected to target database: DUPJY (DBID=1349214878)

RMAN> report schema;

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

List of Permanent Datafiles
===========================
File Size(MB) Tablespace           RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1    840      SYSTEM               YES     /u01/app/oracle/oradata/dupjy/system.317.962209603
3    2210     SYSAUX               NO      /u01/app/oracle/oradata/dupjy/sysaux.298.962209605
4    570      UNDOTBS1             YES     /u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
5    250      PDB$SEED:SYSTEM      NO      /u01/app/oracle/oradata/dupjy/system.256.962209675
6    340      PDB$SEED:SYSAUX      NO      /u01/app/oracle/oradata/dupjy/sysaux.270.962209675
7    5        USERS                NO      /u01/app/oracle/oradata/dupjy/users.301.962209605
8    100      PDB$SEED:UNDOTBS1    NO      /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
9    150      UNDOTBS2             YES     /u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
10   270      JYPDB:SYSTEM         YES     /u01/app/oracle/oradata/dupjy/system.271.962209649
11   590      JYPDB:SYSAUX         NO      /u01/app/oracle/oradata/dupjy/sysaux.316.962209649
12   100      JYPDB:UNDOTBS1       YES     /u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
13   100      JYPDB:UNDO_2         YES     /u01/app/oracle/oradata/dupjy/undo_2.268.962209649
14   1267     JYPDB:USERS          NO      /u01/app/oracle/oradata/dupjy/users.278.962209649
16   260      TESTPDB:SYSTEM       YES     /u01/app/oracle/oradata/dupjy/system.260.962469409
17   550      TESTPDB:SYSAUX       NO      /u01/app/oracle/oradata/dupjy/sysaux.259.962469409
18   100      TESTPDB:UNDOTBS1     YES     /u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
19   100      TESTPDB:UNDO_2       YES     /u01/app/oracle/oradata/dupjy/undo_2.266.962469409
20   5        TESTPDB:USERS        NO      /u01/app/oracle/oradata/dupjy/users.267.962469409
21   100      TESTPDB:TEST         NO      /u01/app/oracle/oradata/dupjy/test.269.962469409

List of Temporary Files
=======================
File Size(MB) Tablespace           Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
1    144      TEMP                 32767       +DATA
2    64       PDB$SEED:TEMP        32767       +DATA
3    137      JYPDB:TEMP           32767       +DATA
4    135      TESTPDB:TEMP         32767       +DATA

到此复制整个RAC CDB数据库(跳过表空间jypdb:test)为单实例CDB数据库完成

Oracle 12C使用RMAN将PDB中分表的多个分区恢复到新用户方案中

Oracle 12C使用RMAN将PDB中分表的多个分区恢复到新用户方案中的操作如下
1.对整个CDB(jy)生成RMAN备份

[oracle@jytest1 ~]$ rman target/ catalog rco/abcd@jypdb_173

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Jan 11 00:43:42 2018

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

connected to target database: JY (DBID=979425723)
connected to recovery catalog database

RMAN> backup as compressed backupset database format '+test/rman_backup/%d_%I_%U_%t' plus archivelog format '+test/rman_backup/arc_%d_%T_%U';


Starting backup at 2018-01-11 00:43:49
current log archived
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=393 instance=jy1 device type=DISK
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=2 sequence=70 RECID=184 STAMP=965090640
input archived log thread=1 sequence=95 RECID=183 STAMP=965090635
channel ORA_DISK_1: starting piece 1 at 2018-01-11 00:44:03
channel ORA_DISK_1: finished piece 1 at 2018-01-11 00:44:18
piece handle=+TEST/rman_backup/arc_jy_20180111_18soc7aj_1_1 tag=TAG20180111T004402 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 2018-01-11 00:44:18

Starting backup at 2018-01-11 00:44:18
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/JY/DATAFILE/sysaux.298.962209605
input datafile file number=00001 name=+DATA/JY/DATAFILE/system.317.962209603
input datafile file number=00004 name=+DATA/JY/DATAFILE/undotbs1.277.962209605
input datafile file number=00009 name=+DATA/JY/DATAFILE/undotbs2.312.962209605
input datafile file number=00007 name=+DATA/JY/DATAFILE/users.301.962209605
channel ORA_DISK_1: starting piece 1 at 2018-01-11 00:44:20
channel ORA_DISK_1: finished piece 1 at 2018-01-11 00:46:05
piece handle=+TEST/rman_backup/jy_979425723_19soc7b4_1_1_965090660 tag=TAG20180111T004418 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
input datafile file number=00011 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
input datafile file number=00010 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
input datafile file number=00012 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
input datafile file number=00013 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
input datafile file number=00015 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
channel ORA_DISK_1: starting piece 1 at 2018-01-11 00:46:06
channel ORA_DISK_1: finished piece 1 at 2018-01-11 00:47:01
piece handle=+TEST/rman_backup/jy_979425723_1asoc7ee_1_1_965090766 tag=TAG20180111T004418 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00016 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00018 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00019 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00021 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00020 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 2018-01-11 00:47:01
channel ORA_DISK_1: finished piece 1 at 2018-01-11 00:47:46
piece handle=+TEST/rman_backup/jy_979425723_1bsoc7g5_1_1_965090821 tag=TAG20180111T004418 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
input datafile file number=00005 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
input datafile file number=00008 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
channel ORA_DISK_1: starting piece 1 at 2018-01-11 00:47:47
channel ORA_DISK_1: finished piece 1 at 2018-01-11 00:48:32
piece handle=+TEST/rman_backup/jy_979425723_1csoc7hj_1_1_965090867 tag=TAG20180111T004418 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 2018-01-11 00:48:32

Starting backup at 2018-01-11 00:48:32
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=96 RECID=185 STAMP=965090913
input archived log thread=2 sequence=71 RECID=186 STAMP=965090913
channel ORA_DISK_1: starting piece 1 at 2018-01-11 00:48:37
channel ORA_DISK_1: finished piece 1 at 2018-01-11 00:48:38
piece handle=+TEST/rman_backup/arc_jy_20180111_1dsoc7j5_1_1 tag=TAG20180111T004835 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 2018-01-11 00:48:38

Starting Control File and SPFILE Autobackup at 2018-01-11 00:48:38
piece handle=+TEST/rman_backup/c-979425723-20180111-00 comment=NONE
Finished Control File and SPFILE Autobackup at 2018-01-11 00:48:46

2.在删除表sh.sales的SALES_Q3_1998与SALES_Q4_1998分区中的数据之前记录当前时间,在执行恢复时它们被用来指定恢复时间点

SQL>  alter session set nls_date_format='yyyy-mm-dd hh24:mi:ss';

Session altered.

SQL> select count(*) from sales partition(SALES_Q3_1998);

  COUNT(*)
----------
     50515

SQL> select count(*) from sales partition(SALES_Q4_1998);

  COUNT(*)
----------
     48874

SQL> select sysdate from dual;

SYSDATE
-------------------
2018-01-11 01:03:47

SQL> select current_scn   from v$database;

CURRENT_SCN
-----------
    8629695

SQL> delete from sales partition(SALES_Q3_1998);

50515 rows deleted.

SQL> delete from sales partition(SALES_Q4_1998);

48874 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(*) from sales partition(SALES_Q3_1998);

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

SQL> select count(*) from sales partition(SALES_Q4_1998);

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

3.启动RMAN并使用有sysbacup或sysdba权限的用户连接到目标数据库

[oracle@jytest1 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
[oracle@jytest1 ~]$ rman target/ catalog rco/abcd@jypdb_173

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jan 10 02:22:13 2018

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

connected to target database: ORCL (DBID=1492772871)

4.通过使用recover table命令将要被恢复的表或表分区恢复到指定的时间点。 使用auxiliary destination子句(/run/recover辅助数据文件存储目录)与until scn来指定恢复时间点,并且在recover命令中使用子句dump file与datapump destination,指定包含被恢复表或表分区的导出dump文件的文件名(t_emp_recvr.dmp)与存储位置(/run/dump)。 使用remap table子句将分区SH.SALES:SALES_Q3_1998恢复成表JY.SALES_Q3_1998,分区 SH.SALES:SALES_Q4_1998恢复成表JY.SALES_Q4_1998使用remap tablespace子句将sh用户方案中的表分区从表空间users恢复到表空间test中

RMAN> run
2> {
3> recover table SH.SALES:SALES_Q3_1998, SH.SALES:SALES_Q4_1998 of pluggable database jypdb
4> until time '2018-01-11 01:03:47'
5> auxiliary destination '/run/recover'
6> datapump destination '/run/dump'
7> dump file 't_emp_recvr.dmp'
8> remap table SH.SALES:SALES_Q3_1998:JY.SALES_Q3_1998,SH.SALES:SALES_Q4_1998:JY.SALES_Q4_1998
9> remap tablespace 'USERS':'TEST';
10> }

Starting recover at 2018-01-11 01:46:51
using channel ORA_DISK_1

Creating automatic instance, with SID='lCEx'

initialization parameters used for automatic instance:
db_name=JY
db_unique_name=lCEx_pitr_jypdb_JY
compatible=12.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=2048M
processes=200
db_create_file_dest=/run/recover
log_archive_dest_1='location=/run/recover'
enable_pluggable_database=true
_clone_one_pdb_recovery=true
#No auxiliary parameter file used


starting up automatic instance JY

Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size                553651488 bytes
Database Buffers            1577058304 bytes
Redo Buffers                   7979008 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 01:03:47";
# 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';
# resync catalog
resync catalog;
}
executing Memory Script

executing command: SET until clause

Starting restore at 2018-01-11 01:47:37
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=211 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 +TEST/rman_backup/c-979425723-20180111-00
channel ORA_AUX_DISK_1: piece handle=+TEST/rman_backup/c-979425723-20180111-00 tag=TAG20180111T004839
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:05
output file name=/run/recover/JY/controlfile/o1_mf_f5dnfy2z_.ctl
Finished restore at 2018-01-11 01:47:43

sql statement: alter database mount clone database

sql statement: alter system archive log current

starting full resync of recovery catalog
full resync complete

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 01:03:47";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  10 to new;
set newname for clone datafile  1 to new;
set newname for clone datafile  12 to new;
set newname for clone datafile  4 to new;
set newname for clone datafile  13 to new;
set newname for clone datafile  9 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  11 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  10, 1, 12, 4, 13, 9, 3, 11;

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

executing command: SET NEWNAME

executing command: SET NEWNAME

executing command: SET NEWNAME

renamed tempfile 1 to /run/recover/JY/datafile/o1_mf_temp_%u_.tmp in control file
renamed tempfile 3 to /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_temp_%u_.tmp in control file

Starting restore at 2018-01-11 01:47:55
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 /run/recover/JY/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00004 to /run/recover/JY/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00009 to /run/recover/JY/datafile/o1_mf_undotbs2_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /run/recover/JY/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_19soc7b4_1_1_965090660
channel ORA_AUX_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_19soc7b4_1_1_965090660 tag=TAG20180111T004418
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:55
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 00010 to /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00012 to /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00013 to /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_undo_2_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00011 to /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_1asoc7ee_1_1_965090766
channel ORA_AUX_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_1asoc7ee_1_1_965090766 tag=TAG20180111T004418
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 2018-01-11 01:50:35

datafile 10 switched to datafile copy
input datafile copy RECID=12 STAMP=965094635 file name=/run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_system_f5dnkync_.dbf
datafile 1 switched to datafile copy
input datafile copy RECID=13 STAMP=965094635 file name=/run/recover/JY/datafile/o1_mf_system_f5dngcjj_.dbf
datafile 12 switched to datafile copy
input datafile copy RECID=14 STAMP=965094635 file name=/run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_undotbs1_f5dnkynd_.dbf
datafile 4 switched to datafile copy
input datafile copy RECID=15 STAMP=965094635 file name=/run/recover/JY/datafile/o1_mf_undotbs1_f5dngcjk_.dbf
datafile 13 switched to datafile copy
input datafile copy RECID=16 STAMP=965094635 file name=/run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_undo_2_f5dnkynd_.dbf
datafile 9 switched to datafile copy
input datafile copy RECID=17 STAMP=965094635 file name=/run/recover/JY/datafile/o1_mf_undotbs2_f5dngcjl_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=18 STAMP=965094635 file name=/run/recover/JY/datafile/o1_mf_sysaux_f5dngcjh_.dbf
datafile 11 switched to datafile copy
input datafile copy RECID=19 STAMP=965094635 file name=/run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_sysaux_f5dnkynb_.dbf

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 01:03:47";
# online the datafiles restored or switched
sql clone 'JYPDB' "alter database datafile
 10 online";
sql clone "alter database datafile  1 online";
sql clone 'JYPDB' "alter database datafile
 12 online";
sql clone "alter database datafile  4 online";
sql clone 'JYPDB' "alter database datafile
 13 online";
sql clone "alter database datafile  9 online";
sql clone "alter database datafile  3 online";
sql clone 'JYPDB' "alter database datafile
 11 online";
# recover and open database read only
recover clone database tablespace  "JYPDB":"SYSTEM", "SYSTEM", "JYPDB":"UNDOTBS1", "UNDOTBS1", "JYPDB":"UNDO_2", "UNDOTBS2", "SYSAUX", "JYPDB":"SYSAUX";
sql clone 'alter database open read only';
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  10 online

sql statement: alter database datafile  1 online

sql statement: alter database datafile  12 online

sql statement: alter database datafile  4 online

sql statement: alter database datafile  13 online

sql statement: alter database datafile  9 online

sql statement: alter database datafile  3 online

sql statement: alter database datafile  11 online

Starting recover at 2018-01-11 01:50:36
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 96 is already on disk as file +TEST/arch/1_96_961976319.dbf
archived log for thread 1 with sequence 97 is already on disk as file +TEST/arch/1_97_961976319.dbf
archived log for thread 2 with sequence 71 is already on disk as file +TEST/arch/2_71_961976319.dbf
archived log for thread 2 with sequence 72 is already on disk as file +TEST/arch/2_72_961976319.dbf
archived log file name=+TEST/arch/1_96_961976319.dbf thread=1 sequence=96
archived log file name=+TEST/arch/2_71_961976319.dbf thread=2 sequence=71
archived log file name=+TEST/arch/1_97_961976319.dbf thread=1 sequence=97
archived log file name=+TEST/arch/2_72_961976319.dbf thread=2 sequence=72
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018-01-11 01:50:39

sql statement: alter database open read only

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

sql statement: alter pluggable database  JYPDB 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 =
  ''/run/recover/JY/controlfile/o1_mf_f5dnfy2z_.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    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size                553651488 bytes
Database Buffers            1577058304 bytes
Redo Buffers                   7979008 bytes

sql statement: alter system set  control_files =   ''/run/recover/JY/controlfile/o1_mf_f5dnfy2z_.ctl'' comment= ''RMAN set'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size                553651488 bytes
Database Buffers            1577058304 bytes
Redo Buffers                   7979008 bytes

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 01:03:47";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile  14 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  14;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 2018-01-11 01:51:49
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=211 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 00014 to /run/recover/LCEX_PITR_JYPDB_JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +TEST/rman_backup/jy_979425723_1asoc7ee_1_1_965090766
channel ORA_AUX_DISK_1: piece handle=+TEST/rman_backup/jy_979425723_1asoc7ee_1_1_965090766 tag=TAG20180111T004418
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:49
Finished restore at 2018-01-11 01:52:39

datafile 14 switched to datafile copy
input datafile copy RECID=21 STAMP=965094759 file name=/run/recover/LCEX_PITR_JYPDB_JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_users_f5dnot2n_.dbf

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 01:03:47";
# online the datafiles restored or switched
sql clone 'JYPDB' "alter database datafile
 14 online";
# recover and open resetlogs
recover clone database tablespace  "JYPDB":"USERS", "JYPDB":"SYSTEM", "SYSTEM", "JYPDB":"UNDOTBS1", "UNDOTBS1", "JYPDB":"UNDO_2", "UNDOTBS2", "SYSAUX", "JYPDB":"SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  14 online

Starting recover at 2018-01-11 01:52:39
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 96 is already on disk as file +TEST/arch/1_96_961976319.dbf
archived log for thread 1 with sequence 97 is already on disk as file +TEST/arch/1_97_961976319.dbf
archived log for thread 2 with sequence 71 is already on disk as file +TEST/arch/2_71_961976319.dbf
archived log for thread 2 with sequence 72 is already on disk as file +TEST/arch/2_72_961976319.dbf
archived log file name=+TEST/arch/1_96_961976319.dbf thread=1 sequence=96
archived log file name=+TEST/arch/2_71_961976319.dbf thread=2 sequence=71
archived log file name=+TEST/arch/1_97_961976319.dbf thread=1 sequence=97
archived log file name=+TEST/arch/2_72_961976319.dbf thread=2 sequence=72
media recovery complete, elapsed time: 00:00:01
Finished recover at 2018-01-11 01:52:42

database opened

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

sql statement: alter pluggable database  JYPDB open

contents of Memory Script:
{
# create directory for datapump import
sql 'JYPDB' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/run/dump''";
# create directory for datapump export
sql clone 'JYPDB' "create or replace directory
TSPITR_DIROBJ_DPDIR as ''
/run/dump''";
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/run/dump''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/run/dump''

Performing export of tables...
   EXPDP> Starting "SYS"."TSPITR_EXP_lCEx_rDzp":
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   EXPDP> Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
   EXPDP> Processing object type TABLE_EXPORT/TABLE/COMMENT
   EXPDP> . . exported "SH"."SALES":"SALES_Q3_1998"                1.634 MB   50515 rows
   EXPDP> . . exported "SH"."SALES":"SALES_Q4_1998"                1.581 MB   48874 rows
   EXPDP> Master table "SYS"."TSPITR_EXP_lCEx_rDzp" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_lCEx_rDzp is:
   EXPDP>   /run/dump/t_emp_recvr.dmp
   EXPDP> Job "SYS"."TSPITR_EXP_lCEx_rDzp" successfully completed at Thu Jan 11 01:53:35 2018 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

Performing import of tables...
   IMPDP> Master table "SYS"."TSPITR_IMP_lCEx_pFDE" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_lCEx_pFDE":
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   IMPDP> . . imported "JY"."SALES_Q3_1998"                        1.634 MB   50515 rows
   IMPDP> . . imported "JY"."SALES_Q4_1998"                        1.581 MB   48874 rows
   IMPDP> Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
   IMPDP> ORA-39083: Object type OBJECT_GRANT failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
GRANT SELECT ON "JY"."SALES" TO "BI"

   IMPDP> Processing object type TABLE_EXPORT/TABLE/COMMENT
   IMPDP> ORA-39083: Object type COMMENT failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON TABLE "JY"."SALES"  IS 'facts table, without a primary key; all rows are uniquely identified by the combination of all foreign keys'

ORA-39083: Object type COMMENT:"PROD_ID" failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON COLUMN "JY"."SALES"."PROD_ID" IS 'FK to the products dimension table'

ORA-39083: Object type COMMENT:"CUST_ID" failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON COLUMN "JY"."SALES"."CUST_ID" IS 'FK to the customers dimension table'

ORA-39083: Object type COMMENT:"TIME_ID" failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON COLUMN "JY"."SALES"."TIME_ID" IS 'FK to the times dimension table'

ORA-39083: Object type COMMENT:"CHANNEL_ID" failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON COLUMN "JY"."SALES"."CHANNEL_ID" IS 'FK to the channels dimension table'

ORA-39083: Object type COMMENT:"PROMO_ID" failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON COLUMN "JY"."SALES"."PROMO_ID" IS 'promotion identifier, without FK constraint (intentionally) to show outer join optimization'

ORA-39083: Object type COMMENT:"QUANTITY_SOLD" failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON COLUMN "JY"."SALES"."QUANTITY_SOLD" IS 'product quantity sold with the transaction'

ORA-39083: Object type COMMENT:"AMOUNT_SOLD" failed to create with error:
ORA-00942: table or view does not exist

Failing sql is:
 COMMENT ON COLUMN "JY"."SALES"."AMOUNT_SOLD" IS 'invoiced amount to the customer'

   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   IMPDP> Job "SYS"."TSPITR_IMP_lCEx_pFDE" completed with 9 error(s) at Thu Jan 11 01:55:38 2018 elapsed 0 00:01:38
import completed with errors; Oracle Data Pump dump file t_emp_recvr.dmp is retained

Removing automatic instance
Automatic instance removed
auxiliary instance file /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_temp_f5dnmkjx_.tmp deleted
auxiliary instance file /run/recover/JY/datafile/o1_mf_temp_f5dnmj7f_.tmp deleted
auxiliary instance file /run/recover/LCEX_PITR_JYPDB_JY/onlinelog/o1_mf_4_f5dnqbjt_.log deleted
auxiliary instance file /run/recover/LCEX_PITR_JYPDB_JY/onlinelog/o1_mf_3_f5dnqbhs_.log deleted
auxiliary instance file /run/recover/LCEX_PITR_JYPDB_JY/onlinelog/o1_mf_2_f5dnqbh8_.log deleted
auxiliary instance file /run/recover/LCEX_PITR_JYPDB_JY/onlinelog/o1_mf_1_f5dnqbgj_.log deleted
auxiliary instance file /run/recover/LCEX_PITR_JYPDB_JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_users_f5dnot2n_.dbf deleted
auxiliary instance file /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_sysaux_f5dnkynb_.dbf deleted
auxiliary instance file /run/recover/JY/datafile/o1_mf_sysaux_f5dngcjh_.dbf deleted
auxiliary instance file /run/recover/JY/datafile/o1_mf_undotbs2_f5dngcjl_.dbf deleted
auxiliary instance file /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_undo_2_f5dnkynd_.dbf deleted
auxiliary instance file /run/recover/JY/datafile/o1_mf_undotbs1_f5dngcjk_.dbf deleted
auxiliary instance file /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_undotbs1_f5dnkynd_.dbf deleted
auxiliary instance file /run/recover/JY/datafile/o1_mf_system_f5dngcjj_.dbf deleted
auxiliary instance file /run/recover/JY/5F9AC6865E87549FE053AB828A0ADE94/datafile/o1_mf_system_f5dnkync_.dbf deleted
auxiliary instance file /run/recover/JY/controlfile/o1_mf_f5dnfy2z_.ctl deleted
Finished recover at 2018-01-11 01:55:46
starting full resync of recovery catalog
full resync complete
5.验证是否分区SH.SALES:SALES_Q3_1998被恢复成表JY.SALES_Q3_1998,分区SH.SALES:SALES_Q4_1998被恢复成表JY.SALES_Q4_1998,从查询记录可以看到已经成功恢复
SQL> select count(*) from JY.SALES_Q3_1998;

  COUNT(*)
----------
     50515

SQL> select count(*) from JY.SALES_Q4_1998;

  COUNT(*)
----------
     48874

Oracle 12C使用RMAN将Non-CDB中分表的多个分区恢复到新用户方案中

Oracle 12C使用RMAN将Non-CDB中分表的多个分区恢复到新用户方案中的操作如下
1.对整个Non-CDB(orcl)生成RMAN备份

RMAN> backup as compressed backupset database format '+data/backup/%d_%I_%U_%t' plus archivelog format 'arc_%d_%T_%U';

Starting backup at 10-JAN-18
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=13 RECID=1 STAMP=964995986
input archived log thread=1 sequence=14 RECID=2 STAMP=965007422
input archived log thread=1 sequence=15 RECID=3 STAMP=965007493
input archived log thread=1 sequence=16 RECID=4 STAMP=965007542
input archived log thread=1 sequence=17 RECID=5 STAMP=965011311
input archived log thread=1 sequence=18 RECID=6 STAMP=965011687
channel ORA_DISK_1: starting piece 1 at 10-JAN-18
channel ORA_DISK_1: finished piece 1 at 10-JAN-18
piece handle=/u01/app/oracle/product/12.2.0/db/dbs/arc_ORCL_20180110_21so9q78_1_1 tag=TAG20180110T024807 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 10-JAN-18

Starting backup at 10-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=+DATA/orcl/datafile/users01.dbf
input datafile file number=00001 name=+DATA/orcl/datafile/system01.dbf
input datafile file number=00002 name=+DATA/orcl/datafile/sysaux01.dbf
input datafile file number=00003 name=+DATA/orcl/datafile/undotbs01.dbf
input datafile file number=00005 name=+DATA/orcl/datafile/usertbs01.dbf
channel ORA_DISK_1: starting piece 1 at 10-JAN-18
channel ORA_DISK_1: finished piece 1 at 10-JAN-18
piece handle=+DATA/backup/orcl_1492772871_22so9q7p_1_1_965011705 tag=TAG20180110T024824 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 10-JAN-18

Starting backup at 10-JAN-18
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=19 RECID=7 STAMP=965011751
channel ORA_DISK_1: starting piece 1 at 10-JAN-18
channel ORA_DISK_1: finished piece 1 at 10-JAN-18
piece handle=/u01/app/oracle/product/12.2.0/db/dbs/arc_ORCL_20180110_23so9q98_1_1 tag=TAG20180110T024912 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-JAN-18

Starting Control File and SPFILE Autobackup at 10-JAN-18
piece handle=+DATA/backup/c-1492772871-20180110-01 comment=NONE
Finished Control File and SPFILE Autobackup at 10-JAN-18

2.在删除表sh.sales的SALES_Q3_1998与SALES_Q4_1998分区中的数据之前记录当前时间,在执行恢复时它们被用来指定恢复时间点

SQL> select count(*) from sales partition(SALES_Q3_1998);

  COUNT(*)
----------
     50515

1 row selected.

SQL> select count(*) from sales partition(SALES_Q4_1998);

  COUNT(*)
----------
     48874

1 row selected.

SQL> select sysdate from dual;

SYSDATE
-------------------
2018-01-11 03:11:06

1 row selected.

SQL> select current_scn   from v$database;

CURRENT_SCN
-----------
     525382

SQL> delete from sales partition(SALES_Q3_1998);

50515 rows deleted.

SQL> delete from sales partition(SALES_Q4_1998);

48874 rows deleted.

SQL> commit;

Commit complete.

SQL> select count(*) from sales partition(SALES_Q3_1998);

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

1 row selected.

SQL> select count(*) from sales partition(SALES_Q4_1998);

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

1 row selected.

3.启动RMAN并使用有sysbacup或sysdba权限的用户连接到目标数据库

[oracle@jytest3 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
[oracle@jytest3 ~]$ rman target/

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jan 10 02:22:13 2018

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

connected to target database: ORCL (DBID=1492772871)

4.通过使用recover table命令将要被恢复的表或表分区恢复到指定的时间点。 使用auxiliary destination子句(/ora_xtts/recover辅助数据文件存储目录)与until scn来指定恢复时间点,并且在recover命令中使用子句 dump file与datapump destination,指定包含被恢复表或表分区的导出dump文件的文件名(t_emp_recvr.dmp)与存储位置(/ora_xtts/dump)。 使用remap table子句将分区SH.SALES:SALES_Q3_1998恢复成表 JY.SALES_Q3_1998,分区SH.SALES:SALES_Q4_1998恢复成表JY.SALES_Q4_1998使用remap tablespace子句将sh用户方案中的表分区从user表空间恢复到usertbs表空间中

RMAN> run
{
2> 3> recover table SH.SALES:SALES_Q3_1998, SH.SALES:SALES_Q4_1998
4> until time '2018-01-11 03:11:06'
5> auxiliary destination '/ora_xtts/recover'
6> datapump destination '/ora_xtts/dump'
7> dump file 't_emp_recvr.dmp'
8> remap table SH.SALES:SALES_Q3_1998:JY.SALES_Q3_1998,SH.SALES:SALES_Q4_1998:JY.SALES_Q4_1998
9> remap tablespace 'USERS':'USERTBS';
10> }

Starting recover at 2018-01-11 03:21:12
using channel ORA_DISK_1
RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time

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

Creating automatic instance, with SID='xDyx'

initialization parameters used for automatic instance:
db_name=ORCL
db_unique_name=xDyx_pitr_ORCL
compatible=12.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=1024M
processes=120
db_create_file_dest=/ora_xtts/recover
log_archive_dest_1='location=/ora_xtts/recover'
#No auxiliary parameter file used


starting up automatic instance ORCL

Oracle instance started

Total System Global Area    1073741824 bytes

Fixed Size                     8628936 bytes
Variable Size                293602616 bytes
Database Buffers             763363328 bytes
Redo Buffers                   8146944 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 03:11:06";
# 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 2018-01-11 03:22:20
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=6 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 +DATA/backup/c-1492772871-20180110-02
channel ORA_AUX_DISK_1: piece handle=+DATA/backup/c-1492772871-20180110-02 tag=TAG20180110T200959
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:05
output file name=/ora_xtts/recover/ORCL/controlfile/o1_mf_f5dszl5f_.ctl
Finished restore at 2018-01-11 03:22:27

sql statement: alter database mount clone database

sql statement: alter system archive log current

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 03:11:06";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  2 to new;
set newname for clone tempfile  1 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 3, 2;

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

renamed tempfile 1 to /ora_xtts/recover/ORCL/datafile/o1_mf_tempts1_%u_.tmp in control file

Starting restore at 2018-01-11 03:22:34
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 /ora_xtts/recover/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /ora_xtts/recover/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /ora_xtts/recover/ORCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +DATA/backup/orcl_1492772871_26sobn77_1_1_965074151
channel ORA_AUX_DISK_1: piece handle=+DATA/backup/orcl_1492772871_26sobn77_1_1_965074151 tag=TAG20180110T200911
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 2018-01-11 03:23:20

datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=965100201 file name=/ora_xtts/recover/ORCL/datafile/o1_mf_system_f5dszvs1_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=965100201 file name=/ora_xtts/recover/ORCL/datafile/o1_mf_undotbs1_f5dszvt5_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=965100201 file name=/ora_xtts/recover/ORCL/datafile/o1_mf_sysaux_f5dszvsm_.dbf

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 03:11:06";
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  3 online";
sql clone "alter database datafile  2 online";
# recover and open database read only
recover clone database tablespace  "SYSTEM", "UNDOTBS1", "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  3 online

sql statement: alter database datafile  2 online

Starting recover at 2018-01-11 03:23:22
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 24 is already on disk as file +DATA/arch/orcl/1_24_964992135.dbf
archived log for thread 1 with sequence 25 is already on disk as file +DATA/arch/orcl/1_25_964992135.dbf
archived log for thread 1 with sequence 26 is already on disk as file +DATA/arch/orcl/1_26_964992135.dbf
archived log for thread 1 with sequence 27 is already on disk as file +DATA/arch/orcl/1_27_964992135.dbf
archived log for thread 1 with sequence 28 is already on disk as file +DATA/arch/orcl/1_28_964992135.dbf
archived log for thread 1 with sequence 29 is already on disk as file +DATA/arch/orcl/1_29_964992135.dbf
archived log for thread 1 with sequence 30 is already on disk as file +DATA/arch/orcl/1_30_964992135.dbf
archived log for thread 1 with sequence 31 is already on disk as file +DATA/arch/orcl/1_31_964992135.dbf
archived log for thread 1 with sequence 32 is already on disk as file +DATA/arch/orcl/1_32_964992135.dbf
archived log for thread 1 with sequence 33 is already on disk as file +DATA/arch/orcl/1_33_964992135.dbf
archived log for thread 1 with sequence 34 is already on disk as file +DATA/arch/orcl/1_34_964992135.dbf
archived log for thread 1 with sequence 35 is already on disk as file +DATA/arch/orcl/1_35_964992135.dbf
archived log file name=+DATA/arch/orcl/1_24_964992135.dbf thread=1 sequence=24
archived log file name=+DATA/arch/orcl/1_25_964992135.dbf thread=1 sequence=25
archived log file name=+DATA/arch/orcl/1_26_964992135.dbf thread=1 sequence=26
archived log file name=+DATA/arch/orcl/1_27_964992135.dbf thread=1 sequence=27
archived log file name=+DATA/arch/orcl/1_28_964992135.dbf thread=1 sequence=28
archived log file name=+DATA/arch/orcl/1_29_964992135.dbf thread=1 sequence=29
archived log file name=+DATA/arch/orcl/1_30_964992135.dbf thread=1 sequence=30
archived log file name=+DATA/arch/orcl/1_31_964992135.dbf thread=1 sequence=31
archived log file name=+DATA/arch/orcl/1_32_964992135.dbf thread=1 sequence=32
archived log file name=+DATA/arch/orcl/1_33_964992135.dbf thread=1 sequence=33
archived log file name=+DATA/arch/orcl/1_34_964992135.dbf thread=1 sequence=34
archived log file name=+DATA/arch/orcl/1_35_964992135.dbf thread=1 sequence=35
media recovery complete, elapsed time: 00:00:51
Finished recover at 2018-01-11 03:24:16

sql statement: alter database 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 =
  ''/ora_xtts/recover/ORCL/controlfile/o1_mf_f5dszl5f_.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    1073741824 bytes

Fixed Size                     8628936 bytes
Variable Size                293602616 bytes
Database Buffers             763363328 bytes
Redo Buffers                   8146944 bytes

sql statement: alter system set  control_files =   ''/ora_xtts/recover/ORCL/controlfile/o1_mf_f5dszl5f_.ctl'' comment= ''RMAN set'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1073741824 bytes

Fixed Size                     8628936 bytes
Variable Size                293602616 bytes
Database Buffers             763363328 bytes
Redo Buffers                   8146944 bytes

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 03:11:06";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile  4 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  4;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 2018-01-11 03:25:26
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=7 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 00004 to /ora_xtts/recover/XDYX_PITR_ORCL/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +DATA/backup/orcl_1492772871_26sobn77_1_1_965074151
channel ORA_AUX_DISK_1: piece handle=+DATA/backup/orcl_1492772871_26sobn77_1_1_965074151 tag=TAG20180110T200911
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:55
Finished restore at 2018-01-11 03:26:22

datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=965100383 file name=/ora_xtts/recover/XDYX_PITR_ORCL/datafile/o1_mf_users_f5dt57w8_.dbf

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-11 03:11:06";
# online the datafiles restored or switched
sql clone "alter database datafile  4 online";
# recover and open resetlogs
recover clone database tablespace  "USERS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  4 online

Starting recover at 2018-01-11 03:26:23
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 24 is already on disk as file +DATA/arch/orcl/1_24_964992135.dbf
archived log for thread 1 with sequence 25 is already on disk as file +DATA/arch/orcl/1_25_964992135.dbf
archived log for thread 1 with sequence 26 is already on disk as file +DATA/arch/orcl/1_26_964992135.dbf
archived log for thread 1 with sequence 27 is already on disk as file +DATA/arch/orcl/1_27_964992135.dbf
archived log for thread 1 with sequence 28 is already on disk as file +DATA/arch/orcl/1_28_964992135.dbf
archived log for thread 1 with sequence 29 is already on disk as file +DATA/arch/orcl/1_29_964992135.dbf
archived log for thread 1 with sequence 30 is already on disk as file +DATA/arch/orcl/1_30_964992135.dbf
archived log for thread 1 with sequence 31 is already on disk as file +DATA/arch/orcl/1_31_964992135.dbf
archived log for thread 1 with sequence 32 is already on disk as file +DATA/arch/orcl/1_32_964992135.dbf
archived log for thread 1 with sequence 33 is already on disk as file +DATA/arch/orcl/1_33_964992135.dbf
archived log for thread 1 with sequence 34 is already on disk as file +DATA/arch/orcl/1_34_964992135.dbf
archived log for thread 1 with sequence 35 is already on disk as file +DATA/arch/orcl/1_35_964992135.dbf
archived log file name=+DATA/arch/orcl/1_24_964992135.dbf thread=1 sequence=24
archived log file name=+DATA/arch/orcl/1_25_964992135.dbf thread=1 sequence=25
archived log file name=+DATA/arch/orcl/1_26_964992135.dbf thread=1 sequence=26
archived log file name=+DATA/arch/orcl/1_27_964992135.dbf thread=1 sequence=27
archived log file name=+DATA/arch/orcl/1_28_964992135.dbf thread=1 sequence=28
archived log file name=+DATA/arch/orcl/1_29_964992135.dbf thread=1 sequence=29
archived log file name=+DATA/arch/orcl/1_30_964992135.dbf thread=1 sequence=30
archived log file name=+DATA/arch/orcl/1_31_964992135.dbf thread=1 sequence=31
archived log file name=+DATA/arch/orcl/1_32_964992135.dbf thread=1 sequence=32
archived log file name=+DATA/arch/orcl/1_33_964992135.dbf thread=1 sequence=33
archived log file name=+DATA/arch/orcl/1_34_964992135.dbf thread=1 sequence=34
archived log file name=+DATA/arch/orcl/1_35_964992135.dbf thread=1 sequence=35
media recovery complete, elapsed time: 00:00:08
Finished recover at 2018-01-11 03:26:34

database opened

contents of Memory Script:
{
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/ora_xtts/dump''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/ora_xtts/dump''";
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/ora_xtts/dump''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/ora_xtts/dump''

Performing export of tables...
   EXPDP> Starting "SYS"."TSPITR_EXP_xDyx_nniA":
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   EXPDP> Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
   EXPDP> Processing object type TABLE_EXPORT/TABLE/COMMENT
   EXPDP> . . exported "SH"."SALES":"SALES_Q3_1998"                1.634 MB   50515 rows
   EXPDP> . . exported "SH"."SALES":"SALES_Q4_1998"                1.581 MB   48874 rows
   EXPDP> Master table "SYS"."TSPITR_EXP_xDyx_nniA" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_xDyx_nniA is:
   EXPDP>   /ora_xtts/dump/t_emp_recvr.dmp
   EXPDP> Job "SYS"."TSPITR_EXP_xDyx_nniA" successfully completed at Thu Jan 11 03:27:33 2018 elapsed 0 00:00:39
Export completed


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

Oracle instance shut down

Performing import of tables...
   IMPDP> Master table "SYS"."TSPITR_IMP_xDyx_xeDs" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_xDyx_xeDs":
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   IMPDP> . . imported "JY"."SALES_Q3_1998"                        1.634 MB   50515 rows
   IMPDP> . . imported "JY"."SALES_Q4_1998"                        1.581 MB   48874 rows
   IMPDP> Processing object type TABLE_EXPORT/TABLE/GRANT/OWNER_GRANT/OBJECT_GRANT
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   IMPDP> Job "SYS"."TSPITR_IMP_xDyx_xeDs" completed with 9 error(s) at Thu Jan 11 03:28:18 2018 elapsed 0 00:00:36
import completed with errors; Oracle Data Pump dump file t_emp_recvr.dmp is retained

Removing automatic instance
Automatic instance removed
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_tempts1_f5dt3146_.tmp deleted
auxiliary instance file /ora_xtts/recover/XDYX_PITR_ORCL/onlinelog/o1_mf_3_f5dt7brh_.log deleted
auxiliary instance file /ora_xtts/recover/XDYX_PITR_ORCL/onlinelog/o1_mf_2_f5dt7bqr_.log deleted
auxiliary instance file /ora_xtts/recover/XDYX_PITR_ORCL/onlinelog/o1_mf_1_f5dt7bq5_.log deleted
auxiliary instance file /ora_xtts/recover/XDYX_PITR_ORCL/datafile/o1_mf_users_f5dt57w8_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_sysaux_f5dszvsm_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_undotbs1_f5dszvt5_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_system_f5dszvs1_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/controlfile/o1_mf_f5dszl5f_.ctl deleted
Finished recover at 2018-01-11 03:28:22

5.验证是否分区SH.SALES:SALES_Q3_1998被恢复成表JY.SALES_Q3_1998,分区SH.SALES:SALES_Q4_1998被恢复成表JY.SALES_Q4_1998,从查询记录可以看到已经成功恢复

SQL> select count(*) from JY.SALES_Q3_1998;

  COUNT(*)
----------
     50515

SQL> select count(*) from JY.SALES_Q4_1998;

  COUNT(*)
----------
     48874

Oracle 12C使用RMAN将Non-CDB中多个用户方案中的多个表或表分区恢复到新用户方案中

Oracle 12C使用RMAN将Non-CDB中多个用户方案中的多个表或表分区恢复到新用户方案中的操作如下
1.对整个Non-CDB(orcl)生成RMAN备份

RMAN> backup as compressed backupset database format '+data/backup/%d_%I_%U_%t' plus archivelog format 'arc_%d_%T_%U';

Starting backup at 10-JAN-18
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=13 RECID=1 STAMP=964995986
input archived log thread=1 sequence=14 RECID=2 STAMP=965007422
input archived log thread=1 sequence=15 RECID=3 STAMP=965007493
input archived log thread=1 sequence=16 RECID=4 STAMP=965007542
input archived log thread=1 sequence=17 RECID=5 STAMP=965011311
input archived log thread=1 sequence=18 RECID=6 STAMP=965011687
channel ORA_DISK_1: starting piece 1 at 10-JAN-18
channel ORA_DISK_1: finished piece 1 at 10-JAN-18
piece handle=/u01/app/oracle/product/12.2.0/db/dbs/arc_ORCL_20180110_21so9q78_1_1 tag=TAG20180110T024807 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:15
Finished backup at 10-JAN-18

Starting backup at 10-JAN-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00004 name=+DATA/orcl/datafile/users01.dbf
input datafile file number=00001 name=+DATA/orcl/datafile/system01.dbf
input datafile file number=00002 name=+DATA/orcl/datafile/sysaux01.dbf
input datafile file number=00003 name=+DATA/orcl/datafile/undotbs01.dbf
input datafile file number=00005 name=+DATA/orcl/datafile/usertbs01.dbf
channel ORA_DISK_1: starting piece 1 at 10-JAN-18
channel ORA_DISK_1: finished piece 1 at 10-JAN-18
piece handle=+DATA/backup/orcl_1492772871_22so9q7p_1_1_965011705 tag=TAG20180110T024824 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:45
Finished backup at 10-JAN-18

Starting backup at 10-JAN-18
current log archived
using channel ORA_DISK_1
channel ORA_DISK_1: starting compressed archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=19 RECID=7 STAMP=965011751
channel ORA_DISK_1: starting piece 1 at 10-JAN-18
channel ORA_DISK_1: finished piece 1 at 10-JAN-18
piece handle=/u01/app/oracle/product/12.2.0/db/dbs/arc_ORCL_20180110_23so9q98_1_1 tag=TAG20180110T024912 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-JAN-18

Starting Control File and SPFILE Autobackup at 10-JAN-18
piece handle=+DATA/backup/c-1492772871-20180110-01 comment=NONE
Finished Control File and SPFILE Autobackup at 10-JAN-18

2.在删除表t_emp之前记录当前时间,在执行恢复时它们被用来指定恢复时间点

SQL> select count(*) from cs.t1;

  COUNT(*)
----------
         8

SQL> select count(*) from hr.t1;

  COUNT(*)
----------
         8

1 row selected.

SQL> select sysdate from dual;

SYSDATE
-------------------
2018-01-10 22:56:16

1 row selected.

SQL> truncate table cs.t1;

Table truncated.

SQL> truncate table hr.t1;

Table truncated.

SQL> select count(*) from cs.t1;

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

SQL> select count(*) from hr.t1;

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

3.启动RMAN并使用有sysbacup或sysdba权限的用户连接到目标数据库

[oracle@jytest3 ~]$ export NLS_DATE_FORMAT='yyyy-mm-dd hh24:mi:ss'
[oracle@jytest3 ~]$ rman target/

Recovery Manager: Release 12.2.0.1.0 - Production on Wed Jan 10 02:22:13 2018

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

connected to target database: ORCL (DBID=1492772871)

4.通过使用recover table命令将要被恢复的表或表分区恢复到指定的时间点。 使用auxiliary destination子句(/ora_xtts/recover辅助数据文件存储目录)与until scn来指定恢复时间点,并且在recover命令中使用子句 dump file与datapump destination,指定包含被恢复表或表分区的导出dump文件的文件名(t_emp_recvr.dmp)与存储位置(/ora_xtts/dump)。 使用remap table子句将hr.t1恢复成jy.t1_1,cs.t1恢复成jy.t1_2。使用remap tablespace子句将hr与cs用户方案中的表t1从表空间users恢复到表空间usertbs中

RMAN> run
2> {
3> recover table hr.t1,cs.t1
4> until time '2018-01-10 22:55:39'
5> auxiliary destination '/ora_xtts/recover'
6> datapump destination '/ora_xtts/dump'
7> dump file 't_emp_recvr.dmp'
8> remap table 'HR'.'T1':'JY'.'T1_1','CS'.'T1':'JY'.'T1_2'
9> remap tablespace 'USERS':'USERTBS';
10> }

Starting recover at 2018-01-10 23:26:43
current log archived
using channel ORA_DISK_1
RMAN-05026: warning: presuming following set of tablespaces applies to specified point-in-time

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

Creating automatic instance, with SID='fvtm'

initialization parameters used for automatic instance:
db_name=ORCL
db_unique_name=fvtm_pitr_ORCL
compatible=12.2.0
db_block_size=8192
db_files=200
diagnostic_dest=/u01/app/oracle
_system_trig_enabled=FALSE
sga_target=1024M
processes=120
db_create_file_dest=/ora_xtts/recover
log_archive_dest_1='location=/ora_xtts/recover'
#No auxiliary parameter file used


starting up automatic instance ORCL

Oracle instance started

Total System Global Area    1073741824 bytes

Fixed Size                     8628936 bytes
Variable Size                293602616 bytes
Database Buffers             763363328 bytes
Redo Buffers                   8146944 bytes
Automatic instance created

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-10 22:55:39";
# 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 2018-01-10 23:27:59
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=6 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 +DATA/backup/c-1492772871-20180110-02
channel ORA_AUX_DISK_1: piece handle=+DATA/backup/c-1492772871-20180110-02 tag=TAG20180110T200959
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:05
output file name=/ora_xtts/recover/ORCL/controlfile/o1_mf_f5dd84jp_.ctl
Finished restore at 2018-01-10 23:28:05

sql statement: alter database mount clone database

sql statement: alter system archive log current

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-10 22:55:39";
# set destinations for recovery set and auxiliary set datafiles
set newname for clone datafile  1 to new;
set newname for clone datafile  3 to new;
set newname for clone datafile  2 to new;
set newname for clone tempfile  1 to new;
# switch all tempfiles
switch clone tempfile all;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  1, 3, 2;

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

renamed tempfile 1 to /ora_xtts/recover/ORCL/datafile/o1_mf_tempts1_%u_.tmp in control file

Starting restore at 2018-01-10 23:28:15
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 /ora_xtts/recover/ORCL/datafile/o1_mf_system_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00003 to /ora_xtts/recover/ORCL/datafile/o1_mf_undotbs1_%u_.dbf
channel ORA_AUX_DISK_1: restoring datafile 00002 to /ora_xtts/recover/ORCL/datafile/o1_mf_sysaux_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +DATA/backup/orcl_1492772871_26sobn77_1_1_965074151
channel ORA_AUX_DISK_1: piece handle=+DATA/backup/orcl_1492772871_26sobn77_1_1_965074151 tag=TAG20180110T200911
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:45
Finished restore at 2018-01-10 23:29:02

datafile 1 switched to datafile copy
input datafile copy RECID=4 STAMP=965086142 file name=/ora_xtts/recover/ORCL/datafile/o1_mf_system_f5dd8k64_.dbf
datafile 3 switched to datafile copy
input datafile copy RECID=5 STAMP=965086142 file name=/ora_xtts/recover/ORCL/datafile/o1_mf_undotbs1_f5dd8k8j_.dbf
datafile 2 switched to datafile copy
input datafile copy RECID=6 STAMP=965086142 file name=/ora_xtts/recover/ORCL/datafile/o1_mf_sysaux_f5dd8k7d_.dbf

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-10 22:55:39";
# online the datafiles restored or switched
sql clone "alter database datafile  1 online";
sql clone "alter database datafile  3 online";
sql clone "alter database datafile  2 online";
# recover and open database read only
recover clone database tablespace  "SYSTEM", "UNDOTBS1", "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  3 online

sql statement: alter database datafile  2 online

Starting recover at 2018-01-10 23:29:03
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 24 is already on disk as file +DATA/arch/orcl/1_24_964992135.dbf
archived log for thread 1 with sequence 25 is already on disk as file +DATA/arch/orcl/1_25_964992135.dbf
archived log for thread 1 with sequence 26 is already on disk as file +DATA/arch/orcl/1_26_964992135.dbf
archived log for thread 1 with sequence 27 is already on disk as file +DATA/arch/orcl/1_27_964992135.dbf
archived log for thread 1 with sequence 28 is already on disk as file +DATA/arch/orcl/1_28_964992135.dbf
archived log for thread 1 with sequence 29 is already on disk as file +DATA/arch/orcl/1_29_964992135.dbf
archived log for thread 1 with sequence 30 is already on disk as file +DATA/arch/orcl/1_30_964992135.dbf
archived log for thread 1 with sequence 31 is already on disk as file +DATA/arch/orcl/1_31_964992135.dbf
archived log for thread 1 with sequence 32 is already on disk as file +DATA/arch/orcl/1_32_964992135.dbf
archived log file name=+DATA/arch/orcl/1_24_964992135.dbf thread=1 sequence=24
archived log file name=+DATA/arch/orcl/1_25_964992135.dbf thread=1 sequence=25
archived log file name=+DATA/arch/orcl/1_26_964992135.dbf thread=1 sequence=26
archived log file name=+DATA/arch/orcl/1_27_964992135.dbf thread=1 sequence=27
archived log file name=+DATA/arch/orcl/1_28_964992135.dbf thread=1 sequence=28
archived log file name=+DATA/arch/orcl/1_29_964992135.dbf thread=1 sequence=29
archived log file name=+DATA/arch/orcl/1_30_964992135.dbf thread=1 sequence=30
archived log file name=+DATA/arch/orcl/1_31_964992135.dbf thread=1 sequence=31
archived log file name=+DATA/arch/orcl/1_32_964992135.dbf thread=1 sequence=32
media recovery complete, elapsed time: 00:00:34
Finished recover at 2018-01-10 23:29:40

sql statement: alter database 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 =
  ''/ora_xtts/recover/ORCL/controlfile/o1_mf_f5dd84jp_.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    1073741824 bytes

Fixed Size                     8628936 bytes
Variable Size                293602616 bytes
Database Buffers             763363328 bytes
Redo Buffers                   8146944 bytes

sql statement: alter system set  control_files =   ''/ora_xtts/recover/ORCL/controlfile/o1_mf_f5dd84jp_.ctl'' comment= ''RMAN set'' scope=spfile

Oracle instance shut down

connected to auxiliary database (not started)
Oracle instance started

Total System Global Area    1073741824 bytes

Fixed Size                     8628936 bytes
Variable Size                293602616 bytes
Database Buffers             763363328 bytes
Redo Buffers                   8146944 bytes

sql statement: alter database mount clone database

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-10 22:55:39";
# set destinations for recovery set and auxiliary set datafiles
set newname for datafile  4 to new;
# restore the tablespaces in the recovery set and the auxiliary set
restore clone datafile  4;

switch clone datafile all;
}
executing Memory Script

executing command: SET until clause

executing command: SET NEWNAME

Starting restore at 2018-01-10 23:30:43
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=7 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 00004 to /ora_xtts/recover/FVTM_PITR_ORCL/datafile/o1_mf_users_%u_.dbf
channel ORA_AUX_DISK_1: reading from backup piece +DATA/backup/orcl_1492772871_26sobn77_1_1_965074151
channel ORA_AUX_DISK_1: piece handle=+DATA/backup/orcl_1492772871_26sobn77_1_1_965074151 tag=TAG20180110T200911
channel ORA_AUX_DISK_1: restored backup piece 1
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 2018-01-10 23:31:50

datafile 4 switched to datafile copy
input datafile copy RECID=8 STAMP=965086310 file name=/ora_xtts/recover/FVTM_PITR_ORCL/datafile/o1_mf_users_f5ddf560_.dbf

contents of Memory Script:
{
# set requested point in time
set until  time "2018-01-10 22:55:39";
# online the datafiles restored or switched
sql clone "alter database datafile  4 online";
# recover and open resetlogs
recover clone database tablespace  "USERS", "SYSTEM", "UNDOTBS1", "SYSAUX" delete archivelog;
alter clone database open resetlogs;
}
executing Memory Script

executing command: SET until clause

sql statement: alter database datafile  4 online

Starting recover at 2018-01-10 23:31:50
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 24 is already on disk as file +DATA/arch/orcl/1_24_964992135.dbf
archived log for thread 1 with sequence 25 is already on disk as file +DATA/arch/orcl/1_25_964992135.dbf
archived log for thread 1 with sequence 26 is already on disk as file +DATA/arch/orcl/1_26_964992135.dbf
archived log for thread 1 with sequence 27 is already on disk as file +DATA/arch/orcl/1_27_964992135.dbf
archived log for thread 1 with sequence 28 is already on disk as file +DATA/arch/orcl/1_28_964992135.dbf
archived log for thread 1 with sequence 29 is already on disk as file +DATA/arch/orcl/1_29_964992135.dbf
archived log for thread 1 with sequence 30 is already on disk as file +DATA/arch/orcl/1_30_964992135.dbf
archived log for thread 1 with sequence 31 is already on disk as file +DATA/arch/orcl/1_31_964992135.dbf
archived log for thread 1 with sequence 32 is already on disk as file +DATA/arch/orcl/1_32_964992135.dbf
archived log file name=+DATA/arch/orcl/1_24_964992135.dbf thread=1 sequence=24
archived log file name=+DATA/arch/orcl/1_25_964992135.dbf thread=1 sequence=25
archived log file name=+DATA/arch/orcl/1_26_964992135.dbf thread=1 sequence=26
archived log file name=+DATA/arch/orcl/1_27_964992135.dbf thread=1 sequence=27
archived log file name=+DATA/arch/orcl/1_28_964992135.dbf thread=1 sequence=28
archived log file name=+DATA/arch/orcl/1_29_964992135.dbf thread=1 sequence=29
archived log file name=+DATA/arch/orcl/1_30_964992135.dbf thread=1 sequence=30
archived log file name=+DATA/arch/orcl/1_31_964992135.dbf thread=1 sequence=31
archived log file name=+DATA/arch/orcl/1_32_964992135.dbf thread=1 sequence=32
media recovery complete, elapsed time: 00:00:05
Finished recover at 2018-01-10 23:31:58

database opened

contents of Memory Script:
{
# create directory for datapump import
sql "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/ora_xtts/dump''";
# create directory for datapump export
sql clone "create or replace directory TSPITR_DIROBJ_DPDIR as ''
/ora_xtts/dump''";
}
executing Memory Script

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/ora_xtts/dump''

sql statement: create or replace directory TSPITR_DIROBJ_DPDIR as ''/ora_xtts/dump''

Performing export of tables...
   EXPDP> Starting "SYS"."TSPITR_EXP_fvtm_ikCg":
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   EXPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   EXPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   EXPDP> . . exported "CS"."T1"                                   39.66 KB       8 rows
   EXPDP> . . exported "HR"."T1"                                   39.66 KB       8 rows
   EXPDP> Master table "SYS"."TSPITR_EXP_fvtm_ikCg" successfully loaded/unloaded
   EXPDP> ******************************************************************************
   EXPDP> Dump file set for SYS.TSPITR_EXP_fvtm_ikCg is:
   EXPDP>   /ora_xtts/dump/t_emp_recvr.dmp
   EXPDP> Job "SYS"."TSPITR_EXP_fvtm_ikCg" successfully completed at Wed Jan 10 23:32:53 2018 elapsed 0 00:00:34
Export completed


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

Oracle instance shut down

Performing import of tables...
   IMPDP> Master table "SYS"."TSPITR_IMP_fvtm_Dybh" successfully loaded/unloaded
   IMPDP> Starting "SYS"."TSPITR_IMP_fvtm_Dybh":
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE
   IMPDP> Processing object type TABLE_EXPORT/TABLE/TABLE_DATA
   IMPDP> . . imported "JY"."T1_2"                                 39.66 KB       8 rows
   IMPDP> . . imported "JY"."T1_1"                                 39.66 KB       8 rows
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/TABLE_STATISTICS
   IMPDP> Processing object type TABLE_EXPORT/TABLE/STATISTICS/MARKER
   IMPDP> Job "SYS"."TSPITR_IMP_fvtm_Dybh" successfully completed at Wed Jan 10 23:33:32 2018 elapsed 0 00:00:30
Import completed


Removing automatic instance
Automatic instance removed
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_tempts1_f5ddc523_.tmp deleted
auxiliary instance file /ora_xtts/recover/FVTM_PITR_ORCL/onlinelog/o1_mf_3_f5ddhgrn_.log deleted
auxiliary instance file /ora_xtts/recover/FVTM_PITR_ORCL/onlinelog/o1_mf_2_f5ddhgqw_.log deleted
auxiliary instance file /ora_xtts/recover/FVTM_PITR_ORCL/onlinelog/o1_mf_1_f5ddhgq8_.log deleted
auxiliary instance file /ora_xtts/recover/FVTM_PITR_ORCL/datafile/o1_mf_users_f5ddf560_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_sysaux_f5dd8k7d_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_undotbs1_f5dd8k8j_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/datafile/o1_mf_system_f5dd8k64_.dbf deleted
auxiliary instance file /ora_xtts/recover/ORCL/controlfile/o1_mf_f5dd84jp_.ctl deleted
auxiliary instance file t_emp_recvr.dmp deleted
Finished recover at 2018-01-10 23:33:36

5.验证表hr.t1,cs.t1的数据是否成功恢复到表jy.t1_1,jy_t1_2中,从查询记录可以看到已经成功恢复。

SQL> select count(*) from jy.t1_1;

  COUNT(*)
----------
         8

SQL> select count(*) from jy.t1_2;

  COUNT(*)
----------
         8
Proudly powered by WordPress | Indrajeet by Sus Hill.