Oracle 12C RMAN Duplicating Tablespaces Within a PDB

使用RMAN复制对CDB中的PDB的表空间操作如下
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.在目标主机上创建存储目标数据库(dupjy)相关数据库文件的目录,目标主机上的/u01/app/oracle/oradata/dupjy目录用来存储数据库的数据文件,控制文件,联机重做日志文件),/u01/app/oracle/arch/dupjy目录用来存储数据库的归档重做日志文件。

3.将源数据库的密码文件复制到目标主机的相应目录中并修改为目标数据库(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

4.使用源数据库的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.

5.使用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

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

[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



7.在目标主机上配置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)
    )
  )

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

[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.

9.在源主机上配置目标数据库的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)
    )
  )

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

[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.

11.对PDB的表空间进行复制(将复制jypdb数据库与testpdb数据库中的test表空间(TESTPDB: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 Tue Jan 23 23:20:22 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 database to dupjy pluggable database jypdb tablespace TESTPDB:'TEST' from active database nofilenamecheck using compressed backupset;

Starting Duplicate Db at 23-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               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes

Starting restore at 23-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 23-JAN-18

database mounted
Automatically adding tablespace SYSTEM
Automatically adding tablespace SYSAUX
Automatically adding tablespace PDB$SEED:SYSTEM
Automatically adding tablespace PDB$SEED:SYSAUX
Automatically adding tablespace TESTPDB:SYSTEM
Automatically adding tablespace TESTPDB:SYSAUX
RMAN-05519: warning: tablespace TESTPDB:SYSTEM is always included when duplicating
Automatically adding tablespace TESTPDB:UNDOTBS1
Automatically adding tablespace UNDOTBS1
Automatically adding tablespace TESTPDB:UNDO_2
Automatically adding tablespace UNDOTBS2
Checking that duplicated tablespaces are self-contained
Skipping tablespace USERS
Skipping tablespace TESTPDB:USERS
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  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  21 to 
 "/u01/app/oracle/oradata/dupjy/test.269.962469409";
   restore
   from  nonsparse   from service 
 'jy'   using compressed backupset
   clone database
   skip forever tablespace  "USERS",
 "TESTPDB":"USERS"   ;
   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

Starting restore at 23-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: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 00005 to /u01/app/oracle/oradata/dupjy/system.256.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service 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 00008 to /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
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 00009 to /u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
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 00010 to /u01/app/oracle/oradata/dupjy/system.271.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service 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:08
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: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 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 00015 to /u01/app/oracle/oradata/dupjy/test.275.962210609
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 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:08
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 00021 to /u01/app/oracle/oradata/dupjy/test.269.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 23-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  15749326;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 23-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=172
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
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=173
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=150
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=151
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=152
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 23-JAN-18

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

contents of Memory Script:
{
   set until scn  15754741;
   recover
   clone database
   skip forever tablespace  "USERS",
 "TESTPDB":"USERS"    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 23-JAN-18
using channel ORA_AUX_DISK_1

Executing: alter database datafile 7 offline drop
Executing: alter database datafile 20 offline drop
starting media recovery

archived log for thread 1 with sequence 172 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_172_961976319.dbf
archived log for thread 1 with sequence 173 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_173_961976319.dbf
archived log for thread 2 with sequence 151 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_151_961976319.dbf
archived log for thread 2 with sequence 152 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_152_961976319.dbf
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_172_961976319.dbf thread=1 sequence=172
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_151_961976319.dbf thread=2 sequence=151
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_173_961976319.dbf thread=1 sequence=173
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_152_961976319.dbf thread=2 sequence=152
media recovery complete, elapsed time: 00:00:09
Finished recover at 23-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";
   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
starting full resync of recovery catalog
full resync complete

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               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
 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/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/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=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605 RECID=2 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675 RECID=3 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675 RECID=4 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605 RECID=5 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649 RECID=6 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649 RECID=7 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649 RECID=8 STAMP=966187585
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.278.962209649 RECID=9 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.275.962210609 RECID=10 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409 RECID=11 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409 RECID=12 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409 RECID=13 STAMP=966187586
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.269.962469409 RECID=14 STAMP=966187586

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 8 switched to datafile copy
input datafile copy RECID=4 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=5 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 11 switched to datafile copy
input datafile copy RECID=6 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=7 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=8 STAMP=966187585 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=9 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 15 switched to datafile copy
input datafile copy RECID=10 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/test.275.962210609
datafile 17 switched to datafile copy
input datafile copy RECID=11 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409
datafile 18 switched to datafile copy
input datafile copy RECID=12 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409
datafile 19 switched to datafile copy
input datafile copy RECID=13 STAMP=966187586 file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409
datafile 21 switched to datafile copy
input datafile copy RECID=14 STAMP=966187586 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: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Executing: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Finished Duplicate Db at 23-JAN-18

12.检查源数据库中的PDB(jypdb)是否被成功复制到目标数据库dupjy中

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

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Jan 23 17:34:24 2018

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

connected to target database: DUPJY (DBID=1349553641)

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    2340     SYSAUX               NO      /u01/app/oracle/oradata/dupjy/sysaux.298.962209605
4    1015     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
8    100      PDB$SEED:UNDOTBS1    NO      /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
9    1350     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   205      JYPDB:UNDOTBS1       YES     /u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
13   310      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
15   100      JYPDB:TEST           NO      /u01/app/oracle/oradata/dupjy/test.275.962210609
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   245      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
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

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    

从上面的输出结果可以看到,虽然只复制jypdb数据库与testpdb数据库中的test表空间,但其实还为了让testpdb的test表空间可以使用还是复制了testpdb中的system,sysaux,undo,temp表空间,到此复制RAC CDB数据库中PDB的表空间到单实例CDB数据库就操作完成。

Oracle 12C RMAN Duplicating the PDB to remote CDB

使用RMAN对CDB中的PDB进行复制的操作如下
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.在目标主机上创建存储目标数据库(dupjy)相关数据库文件的目录,目标主机上的/u01/app/oracle/oradata/dupjy目录用来存储数据库的数据文件,控制文件,联机重做日志文件),/u01/app/oracle/arch/dupjy目录用来存储数据库的归档重做日志文件。

3.将源数据库的密码文件复制到目标主机的相应目录中并修改为目标数据库(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

4.使用源数据库的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.

5.使用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

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

[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


7.在目标主机上配置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)
    )
  )

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

[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.

9.在源主机上配置目标数据库的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)
    )
  )

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

[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.

11.执行PDB数据库复制

[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 Tue Jan 23 17:47:09 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 database to dupjy pluggable database jypdb from active database nofilenamecheck using compressed backupset;

Starting Duplicate Db at 23-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2269 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               1056967968 bytes
Database Buffers            1073741824 bytes
Redo Buffers                   7979008 bytes

Starting restore at 23-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 23-JAN-18

database mounted
Skipping pluggable database TESTPDB
Automatically adding tablespace SYSTEM
Automatically adding tablespace SYSAUX
Automatically adding tablespace PDB$SEED:SYSTEM
Automatically adding tablespace PDB$SEED:SYSAUX
Automatically adding tablespace TESTPDB:SYSTEM
Automatically adding tablespace TESTPDB:UNDOTBS1
Automatically adding tablespace UNDOTBS1
Automatically adding tablespace TESTPDB:UNDO_2
Automatically adding tablespace UNDOTBS2
Skipping tablespace USERS
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  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";
   restore
   from  nonsparse   from service 
 'jy'   using compressed backupset
   clone database
   skip forever tablespace  "USERS",
 "TESTPDB":"USERS",
 "TESTPDB":"UNDO_2",
 "TESTPDB":"UNDOTBS1",
 "TESTPDB":"TEST",
 "TESTPDB":"SYSTEM",
 "TESTPDB":"SYSAUX"   ;
   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

Starting restore at 23-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:15
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:15
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 00008 to /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
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 00009 to /u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
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 00010 to /u01/app/oracle/oradata/dupjy/system.271.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service 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:46
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:08
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:08
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:01:05
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 00015 to /u01/app/oracle/oradata/dupjy/test.275.962210609
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 23-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  15660582;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 23-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=163
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=1 sequence=164
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=1 sequence=165
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=144
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=145
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:02
Finished restore at 23-JAN-18

datafile 1 switched to datafile copy
input datafile copy RECID=17 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/system.317.962209603
datafile 3 switched to datafile copy
input datafile copy RECID=18 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=19 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 5 switched to datafile copy
input datafile copy RECID=20 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/system.256.962209675
datafile 6 switched to datafile copy
input datafile copy RECID=21 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 8 switched to datafile copy
input datafile copy RECID=22 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=23 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 10 switched to datafile copy
input datafile copy RECID=24 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/system.271.962209649
datafile 11 switched to datafile copy
input datafile copy RECID=25 STAMP=966167434 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=26 STAMP=966167435 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=27 STAMP=966167435 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=28 STAMP=966167435 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 15 switched to datafile copy
input datafile copy RECID=29 STAMP=966167435 file name=/u01/app/oracle/oradata/dupjy/test.275.962210609

contents of Memory Script:
{
   set until scn  15661286;
   recover
   clone database
   skip forever tablespace  "USERS",
 "TESTPDB":"USERS",
 "TESTPDB":"UNDO_2",
 "TESTPDB":"UNDOTBS1",
 "TESTPDB":"TEST",
 "TESTPDB":"SYSTEM",
 "TESTPDB":"SYSAUX"    delete archivelog
   ;
}
executing Memory Script

executing command: SET until clause

Starting recover at 23-JAN-18
using channel ORA_AUX_DISK_1

Executing: alter database datafile 7 offline drop
Executing: alter database datafile 20 offline drop
Executing: alter database datafile 19 offline drop
Executing: alter database datafile 18 offline drop
Executing: alter database datafile 21 offline drop
Executing: alter database datafile 16 offline drop
Executing: alter database datafile 17 offline drop
starting media recovery

archived log for thread 1 with sequence 164 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_164_961976319.dbf
archived log for thread 1 with sequence 165 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/1_165_961976319.dbf
archived log for thread 2 with sequence 144 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_144_961976319.dbf
archived log for thread 2 with sequence 145 is already on disk as file /u01/app/oracle/oradata/arch_dupjy/2_145_961976319.dbf
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_164_961976319.dbf thread=1 sequence=164
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_144_961976319.dbf thread=2 sequence=144
archived log file name=/u01/app/oracle/oradata/arch_dupjy/1_165_961976319.dbf thread=1 sequence=165
archived log file name=/u01/app/oracle/oradata/arch_dupjy/2_145_961976319.dbf thread=2 sequence=145
media recovery complete, elapsed time: 00:00:02
Finished recover at 23-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";
   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               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
 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'
 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";
   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/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";
   switch clone datafile all;
}
executing Memory Script

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

cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605 RECID=1 STAMP=966167470
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605 RECID=2 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675 RECID=3 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675 RECID=4 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605 RECID=5 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649 RECID=6 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649 RECID=7 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649 RECID=8 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.278.962209649 RECID=9 STAMP=966167471
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.275.962210609 RECID=10 STAMP=966167471

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=966167470 file name=/u01/app/oracle/oradata/dupjy/sysaux.298.962209605
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675
datafile 8 switched to datafile copy
input datafile copy RECID=4 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
datafile 9 switched to datafile copy
input datafile copy RECID=5 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605
datafile 11 switched to datafile copy
input datafile copy RECID=6 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649
datafile 12 switched to datafile copy
input datafile copy RECID=7 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
datafile 13 switched to datafile copy
input datafile copy RECID=8 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649
datafile 14 switched to datafile copy
input datafile copy RECID=9 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/users.278.962209649
datafile 15 switched to datafile copy
input datafile copy RECID=10 STAMP=966167471 file name=/u01/app/oracle/oradata/dupjy/test.275.962210609

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

database opened
Executing: drop pluggable database "TESTPDB" including datafiles

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: alter database default tablespace system
Executing: drop tablespace "USERS" including contents cascade constraints
Finished Duplicate Db at 23-JAN-18

12.检查源数据库中的PDB(jypdb)是否被成功复制到目标数据库dupjy中

SQL> select name,open_mode from v$pdbs;

NAME                                                                                                                             OPEN_MODE
-------------------------------------------------------------------------------------------------------------------------------- ----------
PDB$SEED                                                                                                                         READ ONLY
JYPDB                                                                                                                            READ WRITE

到此复制RAC CDB数据库中PDB(jypdb)到单实例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 Duplicating the Whole RAC CDB to local RAC CDB

下面的例子是将源RAC CDB数据库通过rman的duplicate命令复制一个RAC 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.在目标主机上创建存储目标数据库(dup)相关数据库文件的目录,目标主机上的+fra/dup目录用来存储数据库的数据文件,控制文件,联机重做日志文件),+fra/dup目录用来存储数据库的归档重做日志文件

ASMCMD [+fra] > mkdir dup

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

[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 admin]$ asmcmd cp  +DATA/JY/PASSWORD/pwdjy.274.961976109 /home/grid/orapwdup1
copying +DATA/JY/PASSWORD/pwdjy.274.961976109 -> /home/grid/orapwdup1

[root@jytest1 ~]# cp /home/grid/orapwdup /u01/app/oracle/product/12.2.0/db/dbs/orapwdup1
[root@jytest1 ~]# chown -R oracle:oinstall /u01/app/oracle/product/12.2.0/db/dbs/orapwdup1
[root@jytest1 ~]# chmod -R 777 /u01/app/oracle/product/12.2.0/db/dbs/orapwdup1

将密码文件orapwdup复制到2号实例主机上

[oracle@jytest2 dbs]$ scp oracle@10.138.130.171:/u01/app/oracle/product/12.2.0/db/dbs/orapwdup1 /u01/app/oracle/product/12.2.0/db/dbs/
orapwdup1                                                                   100% 3584     3.5KB/s   00:00    

[oracle@jytest2 dbs]$ mv orapwdup1 orapwdup2

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

SQL> create pfile from spfile;

File created.

[oracle@jytest1 dbs]$ vi initdup1.ora
*.audit_file_dest='/u01/app/oracle/admin/dup/adump'
*.cluster_database=false
*.compatible='12.2.0'
*.control_files='+fra/dup/CONTROLFILE/control01.ctl'
*.db_block_size=8192
*.db_name='dup'
*.diagnostic_dest='/u01/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=jyXDB)'
*.enable_pluggable_database=true
dup2.instance_number=2
dup1.instance_number=1
*.local_listener='-oraagent-dummy-'
*.log_archive_dest_1='location=+test/arch/dup'
*.nls_language='AMERICAN'
*.nls_territory='AMERICA'
*.open_cursors=300
*.pga_aggregate_target=1g
*.processes=2000
*.remote_login_passwordfile='exclusive'
*.sga_max_size=2147483648
*.sga_target=2147483648
dup2.thread=2
dup1.thread=1
*.undo_retention=8640
dup1.undo_tablespace='UNDOTBS1'
dup2.undo_tablespace='UNDOTBS2'
*.db_file_name_convert=('+DATA/JY/','+fra/dup')
*.log_file_name_convert=('+DATA/JY/','+fra/dup')


[oracle@jytest1 dbs]$ export ORACLE_SID=dup1
[oracle@jytest1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Fri Jan 19 19:46:07 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/initdup1.ora'
ORACLE instance started.

Total System Global Area 2147483648 bytes
Fixed Size                  8794848 bytes
Variable Size            1459621152 bytes
Database Buffers          671088640 bytes
Redo Buffers                7979008 bytes



SQL> create spfile='+fra/dup/spfiledup.ora' from pfile='/u01/app/oracle/product/12.2.0/db/dbs/initdup1.ora';

File created.

[oracle@jytest1 dbs]$ vi initdup1.ora
spfile=+fra/dup/spfiledup.ora

[oracle@jytest2 dbs]$ vi initdup1.ora
spfile=+fra/dup/spfiledup.ora

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

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/spfiledup1.ora

6.给目标数据库配置静态监听与tns名

[grid@jytest1 admin]$ vi listener.ora

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

[grid@jytest2 admin]$ vi listener.ora

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


[grid@jytest1 admin]$ srvctl stop listener -listener LISTENER

[grid@jytest1 admin]$ srvctl start listener -listener LISTENER
[grid@jytest1 admin]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-JAN-2018 22:36:22

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                19-JAN-2018 22:32:51
Uptime                    0 days 0 hr. 3 min. 31 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/12.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jytest1/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.171)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.175)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=jytest1.jydba.net)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.2.0/db/admin/jy/xdb_wallet))(Presentation=HTTP)

(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_CRS" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_FRA" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "+ASM_TEST" has 1 instance(s).
  Instance "+ASM1", status READY, has 1 handler(s) for this service...
Service "5f9ac6865e87549fe053ab828a0ade94" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "600d6f56deb669cce053ab828a0aab7e" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "dup" has 1 instance(s).
  Instance "dup1", status UNKNOWN, has 1 handler(s) for this service...
Service "jy" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "jyXDB" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "jypdb" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
Service "testpdb" has 1 instance(s).
  Instance "jy1", status READY, has 1 handler(s) for this service...
The command completed successfully


[grid@jytest2 admin]$ lsnrctl status

LSNRCTL for Linux: Version 12.2.0.1.0 - Production on 19-JAN-2018 22:41:01

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

Connecting to (DESCRIPTION=(ADDRESS=(PROTOCOL=IPC)(KEY=LISTENER)))
STATUS of the LISTENER
------------------------
Alias                     LISTENER
Version                   TNSLSNR for Linux: Version 12.2.0.1.0 - Production
Start Date                19-JAN-2018 22:37:29
Uptime                    0 days 0 hr. 3 min. 31 sec
Trace Level               off
Security                  ON: Local OS Authentication
SNMP                      OFF
Listener Parameter File   /u01/app/product/12.2.0/crs/network/admin/listener.ora
Listener Log File         /u01/app/grid/diag/tnslsnr/jytest2/listener/alert/log.xml
Listening Endpoints Summary...
  (DESCRIPTION=(ADDRESS=(PROTOCOL=ipc)(KEY=LISTENER)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.172)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcp)(HOST=10.138.130.176)(PORT=1521)))
  (DESCRIPTION=(ADDRESS=(PROTOCOL=tcps)(HOST=jytest2.jydba.net)(PORT=5500))(Security=(my_wallet_directory=/u01/app/oracle/product/12.2.0/db/admin/jy/xdb_wallet))(Presentation=HTTP)

(Session=RAW))
Services Summary...
Service "+ASM" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_CRS" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_DATA" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_FRA" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "+ASM_TEST" has 1 instance(s).
  Instance "+ASM2", status READY, has 1 handler(s) for this service...
Service "5f9ac6865e87549fe053ab828a0ade94" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "600d6f56deb669cce053ab828a0aab7e" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "dup" has 1 instance(s).
  Instance "dup2", status UNKNOWN, has 1 handler(s) for this service...
Service "jy" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "jyXDB" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "jypdb" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
Service "testpdb" has 1 instance(s).
  Instance "jy2", status READY, has 1 handler(s) for this service...
The command completed successfully

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

[oracle@jytest1 admin]$ vi tnsnames.ora 
DUP =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.171)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dup)
      (UR = A)
    )
  )

[oracle@jytest2 admin]$ vi tnsnames.ora 
DUP =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = 10.138.130.172)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = dup)
      (UR = A)
    )
  )

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

[oracle@jytest1 admin]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Fri Jan 19 22:58:34 2018

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

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

9.执行数据库复制

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

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Jan 19 23:16:15 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: DUP (not mounted)

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

Starting Duplicate Db at 19-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2275 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 = 
 ''DUP'' 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 =  ''DUP'' 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               1459621152 bytes
Database Buffers             671088640 bytes
Redo Buffers                   7979008 bytes

Starting restore at 19-JAN-18
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=1519 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=+FRA/dup/CONTROLFILE/control01.ctl
Finished restore at 19-JAN-18

database mounted
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 
 "+FRA";
   set newname for datafile  3 to 
 "+FRA";
   set newname for datafile  4 to 
 "+FRA";
   set newname for datafile  5 to 
 "+FRA";
   set newname for datafile  6 to 
 "+FRA";
   set newname for datafile  7 to 
 "+FRA";
   set newname for datafile  8 to 
 "+FRA";
   set newname for datafile  9 to 
 "+FRA";
   set newname for datafile  10 to 
 "+FRA";
   set newname for datafile  11 to 
 "+FRA";
   set newname for datafile  12 to 
 "+FRA";
   set newname for datafile  13 to 
 "+FRA";
   set newname for datafile  14 to 
 "+FRA";
   set newname for datafile  15 to 
 "+FRA";
   set newname for datafile  16 to 
 "+FRA";
   set newname for datafile  17 to 
 "+FRA";
   set newname for datafile  18 to 
 "+FRA";
   set newname for datafile  19 to 
 "+FRA";
   set newname for datafile  20 to 
 "+FRA";
   set newname for datafile  21 to 
 "+FRA";
   restore
   from  nonsparse   from service 
 'jy'   using compressed backupset
   clone database
   ;
   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

executing command: SET NEWNAME

Starting restore at 19-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 +FRA
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: 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 +FRA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:46
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 +FRA
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 00005 to +FRA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00006 to +FRA
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 +FRA
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 +FRA
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 00009 to +FRA
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 00010 to +FRA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service jy
channel ORA_AUX_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_AUX_DISK_1: restoring datafile 00011 to +FRA
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 00012 to +FRA
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 +FRA
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 +FRA
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 00015 to +FRA
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 00016 to +FRA
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 +FRA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
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 +FRA
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 00019 to +FRA
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 00020 to +FRA
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 00021 to +FRA
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 19-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  13147698;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 19-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=137
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
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=138
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=139
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=114
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=115
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:04
Finished restore at 19-JAN-18

datafile 1 switched to datafile copy
input datafile copy RECID=24 STAMP=965863480 file name=+FRA/DUP/DATAFILE/system.376.965863053
datafile 3 switched to datafile copy
input datafile copy RECID=25 STAMP=965863482 file name=+FRA/DUP/DATAFILE/sysaux.379.965863109
datafile 4 switched to datafile copy
input datafile copy RECID=26 STAMP=965863482 file name=+FRA/DUP/DATAFILE/undotbs1.380.965863215
datafile 5 switched to datafile copy
input datafile copy RECID=27 STAMP=965863482 file name=+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.381.965863229
datafile 6 switched to datafile copy
input datafile copy RECID=28 STAMP=965863482 file name=+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.382.965863245
datafile 7 switched to datafile copy
input datafile copy RECID=29 STAMP=965863483 file name=+FRA/DUP/DATAFILE/users.364.965863281
datafile 8 switched to datafile copy
input datafile copy RECID=30 STAMP=965863483 file name=+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.365.965863281
datafile 9 switched to datafile copy
input datafile copy RECID=31 STAMP=965863483 file name=+FRA/DUP/DATAFILE/undotbs2.366.965863289
datafile 10 switched to datafile copy
input datafile copy RECID=32 STAMP=965863483 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.367.965863293
datafile 11 switched to datafile copy
input datafile copy RECID=33 STAMP=965863483 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.326.965863309
datafile 12 switched to datafile copy
input datafile copy RECID=34 STAMP=965863484 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.285.965863345
datafile 13 switched to datafile copy
input datafile copy RECID=35 STAMP=965863484 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.325.965863349
datafile 14 switched to datafile copy
input datafile copy RECID=36 STAMP=965863484 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.369.965863351
datafile 15 switched to datafile copy
input datafile copy RECID=37 STAMP=965863484 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.370.965863387
datafile 16 switched to datafile copy
input datafile copy RECID=38 STAMP=965863484 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.371.965863391
datafile 17 switched to datafile copy
input datafile copy RECID=39 STAMP=965863485 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.372.965863407
datafile 18 switched to datafile copy
input datafile copy RECID=40 STAMP=965863485 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.373.965863443
datafile 19 switched to datafile copy
input datafile copy RECID=41 STAMP=965863485 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.375.965863445
datafile 20 switched to datafile copy
input datafile copy RECID=42 STAMP=965863485 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.377.965863449
datafile 21 switched to datafile copy
input datafile copy RECID=43 STAMP=965863485 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.378.965863451

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

executing command: SET until clause

Starting recover at 19-JAN-18
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 137 is already on disk as file +TEST/arch/dup/1_137_961976319.dbf
archived log for thread 1 with sequence 138 is already on disk as file +TEST/arch/dup/1_138_961976319.dbf
archived log for thread 1 with sequence 139 is already on disk as file +TEST/arch/dup/1_139_961976319.dbf
archived log for thread 2 with sequence 114 is already on disk as file +TEST/arch/dup/2_114_961976319.dbf
archived log for thread 2 with sequence 115 is already on disk as file +TEST/arch/dup/2_115_961976319.dbf
archived log file name=+TEST/arch/dup/2_114_961976319.dbf thread=2 sequence=114
archived log file name=+TEST/arch/dup/1_137_961976319.dbf thread=1 sequence=137
archived log file name=+TEST/arch/dup/1_138_961976319.dbf thread=1 sequence=138
archived log file name=+TEST/arch/dup/2_115_961976319.dbf thread=2 sequence=115
archived log file name=+TEST/arch/dup/1_139_961976319.dbf thread=1 sequence=139
media recovery complete, elapsed time: 00:00:04
Finished recover at 19-JAN-18
Oracle instance started

Total System Global Area    2147483648 bytes

Fixed Size                     8794848 bytes
Variable Size               1459621152 bytes
Database Buffers             671088640 bytes
Redo Buffers                   7979008 bytes

contents of Memory Script:
{
   sql clone "alter system set  db_name = 
 ''DUP'' 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 =  ''DUP'' 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               1459621152 bytes
Database Buffers             671088640 bytes
Redo Buffers                   7979008 bytes
sql statement: CREATE CONTROLFILE REUSE SET DATABASE "DUP" RESETLOGS ARCHIVELOG 
  MAXLOGFILES    192
  MAXLOGMEMBERS      3
  MAXDATAFILES     1024
  MAXINSTANCES    32
  MAXLOGHISTORY      292
 LOGFILE
  GROUP   1 ( '+FRA' ) SIZE 200 M  REUSE,
  GROUP   2 ( '+FRA' ) SIZE 200 M  REUSE
 DATAFILE
  '+FRA/DUP/DATAFILE/system.376.965863053',
  '+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.381.965863229',
  '+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.367.965863293',
  '+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.371.965863391'
 CHARACTER SET ZHS16GBK

sql statement: ALTER DATABASE ADD LOGFILE 
  
  INSTANCE 'i2' 
  GROUP   3 ( '+FRA' ) SIZE 200 M  REUSE,
  GROUP   4 ( '+FRA' ) SIZE 200 M  REUSE

contents of Memory Script:
{
   set newname for tempfile  1 to 
 "+FRA";
   set newname for tempfile  2 to 
 "+FRA";
   set newname for tempfile  3 to 
 "+FRA";
   set newname for tempfile  4 to 
 "+FRA";
   switch clone tempfile all;
   catalog clone datafilecopy  "+FRA/DUP/DATAFILE/sysaux.379.965863109", 
 "+FRA/DUP/DATAFILE/undotbs1.380.965863215", 
 "+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.382.965863245", 
 "+FRA/DUP/DATAFILE/users.364.965863281", 
 "+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.365.965863281", 
 "+FRA/DUP/DATAFILE/undotbs2.366.965863289", 
 "+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.326.965863309", 
 "+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.285.965863345", 
 "+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.325.965863349", 
 "+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.369.965863351", 
 "+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.370.965863387", 
 "+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.372.965863407", 
 "+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.373.965863443", 
 "+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.375.965863445", 
 "+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.377.965863449", 
 "+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.378.965863451";
   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 +FRA in control file
renamed tempfile 2 to +FRA in control file
renamed tempfile 3 to +FRA in control file
renamed tempfile 4 to +FRA in control file

cataloged datafile copy
datafile copy file name=+FRA/DUP/DATAFILE/sysaux.379.965863109 RECID=1 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/DATAFILE/undotbs1.380.965863215 RECID=2 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.382.965863245 RECID=3 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/DATAFILE/users.364.965863281 RECID=4 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.365.965863281 RECID=5 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/DATAFILE/undotbs2.366.965863289 RECID=6 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.326.965863309 RECID=7 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.285.965863345 RECID=8 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.325.965863349 RECID=9 STAMP=965863550
cataloged datafile copy
datafile copy file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.369.965863351 RECID=10 STAMP=965863551
cataloged datafile copy
datafile copy file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.370.965863387 RECID=11 STAMP=965863551
cataloged datafile copy
datafile copy file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.372.965863407 RECID=12 STAMP=965863551
cataloged datafile copy
datafile copy file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.373.965863443 RECID=13 STAMP=965863551
cataloged datafile copy
datafile copy file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.375.965863445 RECID=14 STAMP=965863551
cataloged datafile copy
datafile copy file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.377.965863449 RECID=15 STAMP=965863551
cataloged datafile copy
datafile copy file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.378.965863451 RECID=16 STAMP=965863551

datafile 3 switched to datafile copy
input datafile copy RECID=1 STAMP=965863550 file name=+FRA/DUP/DATAFILE/sysaux.379.965863109
datafile 4 switched to datafile copy
input datafile copy RECID=2 STAMP=965863550 file name=+FRA/DUP/DATAFILE/undotbs1.380.965863215
datafile 6 switched to datafile copy
input datafile copy RECID=3 STAMP=965863550 file name=+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.382.965863245
datafile 7 switched to datafile copy
input datafile copy RECID=4 STAMP=965863550 file name=+FRA/DUP/DATAFILE/users.364.965863281
datafile 8 switched to datafile copy
input datafile copy RECID=5 STAMP=965863550 file name=+FRA/DUP/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.365.965863281
datafile 9 switched to datafile copy
input datafile copy RECID=6 STAMP=965863550 file name=+FRA/DUP/DATAFILE/undotbs2.366.965863289
datafile 11 switched to datafile copy
input datafile copy RECID=7 STAMP=965863550 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.326.965863309
datafile 12 switched to datafile copy
input datafile copy RECID=8 STAMP=965863550 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.285.965863345
datafile 13 switched to datafile copy
input datafile copy RECID=9 STAMP=965863550 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.325.965863349
datafile 14 switched to datafile copy
input datafile copy RECID=10 STAMP=965863551 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.369.965863351
datafile 15 switched to datafile copy
input datafile copy RECID=11 STAMP=965863551 file name=+FRA/DUP/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.370.965863387
datafile 17 switched to datafile copy
input datafile copy RECID=12 STAMP=965863551 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.372.965863407
datafile 18 switched to datafile copy
input datafile copy RECID=13 STAMP=965863551 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.373.965863443
datafile 19 switched to datafile copy
input datafile copy RECID=14 STAMP=965863551 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.375.965863445
datafile 20 switched to datafile copy
input datafile copy RECID=15 STAMP=965863551 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.377.965863449
datafile 21 switched to datafile copy
input datafile copy RECID=16 STAMP=965863551 file name=+FRA/DUP/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.378.965863451

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

10.检查数据是否一致
在源数据库查询表记录

SQL> conn sys/abcd@jy as sysdba
Connected.
SQL> show parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      jy
SQL> alter session set container=jypdb;

Session altered.

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

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

在目标数据库查询表记录

SQL> conn sys/abcd@dup as sysdba
Connected.
SQL> show parameter db_name

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
db_name                              string      DUP
SQL> alter session set container=jypdb;

Session altered.

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

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

到此复制整个RAC CDB数据库为RAC CDB数据库完成,后面就是向集群注册数据库就不详细介绍了。

Oracle 12c RMAN Duplicating the Whole CDB

下面的例子是将源RAC CDB数据库通过rman的duplicate命令复制一个单实例的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.在目标主机上创建存储目标数据库(dupjy)相关数据库文件的目录,目标主机上的/u01/app/oracle/oradata/dupjy目录用来存储数据库的数据文件,控制文件,联机重做日志文件),/u01/app/oracle/arch/dupjy目录用来存储数据库的归档重做日志文件。

3.将源数据库的密码文件复制到目标主机的相应目录中并修改为目标数据库(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

4.使用源数据库的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.

5.使用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

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

[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


7.在目标主机上配置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)
    )
  )

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

[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.

9.在源主机上配置目标数据库的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)
    )
  )

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

[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.

11.执行数据库复制

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

Recovery Manager: Release 12.2.0.1.0 - Production on Fri Jan 19 03:36:45 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 from active database nofilenamecheck using compressed backupset;

Starting Duplicate Db at 19-JAN-18
starting full resync of recovery catalog
full resync complete
allocated channel: ORA_AUX_DISK_1
channel ORA_AUX_DISK_1: SID=2269 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                570428704 bytes
Database Buffers            1560281088 bytes
Redo Buffers                   7979008 bytes

Starting restore at 19-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 19-JAN-18

database mounted
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  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
   from  nonsparse   from service 
 'jy'   using compressed backupset
   clone database
   ;
   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

executing command: SET NEWNAME

Starting restore at 19-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:01:15
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:03:06
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: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 00005 to /u01/app/oracle/oradata/dupjy/system.256.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 00006 to /u01/app/oracle/oradata/dupjy/sysaux.270.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:56
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: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 00008 to /u01/app/oracle/oradata/dupjy/undotbs1.296.962209675
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service 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: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 00010 to /u01/app/oracle/oradata/dupjy/system.271.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:35
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:01: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 00012 to /u01/app/oracle/oradata/dupjy/undotbs1.264.962209649
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:18
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: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 00014 to /u01/app/oracle/oradata/dupjy/users.278.962209649
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 00015 to /u01/app/oracle/oradata/dupjy/test.275.962210609
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service 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: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 00017 to /u01/app/oracle/oradata/dupjy/sysaux.259.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:01:05
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: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 00019 to /u01/app/oracle/oradata/dupjy/undo_2.266.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:15
channel ORA_AUX_DISK_1: starting datafile backup set restore
channel ORA_AUX_DISK_1: using compressed network backup set from service 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: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 00021 to /u01/app/oracle/oradata/dupjy/test.269.962469409
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:08
Finished restore at 19-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  12917437;
   switch clone datafile all;
}
executing Memory Script

Starting restore at 19-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=130
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=1 sequence=131
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=106
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:26
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=107
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=108
channel ORA_AUX_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 19-JAN-18

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

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

executing command: SET until clause

Starting recover at 19-JAN-18
using channel ORA_AUX_DISK_1

starting media recovery

archived log for thread 1 with sequence 130 is already on disk as file /u01/app/oracle/product/12.2.0/db/dbs/arch1_130_961976319.dbf
archived log for thread 1 with sequence 131 is already on disk as file /u01/app/oracle/product/12.2.0/db/dbs/arch1_131_961976319.dbf
archived log for thread 2 with sequence 107 is already on disk as file /u01/app/oracle/product/12.2.0/db/dbs/arch2_107_961976319.dbf
archived log for thread 2 with sequence 108 is already on disk as file /u01/app/oracle/product/12.2.0/db/dbs/arch2_108_961976319.dbf
archived log file name=/u01/app/oracle/product/12.2.0/db/dbs/arch1_130_961976319.dbf thread=1 sequence=130
archived log file name=/u01/app/oracle/product/12.2.0/db/dbs/arch2_107_961976319.dbf thread=2 sequence=107
archived log file name=/u01/app/oracle/product/12.2.0/db/dbs/arch2_108_961976319.dbf thread=2 sequence=108
archived log file name=/u01/app/oracle/product/12.2.0/db/dbs/arch1_131_961976319.dbf thread=1 sequence=131
media recovery complete, elapsed time: 00:00:02
Finished recover at 19-JAN-18
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

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                570428704 bytes
Database Buffers            1560281088 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/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 +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=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.277.962209605 RECID=2 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.270.962209675 RECID=3 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.301.962209605 RECID=4 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.296.962209675 RECID=5 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs2.312.962209605 RECID=6 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.316.962209649 RECID=7 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.264.962209649 RECID=8 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.268.962209649 RECID=9 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.278.962209649 RECID=10 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.275.962210609 RECID=11 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/sysaux.259.962469409 RECID=12 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undotbs1.265.962469409 RECID=13 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/undo_2.266.962469409 RECID=14 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/users.267.962469409 RECID=15 STAMP=965771317
cataloged datafile copy
datafile copy file name=/u01/app/oracle/oradata/dupjy/test.269.962469409 RECID=16 STAMP=965771317

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


12.检查数据是否一致
在源数据库查询表记录

SQL> conn sys/abcd@jypdb  as sysdba
Connected.

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

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

在目标数据库查询表记录

SQL> conn sys/abcd@jypdb as sysdba
Connected.

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

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

到此复制整个RAC CDB数据库为单实例CDB数据库完成

Oracle 12C xtts and dbms_file_transfer

1.初始化设置阶段
1.1安装目标数据库软件并创建目标数据库
在目标系统上安装目标Oracle数据库软件,版本应该为Oracle12c,操作系统是Linux,我这里都是12.2.0.1。在源数据库中创建了一个要被传输到目标数据库的表空间jy,用户方案jy,源数据库版本也是12.2.0.1,操作系统是Linux。

1.2识别要被传输的表空间
源数据库中要被传输的表空间为jy,用户方案jy。

1.3在源系统上安装xttconvert脚本

[oracle@jytest3 xtts_script]$ unzip rman_xttconvert_v3.zip
Archive:  rman_xttconvert_v3.zip
  inflating: xtt.properties
  inflating: xttcnvrtbkupdest.sql
  inflating: xttdbopen.sql
  inflating: xttdriver.pl
  inflating: xttprep.tmpl
 extracting: xttstartupnomount.sql

 [oracle@jytest1 backup]$ vi $ORACLE_HOME/dbs/initxtt.ora
db_name=xtt
compatible=12.2.0.0.0
[oracle@jytest1 backup]$ export ORACLE_SID=xtt
[oracle@jytest1 backup]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Tue Aug 22 18:25:46 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
SQL> startup nomount
ORACLE instance started.

Total System Global Area  444596224 bytes
Fixed Size                  8621520 bytes
Variable Size             377487920 bytes
Database Buffers           50331648 bytes
Redo Buffers                8155136 bytes

1.4 创建需要使用的目录
如果使用dbms_file_transfer方法,那么配置目录对象与dblink,注意dbms_file_transfer方法要求目标数据库的版本为11.2.0.4,如果使用dbms_file_transfer访求,那么必须创建以下三个数据库对象:
.在源数据库中创建一个数据库目录对象,它指向要被复制的数据文件所存放的目录
.在目标数据库中创建一个数据库目录对象,它指向将要存放数据文件的目录
.在目标数据库中创建一个dblink连接到源数据库

源数据库目录对象引用源数据库中当前存放数据文件的目录。例如,下面创建目录对象指向,数据文件存放目录+DATA/ORCL/DATAFILE/,连接到源数据库房执行以下命令:

[oracle@jytest3 ~]$ export ORACLE_SID=orcl
[oracle@jytest3 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Mon Aug 21 19:57:36 2017

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


Connected to:
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/ORCL/DATAFILE/system.280.941831569
+DATA/ORCL/DATAFILE/sysaux.281.941831647
+DATA/ORCL/DATAFILE/undotbs1.282.941831677
+DATA/ORCL/DATAFILE/users.284.941831687
+DATA/ORCL/DATAFILE/jy.371.952394755

SQL> create directory sourcedir as '+DATA/ORCL/DATAFILE';

Directory created.

目标数据库目录对象引用目标数据库中将要存储数据文件的目录。这个目录是最终目标数据库将要存放数据文件的目录+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/,连接到目标数据库执行以下命令要注意的是目录对象与dblink要在CDB中创建

[oracle@jytest1 ~]$ sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on Mon Aug 21 16:24:46 2017

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

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

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/system.274.939167015
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/sysaux.275.939167015
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/undotbs1.273.939167015
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/undo_2.277.939167063
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/testtb01.dbf
+DATA/JY/4B2C6373AE2547CCE053AB828A0A7CA3/DATAFILE/undotbs2.278.945029905
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/example01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/test01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/users01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/sales_test_01.dbf
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/emp_test_01.dbf

NAME
--------------------------------------------------------------------------------
+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/orders_test_01.dbf

12 rows selected.

SQL> create directory destdir as '+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile';

Directory created.

在目标数据库中创建一个dblink连接到源数据库。例如创建一个名叫ttslink的dblink,执行以下命令:

SQL> create public database link ttslink
  2    connect to system identified by "xxzx#7817600"
  3    using '(DESCRIPTION =
  4      (ADDRESS_LIST =
  5        (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.130.173)(PORT = 1521))
  6      )
  7      (CONNECT_DATA =
  8        (SERVER = DEDICATED)
  9        (SERVICE_NAME =orcl)
 10      )
 11    )';

Database link created.

SQL> select * from dual@ttslink;

D
-
X

在源系统中创建目录/ora_xtts/backupformat用来存储源系统中对源数据库生成的备份及增量备份文件,xtt.properties文件中的backupformat参数设置该目录。

[oracle@jytest3 ora_xtts]$ mkdir backupformat

在目标系统中创建目录/tts/backup用来存储手动从源系统中传输过来的备份及增量备份文件,xtt.properties文件中的stageondest参数设置该目录。

[oracle@jytest1 tts]$ mkdir backup

xtt.properties文件中的storageondest参数设置目标数据库最终存储数据文件的目录,这里是

+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/目录。

1.5在源系统中配置xtt.properties文件

SQL> select platform_id from v$database;

PLATFORM_ID
-----------
         13


[oracle@jytest3 xtts_script]$ vi xtt.properties
tablespaces=JY
platformid=13
srcdir=SOURCEDIR
dstdir=DESTDIR
srclink=ttslink
storageondest=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/
backupformat=/ora_xtts/backupformat
stageondest=/tts/xtts
backupondest=/tts/backup
asm_home=/u01/app/product/12.2.0/crs
asm_sid=+ASM1
parallel=4
cnvinst_home=/u01/app/oracle/product/12.2.0/db
cnvinst_sid=xtt

1.6将源系统中的xttconvert脚本与xtt.properties文件复制到目标系统中
在源系统中以Oracle软件用户来进行复制

[oracle@jytest1 tts]$ scp -r oracle@10.138.130.173:/ora_xtts/xtts_script/ /tts/
The authenticity of host '10.138.130.173 (10.138.130.173)' can't be established.
ECDSA key fingerprint is 67:29:52:b1:c0:74:ff:33:fc:67:63:53:31:14:69:ec.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.173' (ECDSA) to the list of known hosts.
oracle@10.138.130.173's password:
rman_xttconvert_v3.zip                                                                                                                                                                                    100%   33KB  33.2KB/s   00:00
xttcnvrtbkupdest.sql                                                                                                                                                                                      100% 1390     1.4KB/s   00:00
xttdbopen.sql                                                                                                                                                                                             100%   71     0.1KB/s   00:00
xttdriver.pl                                                                                                                                                                                              100%  136KB 136.1KB/s   00:00
xttprep.tmpl                                                                                                                                                                                              100%   11KB  11.4KB/s   00:00
xttstartupnomount.sql                                                                                                                                                                                     100%   52     0.1KB/s   00:00
xtt.properties.jy                                                                                                                                                                                         100% 7969     7.8KB/s   00:00
xtt.properties                                                                                                                                                                                            100%  217     0.2KB/s   00:00

[oracle@jytest1 tts]$ cd xtts_script
[oracle@jytest1 xtts_script]$ ls -lrt
total 212
-rw-r--r-- 1 oracle oinstall  33949 Aug 18 23:35 rman_xttconvert_v3.zip
-rw-r--r-- 1 oracle oinstall   1390 Aug 18 23:35 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     71 Aug 18 23:35 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall 139331 Aug 18 23:35 xttdriver.pl
-rw-r--r-- 1 oracle oinstall  11710 Aug 18 23:35 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall     52 Aug 18 23:35 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall   7969 Aug 18 23:35 xtt.properties.jy
-rw-r--r-- 1 oracle oinstall    217 Aug 18 23:35 xtt.properties

1.7设置环境变量TMPDIR
在源系统与目标系统中设置环境变量TMPDIR。使用shell来执行Perl脚本xttdriver.pl所生成的文件会存储在$TMPDIR目录中,如果没有设置TMPDIR环境变量,那么生成的文件会存储在/tmp目录中。

源系统

[oracle@jytest3 ora_xtts]$ export TMPDIR=/ora_xtts/xtts_script

目标系统

[oracle@jytest1 tts]$ export TMPDIR=/tts/xtts_script

2.准备阶段
在准备阶段,要被传输的表空间会在源系统中生成备份,然后将备份传输到目标系统中,并通过执行xttdriver.pl脚本将备份还原。注意,对于要传输大量数据文件,可以使用dbms_file_transfer进行传输(可以参考文档 1389592.1中的准备阶段)会要比手动传输备份文件到目标系统中快很多。这种方法也适用于Oracle 12c,11G – Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 1389592.1).

2.1在源系统中对要传输的表空间生成备份
在源系统中,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来生成备份

[oracle@jytest3 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db
[oracle@jytest3 xtts_script]$ export ORACLE_SID=orcl

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -S
============================================================
trace file is /ora_xtts/xtts_script/setupgetfile_Aug21_Mon_20_33_36_837//Aug21_Mon_20_33_36_837_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Starting prepare phase
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'JY'  /tts/xtts
xttpreparesrc.sql for 'JY' started at Mon Aug 21 20:33:36 2017
xttpreparesrc.sql for  ended at Mon Aug 21 20:33:36 2017
Prepare source for Tablespaces:
                  ''''  /tts/xtts
xttpreparesrc.sql for '''' started at Mon Aug 21 20:33:36 2017
xttpreparesrc.sql for  ended at Mon Aug 21 20:33:36 2017

--------------------------------------------------------------------
Done with prepare phase
--------------------------------------------------------------------


[oracle@jytest3 xtts_script]$ cat xttnewdatafiles.txt
::JY
5,DESTDIR:/jy.371.952394755
[oracle@jytest3 xtts_script]$ cat getfile.sql
0,SOURCEDIR,jy.371.952394755,DESTDIR,jy_371_952394755

要被传输的一组表空间必须是online,read write状态且不包含脱机数据文件。如果在源数据库中被传输表空间的一个或多个数据文件是脱机状态或read only就会触发错误。如果表空间在整个表空间传输过程中都保持read only状态,那么就使用传统的跨平台传输表空间,不要使用跨平台增量备份传输表空间。

2.2 传输数据文件到目标系统中
在目标系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并复制上一步生成的xttnewdatafiles.txt与getfile.sql文件到目标系统并执行操作来获取数据文件

[oracle@jytest1 xtts_script]$ scp oracle@10.138.130.173:/ora_xtts/xtts_script/xttnewdatafiles.txt /tts/xtts_script/
oracle@10.138.130.173's password:
xttnewdatafiles.txt                                                                                                                                                                                       100%   33     0.0KB/s   00:00
[oracle@jytest1 xtts_script]$ scp oracle@10.138.130.173:/ora_xtts/xtts_script/getfile.sql    /tts/xtts_script/
oracle@10.138.130.173's password:
getfile.sql                                                                                                                                                                                               100%   54     0.1KB/s   00:00
[oracle@jytest1 xtts_script]$ ls -lrt
total 220
-rw-r--r-- 1 oracle oinstall   1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     52 May 24 16:57 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall  11710 May 24 16:57 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall 139331 May 24 16:57 xttdriver.pl
-rw-r--r-- 1 oracle oinstall     71 May 24 16:57 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall   7969 Jun  5 08:47 xtt.properties.jy
-rw-r--r-- 1 oracle oinstall  33949 Aug 18 23:35 rman_xttconvert_v3.zip
-rw-r--r-- 1 oracle oinstall    351 Aug 21 17:02 xtt.properties
-rw-r--r-- 1 oracle oinstall     33 Aug 21 17:17 xttnewdatafiles.txt
-rw-r--r-- 1 oracle oinstall     54 Aug 21 17:17 getfile.sql

[oracle@jytest1 xtts_script]$ export TMPDIR=/tts/xtts_script
[oracle@jytest1 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db
[oracle@jytest1 xtts_script]$ export ORACLE_SID=jy1
[oracle@jytest1 xtts_script]$ export XTTDEBUG=1
[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G
============================================================
trace file is /tts/xtts_script/getfile_Aug22_Tue_17_28_19_991//Aug22_Tue_17_28_19_991_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: backupondest
Values: /tts/backup
Key: backupformat
Values: /ora_xtts/backupformat
Key: cnvinst_sid
Values: jy1
Key: asm_sid
Values: +ASM1
Key: stageondest
Values: /tts/xtts
Key: srclink
Values: ttslink
Key: parallel
Values: 4
Key: tablespaces
Values: JY
Key: platformid
Values: 13
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: dstdir
Values: DESTDIR
Key: srcdir
Values: SOURCEDIR
Key: storageondest
Values: +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT srcdir
ARGUMENT dstdir
ARGUMENT srclink

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Getting datafiles from source
--------------------------------------------------------------------

fetchCheckDirObjectsDST: Check dir path

fetchDirEntry: remotelink not present


--------------------------------------------------------------------
Executing getfile for /tts/xtts_script/getfile_Aug22_Tue_17_28_19_991//getfile_sourcedir_jy.371.952394755_0.sql
--------------------------------------------------------------------

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
Completed getting datafiles from source
--------------------------------------------------------------------

3.前滚阶段
下面在源数据库中创建增量数据

SQL> select * from jy.jy_test;

   USER_ID
----------
         1
         2
         3
SQL> insert into jy.jy_test values(4);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from jy.jy_test;

   USER_ID
----------
         1
         2
         3
         4

在这个阶段会在源系统中对源数据库创建增量备份,将增量备份文件传输到目标系统并转换为目标系统所使用的字节序,然后将转换后的增量备份应用到数据文件。这个阶段的操作可以执行多次。每一次成功的增量备份所花的时间要比上一次的少,这将使用目标数据库中的数据文件的内容更接近源数据库的内容。在执行这个阶段操作时被传输的数据完全可以被访问。

3.1 在源系统中对被传输的表空间LDJC,CDZJ创建增量备份
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /ora_xtts/xtts_script/incremental_Aug22_Tue_21_19_39_709//Aug22_Tue_21_19_39_709_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: srclink
Values: ttslink
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: platformid
Values: 13
Key: storageondest
Values: +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: backupondest
Values: /tts/backup
Key: srcdir
Values: SOURCEDIR
Key: cnvinst_sid
Values: jy1
Key: tablespaces
Values: JY
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: backupformat
Values: /ora_xtts/backupformat
Key: parallel
Values: 4
Key: stageondest
Values: /tts/xtts

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : orcl
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

fetchCheckDirObjectsSRC: Check dir path

fetchDirEntry: remotelink not present

TABLESPACE STRING :'JY'
Prepare source for Tablespaces:
                  'JY'  /tts/xtts
xttpreparesrc.sql for 'JY' started at Tue Aug 22 21:19:39 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:19:39 2017
#DNAME:+DATA/ORCL/DATAFILE
#FNAME:jy.371.952394755
#PLAN:JY::::62924193
#TRANSFER:source_file_name=JY,+DATA/ORCL/DATAFILE,jy.371.952394755
#NEWDESTDF:5,DESTDIR:+DATA/ORCL/DATAFILE,/jy.371.952394755
#PLAN:5
verifySrcdirDatafiles: Entered
TABLESPACE STRING :''''
Prepare source for Tablespaces:
                  ''''  /tts/xtts
xttpreparesrc.sql for '''' started at Tue Aug 22 21:19:39 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:19:40 2017

verifySrcdirDatafiles: Entered
JY: +DATA/ORCL/DATAFILE/jy.371.952394755

============================================================
No new datafiles added
=============================================================
TABLESPACE STRING :'JY'
Prepare newscn for Tablespaces: 'JY'
JY::::62924193
 5
TABLESPACE STRING :''''''
Prepare newscn for Tablespaces: ''''''


--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------

/ora_xtts/xtts_script/incremental_Aug22_Tue_21_19_39_709//rmanincr.cmd

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Aug 22 21:19:40 2017

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

RMAN-06005: connected to target database: ORCL (DBID=1469612247)

RMAN> set nocfau;
2> host 'echo ts::JY';
3> backup incremental from scn 62924193
4>   tag tts_incr_update tablespace 'JY'  format
5>  '/ora_xtts/backupformat/%U';
6>
RMAN-03023: executing command: SET NOCFAU
RMAN-06009: using target database control file instead of recovery catalog

ts::JY
RMAN-06134: host command complete

RMAN-03090: Starting backup at 22-AUG-17
RMAN-08030: allocated channel: ORA_DISK_1
RMAN-08500: channel ORA_DISK_1: SID=43 device type=DISK
RMAN-08008: channel ORA_DISK_1: starting full datafile backup set
RMAN-08010: channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-08522: input datafile file number=00005 name=+DATA/ORCL/DATAFILE/jy.371.952394755
RMAN-08038: channel ORA_DISK_1: starting piece 1 at 22-AUG-17
RMAN-08044: channel ORA_DISK_1: finished piece 1 at 22-AUG-17
RMAN-08530: piece handle=/ora_xtts/backupformat/2dscipng_1_1 tag=TTS_INCR_UPDATE comment=NONE
RMAN-08540: channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
RMAN-03091: Finished backup at 22-AUG-17

Recovery Manager complete.


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=2dscipng_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

[oracle@jytest3 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/2dscipng_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@jytest3 backupformat]$ ls -lrt
total 56
-rw-r-----. 1 oracle asmadmin 57344 Aug 22 21:19 2dscipng_1_1

3.2 将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/xtts/
oracle@10.138.130.171's password:
2dscipng_1_1
                                                                                                                                                                               100%   56KB  56.0KB/s   00:00

3.3 在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttplan.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttplan.txt                                                                                                                                                                                               100%   17     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   23     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/incrbackups.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
incrbackups.txt                                                                                                                                                                                           100%   36     0.0KB/s   00:00


[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /tts/xtts_script/rollforward_Aug22_Tue_18_27_05_399//Aug22_Tue_18_27_05_399_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupformat
Values: /ora_xtts/backupformat
Key: srclink
Values: ttslink
Key: tablespaces
Values: JY
Key: parallel
Values: 4
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: cnvinst_sid
Values: xtt
Key: platformid
Values: 13
Key: stageondest
Values: /tts/xtts
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: backupondest
Values: /tts/backup
Key: srcdir
Values: SOURCEDIR

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /u01/app/oracle/product/12.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 6442450944 bytes
Fixed Size                  8807168 bytes
Variable Size            3909094656 bytes
Database Buffers         1442840576 bytes
Redo Buffers                7966720 bytes
In-Memory Area           1073741824 bytes
rdfno 5

BEFORE ROLLPLAN

datafile number : 5

datafile name   : +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/tts/backup/xib_2dscipng_1_1_5

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm /tts/backup/xib_2dscipng_1_1_5  /u01/app/product/12.2.0/crs .. +ASM1

Connected to an idle instance.
ASMCMD-8102: no connection to Oracle ASM; command requires Oracle ASM to run
ASMCMD:


--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。

3.4 为下一次增量备份判断from_scn
再次生成增量数据

SQL> insert into jy.jy_test values(5);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from jy.jy_test;

   USER_ID
----------
         1
         2
         3
         4
         5

在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /ora_xtts/xtts_script/determinescn_Aug22_Tue_21_54_18_326//Aug22_Tue_21_54_18_326_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupformat
Values: /ora_xtts/backupformat
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: tablespaces
Values: JY
Key: platformid
Values: 13
Key: stageondest
Values: /tts/xtts
Key: backupondest
Values: /tts/backup
Key: parallel
Values: 4
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: srcdir
Values: SOURCEDIR
Key: dstdir
Values: DESTDIR
Key: asm_sid
Values: +ASM1
Key: cnvinst_sid
Values: xtt
Key: srclink
Values: ttslink

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : orcl
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db
TABLESPACE STRING :'JY'
Prepare newscn for Tablespaces: 'JY'

TABLESPACE STRING :''''
Prepare newscn for Tablespaces: ''''

New /ora_xtts/xtts_script/xttplan.txt with FROM SCN's generated


New /ora_xtts/xtts_script/xttplan.txt with FROM SCN's generated
[oracle@jytest3 xtts_script]$ cat xttplan.txt
 JY::::62924193
 5

4.传输阶段
在执行传输阶段操作时,源数据库中被传输表空间要设置为read only状态,并且通过创建与应用最后一次的增量备份使用目标数据库中的数据文件与源数据库中的数据文件内容保持一致。在目标数据库数据文件与源数据库数据文件内容达成一致后,在源系统中执行正常的传输表空间操作来导出元数据,然后将元数据导入到目标数据库中。直到传输阶段操作完成之前,被传输的数据只能以read only模式被访问。

4.1 将源数据库中被传输表空间设置为read only状态
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令将表空间设置为read only:

SQL> alter tablespace jy read only;

Tablespace altered.

4.2 最后一次创建增量备份,并传输到目标系统且执行转换并应用到目标数据文件
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /ora_xtts/xtts_script/incremental_Aug22_Tue_21_57_21_478//Aug22_Tue_21_57_21_478_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: parallel
Values: 4
Key: backupformat
Values: /ora_xtts/backupformat
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: platformid
Values: 13
Key: tablespaces
Values: JY
Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: stageondest
Values: /tts/xtts
Key: srclink
Values: ttslink
Key: srcdir
Values: SOURCEDIR
Key: backupondest
Values: /tts/backup
Key: dstdir
Values: DESTDIR
Key: asm_sid
Values: +ASM1
Key: cnvinst_sid
Values: xtt

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : orcl
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

fetchCheckDirObjectsSRC: Check dir path

fetchDirEntry: remotelink not present

TABLESPACE STRING :'JY'
Prepare source for Tablespaces:
                  'JY'  /tts/xtts
xttpreparesrc.sql for 'JY' started at Tue Aug 22 21:57:21 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:57:21 2017
#DNAME:+DATA/ORCL/DATAFILE
#FNAME:jy.371.952394755
#PLAN:JY::::62928997
#TRANSFER:source_file_name=JY,+DATA/ORCL/DATAFILE,jy.371.952394755
#NEWDESTDF:5,DESTDIR:+DATA/ORCL/DATAFILE,/jy.371.952394755
#PLAN:5
verifySrcdirDatafiles: Entered
TABLESPACE STRING :''''
Prepare source for Tablespaces:
                  ''''  /tts/xtts
xttpreparesrc.sql for '''' started at Tue Aug 22 21:57:21 2017
xttpreparesrc.sql for  ended at Tue Aug 22 21:57:21 2017

verifySrcdirDatafiles: Entered
JY: +DATA/ORCL/DATAFILE/jy.371.952394755

============================================================
No new datafiles added
=============================================================
TABLESPACE STRING :'JY'
Prepare newscn for Tablespaces: 'JY'
JY::::62928997
 5
TABLESPACE STRING :''''''
Prepare newscn for Tablespaces: ''''''


--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------

/ora_xtts/xtts_script/incremental_Aug22_Tue_21_57_21_478//rmanincr.cmd

Recovery Manager: Release 12.2.0.1.0 - Production on Tue Aug 22 21:57:21 2017

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

RMAN-06005: connected to target database: ORCL (DBID=1469612247)

RMAN> set nocfau;
2> host 'echo ts::JY';
3> backup incremental from scn 62924193
4>   tag tts_incr_update tablespace 'JY'  format
5>  '/ora_xtts/backupformat/%U';
6>
RMAN-03023: executing command: SET NOCFAU
RMAN-06009: using target database control file instead of recovery catalog

ts::JY
RMAN-06134: host command complete

RMAN-03090: Starting backup at 22-AUG-17
RMAN-08030: allocated channel: ORA_DISK_1
RMAN-08500: channel ORA_DISK_1: SID=43 device type=DISK
RMAN-08008: channel ORA_DISK_1: starting full datafile backup set
RMAN-08010: channel ORA_DISK_1: specifying datafile(s) in backup set
RMAN-08522: input datafile file number=00005 name=+DATA/ORCL/DATAFILE/jy.371.952394755
RMAN-08038: channel ORA_DISK_1: starting piece 1 at 22-AUG-17
RMAN-08044: channel ORA_DISK_1: finished piece 1 at 22-AUG-17
RMAN-08530: piece handle=/ora_xtts/backupformat/2esciru5_1_1 tag=TTS_INCR_UPDATE comment=NONE
RMAN-08540: channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
RMAN-03091: Finished backup at 22-AUG-17

Recovery Manager complete.


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=2esciru5_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

[oracle@jytest3 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/2esciru5_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@jytest3 backupformat]$ ls -lrt
total 112
-rw-r-----. 1 oracle asmadmin 57344 Aug 22 21:19 2dscipng_1_1
-rw-r-----. 1 oracle asmadmin 57344 Aug 22 21:57 2esciru5_1_1

将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/xtts/
oracle@10.138.130.171's password:
2dscipng_1_1
                                                                                                                                                                               100%   56KB  56.0KB/s   00:00

在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/xtts/
oracle@10.138.130.171's password:
2esciru5_1_1                                                                                                                                                                                              100%   56KB  56.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttplan.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttplan.txt                                                                                                                                                                                               100%   19     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   23     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/incrbackups.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
incrbackups.txt                                                                                                                                                                                           100%   36     0.0KB/s   00:00

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /tts/xtts_script/rollforward_Aug22_Tue_18_38_06_743//Aug22_Tue_18_38_06_743_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: dstdir
Values: DESTDIR
Key: stageondest
Values: /tts/xtts
Key: platformid
Values: 13
Key: parallel
Values: 4
Key: backupformat
Values: /ora_xtts/backupformat
Key: asm_home
Values: /u01/app/product/12.2.0/crs
Key: cnvinst_sid
Values: xtt
Key: srclink
Values: ttslink
Key: srcdir
Values: SOURCEDIR
Key: asm_sid
Values: +ASM1
Key: tablespaces
Values: JY
Key: backupondest
Values: /tts/backup

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /u01/app/oracle/product/12.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 6442450944 bytes
Fixed Size                  8807168 bytes
Variable Size            3892317440 bytes
Database Buffers         1459617792 bytes
Redo Buffers                7966720 bytes
In-Memory Area           1073741824 bytes
rdfno 5

BEFORE ROLLPLAN

datafile number : 5

datafile name   : +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/tts/backup/xib_2esciru5_1_1_5

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm /tts/backup/xib_2esciru5_1_1_5  /u01/app/product/12.2.0/crs .. +ASM1

Connected to an idle instance.
ASMCMD-8102: no connection to Oracle ASM; command requires Oracle ASM to run
ASMCMD:


--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

4.3 在目标数据库中导入元数据
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来生成Data Pump TTS命令:

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -e
============================================================
trace file is /tts/xtts_script/generate_Aug22_Tue_18_39_22_670//Aug22_Tue_18_39_22_670_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: cnvinst_home
Values: /u01/app/oracle/product/12.2.0/db
Key: cnvinst_sid
Values: xtt
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: platformid
Values: 13
Key: backupondest
Values: /tts/backup
Key: parallel
Values: 4
Key: stageondest
Values: /tts/xtts
Key: tablespaces
Values: JY
Key: srclink
Values: ttslink
Key: srcdir
Values: SOURCEDIR
Key: backupformat
Values: /ora_xtts/backupformat
Key: asm_home
Values: /u01/app/product/12.2.0/crs

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jy1
ORACLE_HOME : /u01/app/oracle/product/12.2.0/db

--------------------------------------------------------------------
Generating plugin
--------------------------------------------------------------------


--------------------------------------------------------------------
Done generating plugin file /tts/xtts_script/xttplugin.txt
--------------------------------------------------------------------

[oracle@jytest1 xtts_script]$ cat xttplugin.txt
impdp directory= logfile= \
network_link= transport_full_check=no \
transport_tablespaces=JY \
transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755'

上面的命令会生成一个名叫xttplugin.txt的文件,文件创建了一个使用network_link参数执行传输表空间导入元数据的命令。命令中的transport_tablespaces与transport_datafiles参数已经设置正确。注意network_link模式指示导入通过使用dblink来完成,就不需要执行导出或使用dump文件。如果选择执行这个命令来完成表空间的传输就需要修改directory,logfile与network_link参数

SQL> create directory dump_dir as '/tts/xtts_script';

Directory created.
SQL> grant read,write on directory dump_dir to public;

Grant succeeded.


在目标数据库中创建用户方案jy

SQL> create user jy identified by "jy";

User created.

SQL> grant dba,connect,resource to jy;

Grant succeeded.

[oracle@jytest1 xtts_script]$ impdp  system/abcd@jypdb directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=JY transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755'

Import: Release 12.2.0.1.0 - Production on Tue Aug 22 18:45:00 2017

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

Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03":  system/********@jypdb directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=JY transport_datafiles=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_371_952394755
Source time zone is +08:00 and target time zone is +00:00.
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03" successfully completed at Tue Aug 22 18:46:20 2017 elapsed 0 00:01:11


[oracle@jytest1 xtts_script]$ impdp system/abcd@jypdb directory=dump_dir logfile=ysj.log  content=metadata_only exclude=table,index network_link=ttslink

Import: Release 12.2.0.1.0 - Production on Tue Aug 22 18:47:22 2017

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

Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/********@jypdb directory=dump_dir logfile=ysj.log content=metadata_only exclude=table,index network_link=ttslink
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" successfully completed at Tue Aug 22 18:47:49 2017 elapsed 0 00:00:21

5.验证传输数据
5.1检查表空间是否有损坏

[oracle@jytest1 xtts_script]$ rman target sys/abcd@jypdb

Recovery Manager: Release 12.2.0.1.0 - Production on Sat Aug 19 01:17:35 2017

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

connected to target database: JY:JYPDB (DBID=2825277312)

RMAN> validate tablespace jy check logical;

Starting validate at 19-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1144 instance=jy1 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00083 name=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_5.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:07
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
83   OK     0              1            64001           1590987
  File Name: +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_5.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              5
  Index      0              0
  Other      0              63994

Finished validate at 19-AUG-17

5.2将目标数据库中的表空间JY修改为read write状态

SQL> alter tablespace jy read write;

Tablespace altered.

6.清除操作
如果使用单独的转换home与实例,那么可以关闭转换实例并删除转换home。还可以删除源系统中创建的backupformat目录,目标系统中创建的bacup目录,源系统与目标系统中设置的环境变量$TMPDIR。

xttdriver.pl脚本选项
–backup:对源数据库中要被传输的表空间创建level 0级备份。这些备份将被写到xtt.properties文件中backupoformat参数所指定的目录中。这些备份需要手动复制到目标系统中stageondest参数所指定的目录中。而且还会生成tsbkupmap.txt与xttnewdatafiles.txt文件并且也需要复制到目标系统中相应目录(TMPDIR变量所指向的目录)

–restore:在目标系统中还原并转换stageondest目录中的数据文件备份的副本。还原的文件将会存储到storageondest参数所指定的目录中

–bkpincr:在源系统中对表空间创建增量备份并存储在backupformat参数所指定的目录中。这步操作还会创建incrbackups.txt文件它列出了所创建的备份。这个文件与tsbkupmap.txt必须复制到目标系统中的stageondest参数所指定的目录中

-recover:将增量备份应用到已经还原的数据文件上

-s:对源数据库判断新的from_scn可以执行一次或多次。这个操作将会计算下一个from_scn,并记录在xttplan.txt文件中,然后使用创建增量备份时会使用。

-bkpexport:将执行最后一次增量备份并且会创建元数据的dump文件用来导入数据文件。增量备份将会存储在backupformat参数所指定的目录中并且会创建incrbckups.txt与tsbkupmaps.txt文件,这些都要复制到目标系统中

–resincrdmp:将恢复最后一次增量备份并应用到数据文件。同时dump文件会被还原到TMPDIR变量所指定的目录中,dump文件可以用来导入

-e:在目标系统中生成传输表空间要导入的元数据脚本

-d debug:为了以debug模式来执行xttdriver.pl 与RMAN脚本。也可以设置环境变量XTTDEBUG=1,debug级别可以为1,2,3,例如xttdriver.pl -3

xtt.properties文件参数说明
tablespaces:用逗号来分隔从源数据库要被传输到目标数据库的表空间列表,例如tablespaces=TS1,TS2

platformid:从v$database.platform_id获得的源数据库的platform id,例如platformid=13

backupformat:源系统中存储备份文件的目录。这个目录必须要有足够的空间来存储所有创建的备份与增量备份文件。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。例如,backupformat=/stage_source

stageondest:目标系统中存储从源系统中手动传输过来的数据文件副本。这个目录要有足够的空间来存储数据文件副本。这个目录同时也是用来存储从源系统传输过来的增量备份文件的目录。在目标系统上执行xttdriver.pl -c转换数据文件与执行xttdriver.pl -r前滚数据文件时会从这个目录中读取数据文件副本与增量备份文件。这个目标也可以是一个DBFS-mounted文件系统。个目录可以是源系统上通过NFS-mounted文件系统所挂载到目标系统中的一个目录,在这种情况下,源系统中的backupformat参数与dfcopydir参数就会引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。例如stageondest=/stage_dest

storageondest:目标系统中用来存储xttdriver.pl -c转换操作后所生成的数据文件副本的目录,也就是目标数据库最终存储数据文件的目录。这个目录要有足够的空间来永久存储数据文件。这个参数当使用RMAN备份来生成初始化数据文件副本时才使用,例如
storageondest=+DATA或者storageondest=/oradata/test

asm_home:目标系统中ASM实例的ORACLE_HOME。注意如果backupondest设置为文件系统目录,那么就要删除asm_home与asm_sid参数,例如asm_home=/u01/app/11.2.0.4/grid

asm_sid:目标系统中ASM实例的ORACLE_SID。例如asm_sid=+ASM1

parallel:定义rmanconvert.cmd命令文件中rman convert命令的并行度。如果不设置这个参数,那么xttdriver.pl将使用parallel=8的缺省并行度。例如,parallel=3

Oracle 12C xtts and rman

这篇文章将介绍在12c及更高的版本中,为了在不同字节序的系统之间迁移数据使用跨平台增量备份传输表空间迁移数据将会使用最少的停机时间。

使用跨平台增量备份传输表空间迁移数据的第一步就是在源系统中对源数据库生成一个完全备份副本。然后,使用一系列的增量备份,每一次增量备份都会比上一次的小,在停机之前,目标数据库中的数据已经非常接近源数据库中的数据。只有最后一次增量备份与导出\导入元数据才需要源数据库停机。

跨平台增量备份功能不会影响XTTS的其它操作所花费的时间,比如元数据导出\导入的时间。因此,数据库有大量元数据(DDL语句)时,像Oracle E-Business Suite与其它的包应用程序,它们将是影响跨平台增量备份传输表空间迁移数据效率的关键,因为这种迁移最终停机时间由于导出\导入元数据操作所决定的,而不是由传输数据文件与转换数据文件而决定的。

只有物理存储在被传输表空间中的数据库对象会被复制到目标系统中。如果需要传输存储在不同表空间中的(比如,pl/sql对象,序列等,存储在system表空间中的对象)其它对象,可以data pump将这些对象复制到目标系统中。

跨平台增量备份传输表空间的主要操作如下:
1.初始化阶段
2.准备阶段(源数据处于online状态)
2.1对被传输的表空间生成(level=0)的备份
2.2传输备份文件与其它需要的配置文件到目标系统中
2.3将数据文件还原到目标系统,并且转换为目标系统所使用的字节序

3.前滚阶段(源数据处于online状态,为了使用目标数据文件的内容接近源数据库的内容可以执行多次前滚操作)
3.1在源系统中创建增量备份
3.2将增量备份文件与其它的配置文件传输到目标系统中
3.3在目标系统中将增量备份文件转换为目标系统所使用的字节序并应用到数据文件副本
3.4在源系统中执行操作来决定下一次增量备份的开始scn(from_scn)
3.5重复该阶段操作直到准备执行传输阶段的操作为止

注意,在版本3的转换脚本中,如果向被传输的表空间增加数据文件,或者向xtt.properties文件中的tablespaces参数增加新的表空间名,将会要执行额外的指令。

4.传输阶段
4.1将源数据库中要被传输的表空间设置为read only状态
4.2执行最后一次前滚操操作,这步操作将使用目标数据库中的数据文件的内容与源数据库中数据文件的内容保持一致。当处理大量数据时,
这步操作所花费的时间要比传统的XTTS方法所用的时间更短,因为增量备份的大小更小。
4.3使用data pump将被传输的表空间所存的对象的元数据导入到目标数据库中
4.4将目标数据库中被传输过来的表空间设置为read write状态

这篇文章提供了一个例子来介绍如何使用跨平台增量备份来减少传输表空间的停机时间。

源系统可以是先决条件所引用的和平台与数据库所满足的列表中所列出任何平台。如果从一种小字节序平台迁移到Oracle Linux,那么最应该考虑的方法是使用Data Guard,可以参考Note 413484.1关于在当前小字节序平台与Oracle Linux之间Data Guard所支持的异构平台。

这里将介绍如何从Aix平台上将表空间cdzj,ldjc使用跨平台增量备份的传输表空间方法来迁移到Oracle Linux平台。在执行完初始化阶段后执行以下三个阶段来执行数据的迁移操作:
准备阶段
在准备阶段,在源系统上会对要被传输的表空间的数据文件生成level=0的备份。备份文件会被传输到目标系统中,然后将数据文件还原并转换后目标系统所使用的字节序。

前滚阶段
在前滚阶段,在准备阶段被转换后的数据文件将会使用来自源数据库的增量备份来进行前滚操作。通过多次执行该阶段的操作,每次成功的增量备份将会更小与更快的应用到数据文件副本,允许目标系统中的数据都是来自源系统中。在执行前滚阶段时应用程序可以完全访问源数据。

传输阶段
在传输阶段,在源数据库中将要被传输的表空间设置为read only状态,并且在源平台上执行最后一次增量备份并且将它传输到目标平台上并应用到数据文件副本,使用目标系统中的数据文件副本与源数据库中的数据文件保护一致。一旦数据文件状态一致,从源数据库中导出所传输表空间所存储对象的元数据,并且在目标平台导入这些元数据。最后在目标数据库中将传输过来的表空间设置为read write状态。在传输阶段应用程序是不能更新源数据的。

跨平台增量备份所支持的脚本
跨平台增量备份的核心功能是基于Oracle 11.2.0.4与之后的版本。这时所介绍的操作只能用于Oracle 12c,12.1及之后的版本,请查看条件与建议部分了解详细信息。。另外有一组支持脚本存储在rman-xttconvert_2.0.zip。其中有两个主要支持的脚本:
.Perl脚本xttdriver.pl 这个脚本用来执行跨平台增量备份传输表空间的主要步骤。
.参数文件xtt.properties 这个文件包含自已平台特定配置

执行跨平台增量备份传输表空间的条件与建议
执行跨平台增量备份传输表空间的条件
在执行跨平台增量备份传输表空间之前需要检查是否满足以下条件:
.传输表空间的限制
.其它必须满足的条件
当前版本不支持windows
源数据库的compatible参数必须设置为12.1.0或更高版本
源数据库的compatible参数必须不能比目标数据库的compatible参数的值大
源数据库必须启用了archivelog模式
源数据库的RMAN不能对DEVICE TYPE DISK使用COMPRESSED配置
目标数据库的compatible参数必须设置为12.1.0或更高版本
源数据库中将要被迁移的表空间必须是online,并且不能包含脱机数据文件。表空间必须为read write状态。表空间为read only那么可以使用正常的XTTS方法进行迁移。
尽管首选目标系统是Linux操作系统(可以是64位的Oracle Linux或者是已经认证的Redhat Linux),但这个过程也可以在其它Unix操作系统中执行。然而,对于任何non-Linux操作系统来说数据库的版本必须是12.1.0.1或更高的版本。
源数据库的版本必须小于或等于目标数据库的版本

.所有步骤中执行操作的用户必须是Oracle用户并且它是OSDBA组的成员。操作系统审计被用来连接源数据库与目标数据库。
.对于备库或快照备库是不支持这种操作的
.这种方法不支持多租户数据库。增强bug 22570430解决了这个限制。

诊断
为了启用诊断模式,可以使用-d参数来执行xttdriver.pl脚本,或者在执行xttdriver.pl脚本之前设置环境变量XTTDEBUG=1。Debug模式会启用额外的屏幕输出并且造成所有RMAN操作使用debug命令行选项。

已知问题
1.如果前滚阶段(xttdriver.pl -r)失败并显示以下错误信息,那么验证RMAN的DEVICE TYPE DISK不能使用COMPRESSED配置

Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: RestoreSetPiece
DECLARE
*
ERROR at line 1:
ORA-19624: operation failed, retry possible
ORA-19870: error while restoring backup piece
/dbfs_direct/FS1/xtts/incrementals/xtts_incr_backup
ORA-19608: /dbfs_direct/FS1/xtts/incrementals/xtts_incr_backup is not a backup
piece
ORA-19837: invalid blocksize 0 in backup piece header
ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 2338
ORA-06512: at line 40

使用跨平台增量备份来减少传输表空间的时间
使用跨平台增量备份来传输表空间主要有以下几个阶段:
1.初始化设置阶段
2.准备阶段
3.前滚阶段
4.最后的增量备份阶段
5.传输阶段导入元数据
6.验证传输的数据
7.清除操作

1.初始化设置阶段
1.1安装目标数据库软件并创建目标数据库
在目标系统上安装目标Oracle数据库软件,版本应该为Oracle12c,操作系统是Linux,我这里都是12.2.0.1。在源数据库中创建了一个要被传输到目标数据库的表空间jy,用户方案jy,源数据库版本也是12.2.0.1,操作系统是Linux。

1.2识别要被传输的表空间
源数据库中要被传输的表空间为jy,用户方案jy。

1.3在源系统上安装xttconvert脚本

[oracle@jytest3 xtts_script]$ unzip rman_xttconvert_v3.zip
Archive:  rman_xttconvert_v3.zip
  inflating: xtt.properties
  inflating: xttcnvrtbkupdest.sql
  inflating: xttdbopen.sql
  inflating: xttdriver.pl
  inflating: xttprep.tmpl
 extracting: xttstartupnomount.sql

1.4 创建需要使用的目录
在源系统中创建目录/ora_xtts/backupformat用来存储源系统中对源数据库生成的备份及增量备份文件,xtt.properties文件中的backupformat参数设置该目录。

[oracle@jytest3 ora_xtts]$ mkdir backupformat

在目标系统中创建目录/tts/backup用来存储手动从源系统中传输过来的备份及增量备份文件,xtt.properties文件中的stageondest参数设置该目录。

[oracle@jytest1 tts]$ mkdir backup

xtt.properties文件中的storageondest参数设置目标数据库最终存储数据文件的目录,这里是+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/目录。

1.5在源系统中配置xtt.properties文件

SQL> select platform_id from v$database;

PLATFORM_ID
-----------
         13


[oracle@jytest3 xtts_script]$ vi xtt.properties
tablespaces=JY
platformid=13
storageondest=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/
backupformat=/ora_xtts/backupformat
stageondest=/tts/backup
asm_home=/u01/app/product/12.2.0/crs
asm_sid=+ASM1
parallel=4

1.6将源系统中的xttconvert脚本与xtt.properties文件复制到目标系统中
在源系统中以Oracle软件用户来进行复制

[oracle@jytest1 tts]$ scp -r oracle@10.138.130.173:/ora_xtts/xtts_script/ /tts/
The authenticity of host '10.138.130.173 (10.138.130.173)' can't be established.
ECDSA key fingerprint is 67:29:52:b1:c0:74:ff:33:fc:67:63:53:31:14:69:ec.
Are you sure you want to continue connecting (yes/no)? yes
Warning: Permanently added '10.138.130.173' (ECDSA) to the list of known hosts.
oracle@10.138.130.173's password:
rman_xttconvert_v3.zip                                                                                                                                                                                    100%   33KB  33.2KB/s   00:00
xttcnvrtbkupdest.sql                                                                                                                                                                                      100% 1390     1.4KB/s   00:00
xttdbopen.sql                                                                                                                                                                                             100%   71     0.1KB/s   00:00
xttdriver.pl                                                                                                                                                                                              100%  136KB 136.1KB/s   00:00
xttprep.tmpl                                                                                                                                                                                              100%   11KB  11.4KB/s   00:00
xttstartupnomount.sql                                                                                                                                                                                     100%   52     0.1KB/s   00:00
xtt.properties.jy                                                                                                                                                                                         100% 7969     7.8KB/s   00:00
xtt.properties                                                                                                                                                                                            100%  217     0.2KB/s   00:00

[oracle@jytest1 tts]$ cd xtts_script
[oracle@jytest1 xtts_script]$ ls -lrt
total 212
-rw-r--r-- 1 oracle oinstall  33949 Aug 18 23:35 rman_xttconvert_v3.zip
-rw-r--r-- 1 oracle oinstall   1390 Aug 18 23:35 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     71 Aug 18 23:35 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall 139331 Aug 18 23:35 xttdriver.pl
-rw-r--r-- 1 oracle oinstall  11710 Aug 18 23:35 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall     52 Aug 18 23:35 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall   7969 Aug 18 23:35 xtt.properties.jy
-rw-r--r-- 1 oracle oinstall    217 Aug 18 23:35 xtt.properties

1.7设置环境变量TMPDIR
在源系统与目标系统中设置环境变量TMPDIR。使用shell来执行Perl脚本xttdriver.pl所生成的文件会存储在$TMPDIR目录中,如果没有设置
TMPDIR环境变量,那么生成的文件会存储在/tmp目录中。

源系统

[oracle@jytest3 ora_xtts]$ export TMPDIR=/ora_xtts/xtts_script

目标系统

[oracle@jytest1 tts]$ export TMPDIR=/tts/xtts_script

2.准备阶段
在准备阶段,要被传输的表空间会在源系统中生成备份,然后将备份传输到目标系统中,并通过执行xttdriver.pl脚本将备份还原。注意,对于要传输大量数据文件,可以使用dbms_file_transfer进行传输(可以参考文档 1389592.1中的准备阶段)会要比手动传输备份文件到目标系统中快很多。这种方法也适用于Oracle 12c,11G – Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup (Doc ID 1389592.1).

2.1在源系统中对要传输的表空间生成备份
在源系统中,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来生成备份

[oracle@jytest3 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db
[oracle@jytest3 xtts_script]$ export ORACLE_SID=orcl

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --backup
============================================================
trace file is /ora_xtts/xtts_script/backup_Aug19_Sat_03_17_33_312//Aug19_Sat_03_17_33_312_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Starting prepare phase
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'JY'  /tts/backup
xttpreparesrc.sql for 'JY' started at Sat Aug 19 03:17:33 2017
xttpreparesrc.sql for  ended at Sat Aug 19 03:17:34 2017
Prepare source for Tablespaces:
                  ''''  /tts/backup
xttpreparesrc.sql for '''' started at Sat Aug 19 03:17:40 2017
xttpreparesrc.sql for  ended at Sat Aug 19 03:17:40 2017

--------------------------------------------------------------------
Done with prepare phase
--------------------------------------------------------------------


--------------------------------------------------------------------
Find list of datafiles in system
--------------------------------------------------------------------


--------------------------------------------------------------------
Done finding list of datafiles in system
--------------------------------------------------------------------

[oracle@jytest3 backupformat]$ ls -lrt
total 1072
-rw-r-----. 1 oracle asmadmin 1097728 Aug 19 03:17 JY_5_25sc8t6j_1_1.bkp

[oracle@jytest3 xtts_script]$ cat xttplan.txt
JY::::1586999
5
[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
::5:::1=JY_5_25sc8t6j_1_1.bkp
[oracle@jytest3 xtts_script]$ cat xttnewdatafiles.txt
::JY
5,+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile//JY_5.dbf

2.2将备份文件传输到目标系统
将上一步生成的备份文件从源系统中的backupformat目录(/ora_xtts/backupformat)传输到目标系统中的stageondest目录(/tts/backup)

[oracle@jytest3 backupformat]$ scp /ora_xtts/backupformat/* oracle@10.138.130.171:/tts/backup/
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.
oracle@10.138.130.171's password:
JY_5_25sc8t6j_1_1.bkp                                                                                                                                                                                     100% 1072KB   1.1MB/s   00:00

[oracle@jytest1 backup]$ ls -lrt
total 1072
-rw-r----- 1 oracle oinstall 1097728 Aug 18 23:58 JY_5_25sc8t6j_1_1.bkp

将上一步生成的tsbkupmap.txt与xttnewdatafiles.txt文件传到目标系统中的$TMPDIR目录(/tts/xtts_script)

[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   30     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttnewdatafiles.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttnewdatafiles.txt                                                                                                                                                                                       100%   68     0.1KB/s   00:00


[oracle@jytest1 xtts_script]$ ls -lrt
total 220
-rw-r--r-- 1 oracle oinstall  33949 Aug 18 23:35 rman_xttconvert_v3.zip
-rw-r--r-- 1 oracle oinstall   1390 Aug 18 23:35 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     71 Aug 18 23:35 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall 139331 Aug 18 23:35 xttdriver.pl
-rw-r--r-- 1 oracle oinstall  11710 Aug 18 23:35 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall     52 Aug 18 23:35 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall   7969 Aug 18 23:35 xtt.properties.jy
-rw-r--r-- 1 oracle oinstall    217 Aug 18 23:35 xtt.properties
-rw-r--r-- 1 oracle oinstall     30 Aug 19 00:02 tsbkupmap.txt
-rw-r--r-- 1 oracle oinstall     68 Aug 19 00:03 xttnewdatafiles.txt

2.3在目标系统中还原数据文件
在目标系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下还原操作:

[oracle@jytest1 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/12.2.0/db
[oracle@jytest1 xtts_script]$ export ORACLE_SID=jy1

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --restore
============================================================
trace file is /tts/xtts_script/restore_Aug19_Sat_00_06_38_642//Aug19_Sat_00_06_38_642_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Start restore/recover
--------------------------------------------------------------------


--------------------------------------------------------------------
End of restore/recover phase
--------------------------------------------------------------------

数据文件将会存储到storageondest参数所指定目录中

ASMCMD [+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile] > ls -lt
Type      Redund  Striped  Time             Sys  Name
DATAFILE  UNPROT  COARSE   AUG 19 00:00:00  N    jy_5.dbf => +DATA/jy/4D98CBB596437310E053AD828A0A6B56/DATAFILE/JY.317.952387605

3.前滚阶段
在这个阶段会在源系统中对源数据库创建增量备份,将增量备份文件传输到目标系统并转换为目标系统所使用的字节序,然后将转换后的增量备份应用到数据文件。这个阶段的操作可以执行多次。每一次成功的增量备份所花的时间要比上一次的少,这将使用目标数据库中的数据文件的内容更接近源数据库的内容。在执行这个阶段操作时被传输的数据完全可以被访问。

3.1在源系统中创建增量备份
在源系统中,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来生成增量备份

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpinc
============================================================
trace file is /ora_xtts/xtts_script/bkpincr_Aug19_Sat_03_37_38_757//Aug19_Sat_03_37_38_757_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'JY'
Prepare newscn for Tablespaces: ''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作将会创建增量备份文件,并会创建以下文件

xttplan.txt
tsbkupmap.txt
incrbackups.txt

[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=26sc8uc7_1_1
[oracle@jytest3 xtts_script]$ cat xttplan.txt
JY::::1586999
5
[oracle@jytest3 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/26sc8uc7_1_1

3.2将增量备份文件传输到目标系统中

[oracle@jytest3 xtts_script]$  scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/backup/
oracle@10.138.130.171's password:
26sc8uc7_1_1                                                                                                                                                                                              100%   48KB  48.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttplan.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttplan.txt                                                                                                                                                                                               100%   16     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   23     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/incrbackups.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
incrbackups.txt                                                                                                                                                                                           100%   36     0.0KB/s   00:00


[oracle@jytest1 backup]$ ls -lrt
total 1120
-rw-r----- 1 oracle oinstall 1097728 Aug 18 23:58 JY_5_25sc8t6j_1_1.bkp
-rw-r----- 1 oracle oinstall   49152 Aug 19 00:18 26sc8uc7_1_1

[oracle@jytest1 xtts_script]$ cat xttplan.txt
JY::::1586999
5
[oracle@jytest1 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=26sc8uc7_1_1
[oracle@jytest1 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/26sc8uc7_1_1

如果源系统中的backupformat目录是目标系统中stageondest目录通过NFS挂载到源系统中的话,那么就不需要复制这些备份文件目标系统就可以使用。然而,(xttplan.txt,tsbkupmap.txt,incrbackups.txt)文件在每次增量备份后都需要传输到目标系统中。

3.3在目标系统将增量备份应用到数据文件
在目标系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来执行前滚操作:

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --recover
============================================================
trace file is /tts/xtts_script/recover_Aug19_Sat_00_25_22_517//Aug19_Sat_00_25_22_517_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Start restore/recover
--------------------------------------------------------------------


--------------------------------------------------------------------
End of restore/recover phase
--------------------------------------------------------------------

3.4生成下一次增量备份需要的from_scn
在源系统中,为了以后生成增量备份,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来生成新的from_scn:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /ora_xtts/xtts_script/determinescn_Aug19_Sat_03_51_12_712//Aug19_Sat_03_51_12_712_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'JY'
Prepare newscn for Tablespaces: ''''
New /ora_xtts/xtts_script/xttplan.txt with FROM SCN's generated

这步操作会计算新的from_scn,并将其记录到xttplan.txt文件,在下次生成增量备份时将会使用。

[oracle@jytest3 xtts_script]$ cat xttplan.txt
 JY::::1587737
 5

3.5 再次重复前滚阶段或执行传输阶段
这里有两种选择:
1.如果如果将目标数据库中的数据文件与源数据库中的数据文件进行最接近的同步,那么就重复执行前滚操作。
2.如果目标数据库中的数据文件与源数据库中的数据文件已经达到所期望的接近,那么执行传输阶段的操作。

注意:如果从上一次增量备份后增加了一个新的表空间或者一个新的表空间名增加到xtt.properties文件中,那么将会出现以下错误:

Error:
------
The incremental backup was not taken as a datafile has been added to the tablespace:

Please Do the following:
--------------------------
1. Copy fixnewdf.txt from source to destination temp dir

2. Copy backups:

from  to the  in destination

3. On Destination, run $ORACLE_HOME/perl/bin/perl xttdriver.pl --fixnewdf

4. Re-execute the incremental backup in source:
$ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpincr

NOTE: Before running incremental backup, delete FAILED in source temp dir or
run xttdriver.pl with -L option:

$ORACLE_HOME/perl/bin/perl xttdriver.pl -L --bkpincr

These instructions must be followed exactly as listed. The next incremental backup will include the new datafile.

我这里再次执行前滚操作

SQL> select * from jy_test;

no rows selected

SQL> insert into jy_test values(1);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from jy_test;

   USER_ID
----------
         1

在源系统中创建增量备份
在源系统中,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来生成增量备份

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpinc
============================================================
trace file is /ora_xtts/xtts_script/bkpincr_Aug19_Sat_03_55_51_357//Aug19_Sat_03_55_51_357_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'JY'
Prepare newscn for Tablespaces: ''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作将会创建增量备份文件,并会创建以下文件
xttplan.txt
tsbkupmap.txt
incrbackups.txt

[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=27sc8vec_1_1
[oracle@jytest3 xtts_script]$ cat xttplan.txt
 JY::::1587737
 5
[oracle@jytest3 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/27sc8vec_1_1

3.2将增量备份文件传输到目标系统中

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/backup/
oracle@10.138.130.171's password:
27sc8vec_1_1                                                                                                                                                                                              100%  128KB 128.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttplan.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttplan.txt                                                                                                                                                                                               100%   18     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   23     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/incrbackups.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
incrbackups.txt                                                                                                                                                                                           100%   36     0.0KB/s   00:00


[oracle@jytest1 backup]$ ls -lrt
total 1248
-rw-r----- 1 oracle oinstall 1097728 Aug 18 23:58 JY_5_25sc8t6j_1_1.bkp
-rw-r----- 1 oracle oinstall   49152 Aug 19 00:18 26sc8uc7_1_1
-rw-r----- 1 oracle oinstall  131072 Aug 19 00:33 27sc8vec_1_1

[oracle@jytest1 xtts_script]$ cat xttplan.txt
 JY::::1587737
 5
[oracle@jytest1 xtts_script]$ cat tsbkupmap.txt
JY::5:::1=27sc8vec_1_1
[oracle@jytest1 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/27sc8vec_1_1

如果源系统中的backupformat目录是目标系统中stageondest目录通过NFS挂载到源系统中的话,那么就不需要复制这些备份文件目标系统就可以使用。然而,(xttplan.txt,tsbkupmap.txt,incrbackups.txt)文件在每次增量备份后都需要传输到目标系统中。

3.3在目标系统将增量备份应用到数据文件
在目标系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来执行前滚操作:

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --recover
============================================================
trace file is /tts/xtts_script/recover_Aug19_Sat_00_35_56_534//Aug19_Sat_00_35_56_534_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Start restore/recover
--------------------------------------------------------------------


--------------------------------------------------------------------
End of restore/recover phase
--------------------------------------------------------------------

3.4生成下一次增量备份需要的from_scn
在源系统中,为了以后生成增量备份,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来生成新的from_scn:

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /ora_xtts/xtts_script/determinescn_Aug19_Sat_04_00_04_92//Aug19_Sat_04_00_04_92_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'JY'
Prepare newscn for Tablespaces: ''''
New /ora_xtts/xtts_script/xttplan.txt with FROM SCN's generated

这步操作会计算新的from_scn,并将其记录到xttplan.txt文件,在下次生成增量备份时将会使用。

[oracle@jytest3 xtts_script]$ cat xttplan.txt
 JY::::1588547
 5

4.最后一次增量备份
在这个阶段,需要将源数据库中要被传输的表空间设置为read only状态,通过创建与应用最后一次增量备份使用目标数据文件与源数据库的内容达到一致状态。然后可以使用正常的传输表空间操作来从源数据库中导出元数据并导入目标数据库,直到这个阶段的操作完成之前源数据库中被传输的表空间会处于read only状态。

4.1 将源数据库中的表空间JY设置为read only状态
在源系统中,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下操作:

SQL> insert into jy_test values(2);

1 row created.

SQL> commit;

Commit complete.

SQL> select * from jy_test;

   USER_ID
----------
         1
         2

SQL> alter tablespace jy read only;

Tablespace altered.

4.2创建最后一次的增量备份并将相关文件传输到目标系统
在源系统中,以oracle软件用户登录,并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来生成最后的增量备份

[oracle@jytest3 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpexport
============================================================
trace file is /ora_xtts/xtts_script/bkpexport_Aug19_Sat_04_06_32_838//Aug19_Sat_04_06_32_838_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'JY'
Prepare newscn for Tablespaces: ''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作将会创建增量备份文件,并会创建以下文件
xttplan.txt
tsbkupmap.txt
incrbackups.txt

[oracle@jytest3 xtts_script]$ cat xttplan.txt
 JY::::1588547
 5
[oracle@jytest3 xtts_script]$ cat tsbkupmap.txt
DMPEXP::29sc9068_1_1
::5:::1=28sc9066_1_1
[oracle@jytest3 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/29sc9068_1_1
/ora_xtts/backupformat/28sc9066_1_1

[oracle@jytest3 xtts_script]$ scp `cat incrbackups.txt` oracle@10.138.130.171:/tts/backup/
oracle@10.138.130.171's password:
29sc9068_1_1                                                                                                                                                                                              100%  192KB 192.0KB/s   00:00
28sc9066_1_1                                                                                                                                                                                              100%  128KB 128.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/xttplan.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
xttplan.txt                                                                                                                                                                                               100%   18     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/tsbkupmap.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
tsbkupmap.txt                                                                                                                                                                                             100%   42     0.0KB/s   00:00
[oracle@jytest3 xtts_script]$ scp /ora_xtts/xtts_script/incrbackups.txt oracle@10.138.130.171:/tts/xtts_script
oracle@10.138.130.171's password:
incrbackups.txt                                                                                                                                                                                           100%   73     0.1KB/s   00:00


[oracle@jytest1 backup]$ ls -lrt
total 1568
-rw-r----- 1 oracle oinstall 1097728 Aug 18 23:58 JY_5_25sc8t6j_1_1.bkp
-rw-r----- 1 oracle oinstall   49152 Aug 19 00:18 26sc8uc7_1_1
-rw-r----- 1 oracle oinstall  131072 Aug 19 00:33 27sc8vec_1_1
-rw-r----- 1 oracle oinstall  196608 Aug 19 00:47 29sc9068_1_1
-rw-r----- 1 oracle oinstall  131072 Aug 19 00:47 28sc9066_1_1

[oracle@jytest1 xtts_script]$ cat xttplan.txt
 JY::::1588547
 5
[oracle@jytest1 xtts_script]$ cat tsbkupmap.txt
DMPEXP::29sc9068_1_1
::5:::1=28sc9066_1_1
[oracle@jytest1 xtts_script]$ cat incrbackups.txt
/ora_xtts/backupformat/29sc9068_1_1
/ora_xtts/backupformat/28sc9066_1_1

4.3应用最后的增量备份
在目标系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来应用最后的增量备份

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl --resincrdmp
============================================================
trace file is /tts/xtts_script/resincrdmp_Aug19_Sat_00_49_56_533//Aug19_Sat_00_49_56_533_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Start restore/recover
--------------------------------------------------------------------


--------------------------------------------------------------------
End of restore/recover phase
--------------------------------------------------------------------


--------------------------------------------------------------------
Start creating dumpfile
--------------------------------------------------------------------


--------------------------------------------------------------------
End of creating dumpfile
--------------------------------------------------------------------


--------------------------------------------------------------------
Generating plugin
--------------------------------------------------------------------


--------------------------------------------------------------------
Done generating plugin file /tts/xtts_script/xttplugin.txt
--------------------------------------------------------------------

上面的操作将会对数据文件应用最后的增量备份。另外,还会还原阶段5A导入元数据所需要的dump文件与xttplugin.txt文件

[oracle@jytest1 xtts_script]$ cat xttplugin.txt
impdp directory= logfile= \
dumpfile=impdp_Aug19_Sat_00_49_56_533.dmp \
transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile//JY_5.dbf'
[oracle@jytest1 xtts_script]$ ls -lrt

-rw-r----- 1 oracle asmadmin 167936 Aug 19 00:50 impdp_Aug19_Sat_00_49_56_533.dmp
-rw-r--r-- 1 oracle oinstall    183 Aug 19 00:50 xttplugin.txt

5.传输阶段:将对象元数据导入目标数据库
在这个阶段表空间将会被附加到目标数据库中。这里有两种方法。第一种是使用步骤4.3所创建的dump文件来进行导入。第二种方法是通过连接两个数据库的dblink来进行导入。

5a 通过dump文件导入
5a.1 创建datapump目录并授权

SQL>create directory dpump_tts as '/tts/xtts_script';
SQL>GRANT READ, WRITE ON DIRECTORY dpump_tts TO system;

5a.2 修改导入命令并执行

[oracle@jytest1 xtts_script]$ impdp directory=pump_tts logfile=tts_imp.log
dumpfile=impdp_Aug19_Sat_00_49_56_533.dmp
transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile//JY_5.dbf'

5b使用dblink导入元数据
5b.1创建dblink
在目标系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令:

[oracle@jytest1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -e
============================================================
trace file is /tts/xtts_script/generate_Aug19_Sat_00_58_39_839//Aug19_Sat_00_58_39_839_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Generating plugin
--------------------------------------------------------------------


--------------------------------------------------------------------
Done generating plugin file /tts/xtts_script/xttplugin.txt
--------------------------------------------------------------------

[oracle@jytest1 xtts_script]$ cat xttplugin.txt
impdp directory= logfile= \
network_link= transport_full_check=no \
transport_tablespaces=JY \
transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile//JY_5.dbf'

5b.2 在目标数据库中创建dblink

SQL> create public database link ttslink
  2    connect to system identified by "xxzx#7817600"
  3    using '(DESCRIPTION =
  4      (ADDRESS_LIST =
  5        (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.130.173)(PORT = 1521))
  6      )
  7      (CONNECT_DATA =
  8        (SERVER = DEDICATED)
  9        (SERVICE_NAME =orcl)
 10      )
 11    )';

Database link created.

SQL> select name from v$database@ttslink;

NAME
---------
ORCL

5b.3修改导入脚本并执行脚本

SQL> create directory dpump_tts as '/tts/xtts_script';

Directory created.

SQL> GRANT READ, WRITE ON DIRECTORY dpump_tts TO public;

Grant succeeded.


[oracle@jytest1 xtts_script]$ impdp system/abcd@jypdb directory=dpump_tts logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=JY transport_datafiles='+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile//JY_5.dbf' exclude=statistics

Import: Release 12.2.0.1.0 - Production on Sat Aug 19 01:08:07 2017

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

Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03":  system/********@jypdb directory=dpump_tts logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=JY transport_datafiles=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile//JY_5.dbf exclude=statistics
Source time zone is +08:00 and target time zone is +00:00.
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03" successfully completed at Sat Aug 19 01:09:09 2017 elapsed 0 00:00:49


[oracle@jytest1 xtts_script]$ impdp system/abcd@jypdb directory=dpump_tts logfile=ysj.log schemas=jy content=metadata_only exclude=table,index network_link=ttslink

Import: Release 12.2.0.1.0 - Production on Sat Aug 19 01:11:32 2017

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

Connected to: Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/********@jypdb directory=dpump_tts logfile=ysj.log schemas=jy content=metadata_only exclude=table,index network_link=ttslink
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"JY" already exists

Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/STATISTICS/MARKER
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 1 error(s) at Sat Aug 19 01:11:55 2017 elapsed 0 00:00:21

6.验证传输数据
6.1检查表空间是否有损坏

[oracle@jytest1 xtts_script]$ rman target sys/abcd@jypdb

Recovery Manager: Release 12.2.0.1.0 - Production on Sat Aug 19 01:17:35 2017

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

connected to target database: JY:JYPDB (DBID=2825277312)

RMAN> validate tablespace jy check logical;

Starting validate at 19-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=1144 instance=jy1 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00083 name=+DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_5.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:07
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
83   OK     0              1            64001           1590987
  File Name: +DATA/jy/4B2C6373AE2547CCE053AB828A0A7CA3/datafile/jy_5.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              5
  Index      0              0
  Other      0              63994

Finished validate at 19-AUG-17

6.2将目标数据库中的表空间JY修改为read write状态

SQL> alter tablespace jy read write;

Tablespace altered.

7.清除操作
如果使用单独的转换home与实例,那么可以关闭转换实例并删除转换home。还可以删除源系统中创建的backupformat目录,目标系统中创建的bacup目录,源系统与目标系统中设置的环境变量$TMPDIR。

xttdriver.pl脚本选项
–backup:对源数据库中要被传输的表空间创建level 0级备份。这些备份将被写到xtt.properties文件中backupoformat参数所指定的目录中。这些备份需要手动复制到目标系统中stageondest参数所指定的目录中。而且还会生成tsbkupmap.txt与xttnewdatafiles.txt文件并且也需要复制到目标系统中相应目录(TMPDIR变量所指向的目录)

–restore:在目标系统中还原并转换stageondest目录中的数据文件备份的副本。还原的文件将会存储到storageondest参数所指定的目录中

–bkpincr:在源系统中对表空间创建增量备份并存储在backupformat参数所指定的目录中。这步操作还会创建incrbackups.txt文件它列出了所创建的备份。这个文件与tsbkupmap.txt必须复制到目标系统中的stageondest参数所指定的目录中

-recover:将增量备份应用到已经还原的数据文件上

-s:对源数据库判断新的from_scn可以执行一次或多次。这个操作将会计算下一个from_scn,并记录在xttplan.txt文件中,然后使用创建增量备份时会使用。

-bkpexport:将执行最后一次增量备份并且会创建元数据的dump文件用来导入数据文件。增量备份将会存储在backupformat参数所指定的目录中并且会创建incrbckups.txt与tsbkupmaps.txt文件,这些都要复制到目标系统中

–resincrdmp:将恢复最后一次增量备份并应用到数据文件。同时dump文件会被还原到TMPDIR变量所指定的目录中,dump文件可以用来导入

-e:在目标系统中生成传输表空间要导入的元数据脚本

-d debug:为了以debug模式来执行xttdriver.pl 与RMAN脚本。也可以设置环境变量XTTDEBUG=1,debug级别可以为1,2,3,例如xttdriver.pl -3

xtt.properties文件参数说明
tablespaces:用逗号来分隔从源数据库要被传输到目标数据库的表空间列表,例如tablespaces=TS1,TS2

platformid:从v$database.platform_id获得的源数据库的platform id,例如platformid=13

backupformat:源系统中存储备份文件的目录。这个目录必须要有足够的空间来存储所有创建的备份与增量备份文件。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。例如,backupformat=/stage_source

stageondest:目标系统中存储从源系统中手动传输过来的数据文件副本。这个目录要有足够的空间来存储数据文件副本。这个目录同时也是用来存储从源系统传输过来的增量备份文件的目录。在目标系统上执行xttdriver.pl -c转换数据文件与执行xttdriver.pl -r前滚数据文件时会从这个目录中读取数据文件副本与增量备份文件。这个目标也可以是一个DBFS-mounted文件系统。个目录可以是源系统上通过NFS-mounted文件系统所挂载到目标系统中的一个目录,在这种情况下,源系统中的backupformat参数与dfcopydir参数就会引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。例如stageondest=/stage_dest

storageondest:目标系统中用来存储xttdriver.pl -c转换操作后所生成的数据文件副本的目录,也就是目标数据库最终存储数据文件的目录。这个目录要有足够的空间来永久存储数据文件。这个参数当使用RMAN备份来生成初始化数据文件副本时才使用,例如
storageondest=+DATA或者storageondest=/oradata/test

asm_home:目标系统中ASM实例的ORACLE_HOME。注意如果backupondest设置为文件系统目录,那么就要删除asm_home与asm_sid参数,例如asm_home=/u01/app/11.2.0.4/grid

asm_sid:目标系统中ASM实例的ORACLE_SID。例如asm_sid=+ASM1

parallel:定义rmanconvert.cmd命令文件中rman convert命令的并行度。如果不设置这个参数,那么xttdriver.pl将使用parallel=8的缺省并行度。例如,parallel=3

xtts from文件系统到ASM存储(dbms_file_transfer)

从AIX将数据库迁移到Linux Oracle为11.2.0.4
下面操作可以用来创建一个名叫xtt的增量转换实例,增量转换home为/u01/app/oracle/product/11.2.0/db/dbs:

[oracle@jyrac1 dbs]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db/
[oracle@jyrac1 dbs]$ export ORACLE_SID=xtt
[oracle@jyrac1 dbs]$ cat < < EOF > $ORACLE_HOME/dbs/init$ORACLE_SID.ora
> db_name=xtt
> compatible=11.2.0.4.0
> EOF

[oracle@jyrac1 dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Fri Aug 18 10:15:02 2017

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

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  296493056 bytes
Fixed Size                  2252584 bytes
Variable Size             239075544 bytes
Database Buffers           50331648 bytes
Redo Buffers                4833280 bytes

源数据库目录对象引用源数据库中当前存放数据文件的目录。例如,下面创建目录对象指向,数据文件存放目录/oracle11/oradata/jycs/jycs/,连接到源数据库房执行以下命令:

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.4.0
Connected as ldjc@129_2


SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/oracle11/oradata/jycs/jycs/system01.dbf
/oracle11/oradata/jycs/jycs/sysaux01.dbf
/oracle11/oradata/jycs/jycs/undotbs01.dbf
/oracle11/oradata/jycs/jycs/users01.dbf
/oracle11/oradata/jycs/jycs/example01.dbf
/oracle11/oradata/jycs/jycs/cdzj01
/oracle11/oradata/jycs/jycs/ldjc01
7 rows selected

SQL> create directory sourcedir as '/oracle11/oradata/jycs/jycs';
Directory created

SQL> select platform_id from v$database;
PLATFORM_ID
-----------
          6

目标数据库目录对象引用目标数据库中将要存储数据文件的目录。这个目录是最终目标数据库将要存放数据文件的目录+DATADG/jyrac/datafile/,连接到目标数据库执行以下命令

Connected to Oracle Database 11g Enterprise Edition Release 11.2.0.4.0
Connected as sys@jyrac AS SYSDBA


SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATADG/jyrac/datafile/system.259.930413057
+DATADG/jyrac/datafile/sysaux.258.930413055
+DATADG/jyrac/datafile/undotbs1.262.930413057
+DATADG/jyrac/datafile/users.263.930413057
+DATADG/jyrac/datafile/example.260.930413057
+DATADG/jyrac/datafile/undotbs2.261.930413057
+DATADG/jyrac/datafile/test01.dbf
+DATADG/jyrac/datafile/sales_test_01.dbf
+DATADG/jyrac/datafile/emp_test_01.dbf
+DATADG/jyrac/datafile/orders_test_01.dbf
10 rows selected

SQL> create directory destdir as '+DATADG/jyrac/datafile';
Directory created

在目标数据库中创建一个dblink连接到源数据库。例如创建一个名叫ttslink的dblink,执行以下命令:

SQL> create public database link ttslink
  2    connect to system identified by "xxzx7817600"
  3    using '(DESCRIPTION =
  4      (ADDRESS_LIST =
  5        (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.129.2)(PORT = 1521))
  6      )
  7      (CONNECT_DATA =
  8        (SERVER = DEDICATED)
  9        (SERVICE_NAME =jycs)
 10      )
 11    )';

Database link created.

创建dblink后验证是否可以能过dblink访问源数据库

SQL> select * from dual@ttslink;

D
-
X

在源系统与目标系统中创建预备目录,它们将被设置为xtt.properties文件中的backupformat(源系统中存放增量备份文件的目录),backupondest(目标系统中存放转换后的增量备份文件的目录)参数的值。如果使用RMAN备份方法,在源系统与目标系统中还需要为xtt.properties文件中的dfcopydir(源系统中存放数据文件副本的目录,只有使用rman备份才使用),stageondest(目标系统中存放从源系统传输过来的数据文件副本与增量备份的目录,只有使用rman备份才使用)。

在源系统中执行下面的命令分别创建backupformat目录(/oracle11/backup),dfcopydir目录(/oracle11/dfcopydir)

IBMP740-2:/oracle11$mkdir backup
IBMP740-2:/oracle11$mkdir dfcopydir

在目标系统中执行下面的命令分别创建backupondest目录(+DATADG/backup),stagenodest目录(/u01/xtts)

ASMCMD [+datadg] > mkdir backup

如果ASM被用于存储xtt.properties文件中的参数backupondest,那么实例的compatible参数的值必须等于或大于ASM磁盘组所使用的rdbms.compatible的值。

[grid@jyrac1 ~]$ asmcmd lsattr -G DATADG -l
Name                     Value
access_control.enabled   false
access_control.umask     026
au_size                  1048576
cell.smart_scan_capable  FALSE
compatible.asm           11.2.0.0.0
compatible.rdbms         11.2.0.0.0
disk_repair_time         4.5 H
sector_size              512

[root@jyrac1 u01]# mkdir xtts
[root@jyrac1 u01]# chown -R oracle:oinstall xtts
[root@jyrac1 u01]# chmod 777 xtts

在源系统中安装xttconver脚本
在源系统中,使用Oracle软件用户,下裁与解压脚本

IBMP740-2:/oracle11/xtts_script$unzip rman_xttconvert_v3.zip
Archive:  rman_xttconvert_v3.zip
  inflating: xtt.properties
  inflating: xttcnvrtbkupdest.sql
  inflating: xttdbopen.sql
  inflating: xttdriver.pl
  inflating: xttprep.tmpl
 extracting: xttstartupnomount.sql

IBMP740-2:/oracle11/xtts_script$ls -lrt
total 416
-rw-r--r--    1 oracle11 oinstall       1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 oracle11 oinstall         52 May 24 16:57 xttstartupnomount.sql
-rw-r--r--    1 oracle11 oinstall      11710 May 24 16:57 xttprep.tmpl
-rw-r--r--    1 oracle11 oinstall     139331 May 24 16:57 xttdriver.pl
-rw-r--r--    1 oracle11 oinstall         71 May 24 16:57 xttdbopen.sql
-rw-r--r--    1 oracle11 oinstall       7969 Jun 05 08:47 xtt.properties
-rw-r-----    1 oracle11 oinstall      33949 Aug 18 09:26 rman_xttconvert_v3.zip

在源系统中配置xtt.properties文件

IBMP740-2:/oracle11/xtts_script$vi xtt.properties
tablespaces=CDZJ,LDJC
platformid=6
srcdir=SOURCEDIR
dstdir=DESTDIR
srclink=ttslink
#dfcopydir=/oracle11/dfcopydir
backupformat=/oracle11/backup
stageondest=/u01/xtts
backupondest=+DATADG/backup
#storageondest=+DATADG/jyrac/datafile/
cnvinst_home=/oracle11/app/oracle/product/11.2.0/db
cnvinst_sid=xtt
asm_home=/u01/app/product/11.2.0/crs
asm_sid=+ASM1

将源系统中的转换脚本与xtt.properties文件复制到目标系统中

[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2
Connected to 10.138.129.2.
220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready.
502 authentication type cannot be set to GSSAPI
502 authentication type cannot be set to KERBEROS_V4
KERBEROS_V4 rejected as an authentication type
Name (10.138.129.2:oracle): oracle
331 Password required for oracle.
Password:
230-Last unsuccessful login: Wed Dec  3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31
230-Last login: Mon Aug 14 08:39:17 BEIST 2017 on /dev/pts/0 from 10.138.130.242
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /oracle11/xtts_script
250 CWD command successful.
ftp> ls -lrt
227 Entering Passive Mode (10,138,129,2,37,50)
150 Opening data connection for /bin/ls.
total 424
-rw-r--r--    1 oracle11 oinstall       1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 oracle11 oinstall         52 May 24 16:57 xttstartupnomount.sql
-rw-r--r--    1 oracle11 oinstall      11710 May 24 16:57 xttprep.tmpl
-rw-r--r--    1 oracle11 oinstall     139331 May 24 16:57 xttdriver.pl
-rw-r--r--    1 oracle11 oinstall         71 May 24 16:57 xttdbopen.sql
-rw-r--r--    1 oracle11 oinstall       7969 Jun 05 08:47 xtt.properties.jy
-rw-r-----    1 oracle11 oinstall      33949 Aug 18 09:26 rman_xttconvert_v3.zip
-rw-r--r--    1 oracle11 oinstall        352 Aug 18 10:15 xtt.properties
226 Transfer complete.
ftp> lcd /u01/xtts_script
Local directory now /u01/xtts_script
ftp> bin
200 Type set to I.
ftp> get xttcnvrtbkupdest.sql
local: xttcnvrtbkupdest.sql remote: xttcnvrtbkupdest.sql
227 Entering Passive Mode (10,138,129,2,37,63)
150 Opening data connection for xttcnvrtbkupdest.sql (1390 bytes).
226 Transfer complete.
1390 bytes received in 4.8e-05 seconds (2.8e+04 Kbytes/s)
ftp> get xttstartupnomount.sql
local: xttstartupnomount.sql remote: xttstartupnomount.sql
227 Entering Passive Mode (10,138,129,2,37,66)
150 Opening data connection for xttstartupnomount.sql (52 bytes).
226 Transfer complete.
52 bytes received in 3.7e-05 seconds (1.4e+03 Kbytes/s)
ftp> get xttprep.tmpl
local: xttprep.tmpl remote: xttprep.tmpl
227 Entering Passive Mode (10,138,129,2,37,69)
150 Opening data connection for xttprep.tmpl (11710 bytes).
226 Transfer complete.
11710 bytes received in 0.00065 seconds (1.7e+04 Kbytes/s)
ftp> get xttdriver.pl
local: xttdriver.pl remote: xttdriver.pl
227 Entering Passive Mode (10,138,129,2,37,72)
150 Opening data connection for xttdriver.pl (139331 bytes).
226 Transfer complete.
139331 bytes received in 0.0026 seconds (5.3e+04 Kbytes/s)
ftp> get xttdbopen.sql
local: xttdbopen.sql remote: xttdbopen.sql
227 Entering Passive Mode (10,138,129,2,37,77)
150 Opening data connection for xttdbopen.sql (71 bytes).
226 Transfer complete.
71 bytes received in 3.9e-05 seconds (1.8e+03 Kbytes/s)
ftp> get xtt.properties
local: xtt.properties remote: xtt.properties
227 Entering Passive Mode (10,138,129,2,37,84)
150 Opening data connection for xtt.properties (352 bytes).
226 Transfer complete.
352 bytes received in 4.2e-05 seconds (8.2e+03 Kbytes/s)

[oracle@jyrac1 xtts_script]$ ls -lrt
total 172
-rw-r--r-- 1 oracle oinstall   1390 Aug 18 10:38 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     52 Aug 18 10:38 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall  11710 Aug 18 10:38 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall 139331 Aug 18 10:38 xttdriver.pl
-rw-r--r-- 1 oracle oinstall     71 Aug 18 10:38 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall    352 Aug 18 10:38 xtt.properties

在源系统与目标系统中设置环境变TMPDIR,它指向转换脚本所在的目录。为了执行Perl脚本xttdriver.pl设置如下。如果TMPDIR没有设置,那么脚本生成的输出文件将会存放在/tmp目录中。

IBMP740-2:/oracle11$export TMPDIR=/oracle11/xtts_script
[oracle@jyrac1 xtts_script]$ export TMPDIR=/u01/xtts_script

2.准备阶段
在准备阶段,被传输表空间的数据文件会被传输到目标系统并且通过执行xttdriver.pl脚本进行转换。有以下两种方法可以使用:
1. dbms_file_transfer方法
2. RMAN备份方法

对于大量数据文件使用dbms_file_transfer方法要比传输数据文件到目标系统更快。

2a.使用dbms_file_transfer方法
2a.1在源系统中执行准备操作
在源系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令:

IBMP740-2:/oracle11/xtts_script$export ORACLE_HOME=/oracle11/app/oracle/product/11.2.0/db
IBMP740-2:/oracle11/xtts_script$export ORACLE_SID=jycs
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -S
============================================================
trace file is /oracle11/xtts_script/setupgetfile_Aug18_Fri_10_21_17_169//Aug18_Fri_10_21_17_169_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Starting prepare phase
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /u01/xtts
xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 10:21:17 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:21:18 2017
Prepare source for Tablespaces:
                  'LDJC'  /u01/xtts
xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 10:21:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:21:18 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 10:21:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:21:18 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 10:21:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:21:18 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 10:21:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:21:18 2017

--------------------------------------------------------------------
Done with prepare phase
--------------------------------------------------------------------

准备操作将在源系统中执行以下操作
.验证表空间是否online,read write且不包含脱机数据文件
.将创建后面所要使用的以下文件:
xttnewdatafiles.txt
getfile.sql

IBMP740-2:/oracle11/xtts_script$cat xttnewdatafiles.txt
::CDZJ
6,DESTDIR:/cdzj01
::LDJC
7,DESTDIR:/ldjc01
IBMP740-2:/oracle11/xtts_script$cat getfile.sql
0,SOURCEDIR,cdzj01,DESTDIR,cdzj01
1,SOURCEDIR,ldjc01,DESTDIR,ldjc01

要被传输的一组表空间必须是online,read write状态且不包含脱机数据文件。如果在源数据库中被传输表空间的一个或多个数据文件是脱机状态或read only就会触发错误。如果表空间在整个表空间传输过程中都保持read only状态,那么就使用传统的跨平台传输表空间,不要使用跨平台增量备份传输表空间。

2a.2 传输数据文件到目标系统中
在目标系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并复制上一步生成的xttnewdatafiles.txt与getfile.sql文件到目标系统并执行操作来获取数据文件

[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2
Connected to 10.138.129.2.
220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready.
502 authentication type cannot be set to GSSAPI
502 authentication type cannot be set to KERBEROS_V4
KERBEROS_V4 rejected as an authentication type
Name (10.138.129.2:oracle): oracle
331 Password required for oracle.
Password:
230-Last unsuccessful login: Wed Dec  3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31
230-Last login: Fri Aug 18 10:16:01 BEIST 2017 on ftp from ::ffff:10.138.130.151
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /oracle11/xtts_script
250 CWD command successful.
ftp> ls -lrt
227 Entering Passive Mode (10,138,129,2,38,79)
150 Opening data connection for /bin/ls.
total 456
-rw-r--r--    1 oracle11 oinstall       1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 oracle11 oinstall         52 May 24 16:57 xttstartupnomount.sql
-rw-r--r--    1 oracle11 oinstall      11710 May 24 16:57 xttprep.tmpl
-rw-r--r--    1 oracle11 oinstall     139331 May 24 16:57 xttdriver.pl
-rw-r--r--    1 oracle11 oinstall         71 May 24 16:57 xttdbopen.sql
-rw-r--r--    1 oracle11 oinstall       7969 Jun 05 08:47 xtt.properties.jy
-rw-r-----    1 oracle11 oinstall      33949 Aug 18 09:26 rman_xttconvert_v3.zip
-rw-r--r--    1 oracle11 oinstall        352 Aug 18 10:15 xtt.properties
-rw-r--r--    1 oracle11 oinstall         50 Aug 18 10:21 xttplan.txt
-rw-r--r--    1 oracle11 oinstall        106 Aug 18 10:21 xttnewdatafiles.txt_temp
-rw-r--r--    1 oracle11 oinstall         50 Aug 18 10:21 xttnewdatafiles.txt
drwxr-xr-x    2 oracle11 oinstall        256 Aug 18 10:21 setupgetfile_Aug18_Fri_10_21_17_169
-rw-r--r--    1 oracle11 oinstall         68 Aug 18 10:21 getfile.sql
226 Transfer complete.
ftp> lcd /u01/xtts_script
Local directory now /u01/xtts_script
ftp> bin
200 Type set to I.
ftp> get xttnewdatafiles.txt
local: xttnewdatafiles.txt remote: xttnewdatafiles.txt
227 Entering Passive Mode (10,138,129,2,38,112)
150 Opening data connection for xttnewdatafiles.txt (50 bytes).
226 Transfer complete.
50 bytes received in 6.2e-05 seconds (7.9e+02 Kbytes/s)
ftp> get getfile.sql
local: getfile.sql remote: getfile.sql
227 Entering Passive Mode (10,138,129,2,38,115)
150 Opening data connection for getfile.sql (68 bytes).
226 Transfer complete.
68 bytes received in 4.9e-05 seconds (1.4e+03 Kbytes/s)

# MUST set environment to destination database
[oracle@jyrac1 xtts_script]$ export ORACLE_HOME=/u01/app/oracle/product/11.2.0/db
[oracle@jyrac1 xtts_script]$ export ORACLE_SID=jyrac1
[oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G
============================================================
trace file is /u01/xtts_script/getfile_Aug18_Fri_11_03_48_564//Aug18_Fri_11_03_48_564_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Getting datafiles from source
--------------------------------------------------------------------


--------------------------------------------------------------------
Executing getfile for /u01/xtts_script/getfile_Aug18_Fri_11_03_48_564//getfile_sourcedir_cdzj01_0.sql
--------------------------------------------------------------------


--------------------------------------------------------------------
Executing getfile for /u01/xtts_script/getfile_Aug18_Fri_11_03_48_564//getfile_sourcedir_ldjc01_1.sql
--------------------------------------------------------------------


--------------------------------------------------------------------
Completed getting datafiles from source
--------------------------------------------------------------------

ASMCMD [+datadg/jyrac/datafile] > ls -lt
Type      Redund  Striped  Time             Sys  Name
                                            N    ldjc01 => +DATADG/JYRAC/DATAFILE/FILE_TRANSFER.271.952340629
                                            N    cdzj01 => +DATADG/JYRAC/DATAFILE/FILE_TRANSFER.272.952340629
DATAFILE  MIRROR  COARSE   AUG 18 11:00:00  Y    FILE_TRANSFER.272.952340629
DATAFILE  MIRROR  COARSE   AUG 18 11:00:00  Y    FILE_TRANSFER.271.952340629

当这步操作完成后,要被传输的数据文件会存放在目标系统最终存放数据文件的目录中。转换操作会自动执行。下面就要执行前滚阶段的操作了。

3.前滚阶段
下面在源数据库中创建增量数据

SQL> insert into ldjc.jy_test values(7);
1 row inserted

SQL> insert into cdzj.jy_test values(7);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    7
                    1
                    2
                    3
                    4
                    5
                    6
7 rows selected

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    7
                    1
                    2
                    3
                    4
                    5
                    6
7 rows selected

在这个阶段,会在源系统中对源数据库创建增量备份,然后将生成的增量备份传输到目标系统中,并将增量备份转换为目标系统所使用的字节序,然后将转换后的增量备份应用到转换后的数据文件进行前滚操作。这个阶段的操作可以执行多次,每一次成功的增量备份应该比之前的增量备份花费更少的时间,并且让目标系统中的数据文件的内容更加接近源数据库的内容。在这个阶段源数据库中被传输的数据完全可以被访问。

3.1 在源系统中对被传输的表空间LDJC,CDZJ创建增量备份
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /oracle11/xtts_script/incremental_Aug18_Fri_10_56_44_606//Aug18_Fri_10_56_44_606_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /u01/xtts
xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 10:56:44 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:56:44 2017
Prepare source for Tablespaces:
                  'LDJC'  /u01/xtts
xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 10:56:44 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:56:44 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 10:56:44 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:56:44 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 10:56:44 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:56:44 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 10:56:44 2017
xttpreparesrc.sql for  ended at Fri Aug 18 10:56:44 2017
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''''''''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
LDJC::7:::1=07sc73ng_1_1
CDZJ::6:::1=06sc73nf_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

IBMP740-2:/oracle11/xtts_script$cat incrbackups.txt
/oracle11/backup/07sc73ng_1_1
/oracle11/backup/06sc73nf_1_1

文件中的内容显示了生成的增量备份文件信息

IBMP740-2:/oracle11/backup$ls -lrt
total 624
-rw-r-----    1 oracle11 oinstall      65536 Aug 18 10:56 06sc73nf_1_1
-rw-r-----    1 oracle11 oinstall     253952 Aug 18 10:56 07sc73ng_1_1

3.2 将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/u01/xtts)中。

[oracle@jyrac1 xtts]$ ftp 10.138.129.2
Connected to 10.138.129.2.
220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready.
502 authentication type cannot be set to GSSAPI
502 authentication type cannot be set to KERBEROS_V4
KERBEROS_V4 rejected as an authentication type
Name (10.138.129.2:oracle): oracle
331 Password required for oracle.
Password:
230-Last unsuccessful login: Wed Dec  3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31
230-Last login: Fri Aug 18 10:24:32 BEIST 2017 on ftp from ::ffff:10.138.130.151
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /oracle11/backup
250 CWD command successful.
ftp> ls -lrt
227 Entering Passive Mode (10,138,129,2,43,121)
150 Opening data connection for /bin/ls.
total 624
-rw-r-----    1 oracle11 oinstall      65536 Aug 18 10:56 06sc73nf_1_1
-rw-r-----    1 oracle11 oinstall     253952 Aug 18 10:56 07sc73ng_1_1
226 Transfer complete.
ftp> lcd /u01/xtts
Local directory now /u01/xtts
ftp> bin
200 Type set to I.
ftp> get 06sc73nf_1_1
local: 06sc73nf_1_1 remote: 06sc73nf_1_1
227 Entering Passive Mode (10,138,129,2,43,130)
150 Opening data connection for 06sc73nf_1_1 (65536 bytes).
226 Transfer complete.
65536 bytes received in 0.0018 seconds (3.5e+04 Kbytes/s)
ftp> get 07sc73ng_1_1
local: 07sc73ng_1_1 remote: 07sc73ng_1_1
227 Entering Passive Mode (10,138,129,2,43,134)
150 Opening data connection for 07sc73ng_1_1 (253952 bytes).
226 Transfer complete.
253952 bytes received in 0.0038 seconds (6.5e+04 Kbytes/s)

[oracle@jyrac1 xtts]$ ls -lrt
total 320
-rw-r--r-- 1 oracle oinstall  65536 Aug 18 11:22 06sc73nf_1_1
-rw-r--r-- 1 oracle oinstall 253952 Aug 18 11:22 07sc73ng_1_1

3.3 在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2
Connected to 10.138.129.2.
220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready.
502 authentication type cannot be set to GSSAPI
502 authentication type cannot be set to KERBEROS_V4
KERBEROS_V4 rejected as an authentication type
Name (10.138.129.2:oracle): oracle
331 Password required for oracle.
Password:
230-Last unsuccessful login: Wed Dec  3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31
230-Last login: Fri Aug 18 11:00:11 BEIST 2017 on ftp from ::ffff:10.138.130.151
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /oracle11/xtts_script
250 CWD command successful.
ftp> ls -lrt
227 Entering Passive Mode (10,138,129,2,43,196)
150 Opening data connection for /bin/ls.
total 520
-rw-r--r--    1 oracle11 oinstall       1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 oracle11 oinstall         52 May 24 16:57 xttstartupnomount.sql
-rw-r--r--    1 oracle11 oinstall      11710 May 24 16:57 xttprep.tmpl
-rw-r--r--    1 oracle11 oinstall     139331 May 24 16:57 xttdriver.pl
-rw-r--r--    1 oracle11 oinstall         71 May 24 16:57 xttdbopen.sql
-rw-r--r--    1 oracle11 oinstall       7969 Jun 05 08:47 xtt.properties.jy
-rw-r-----    1 oracle11 oinstall      33949 Aug 18 09:26 rman_xttconvert_v3.zip
-rw-r--r--    1 oracle11 oinstall        352 Aug 18 10:15 xtt.properties
-rw-r--r--    1 oracle11 oinstall         50 Aug 18 10:21 xttplan.txt
-rw-r--r--    1 oracle11 oinstall        106 Aug 18 10:21 xttnewdatafiles.txt_temp
-rw-r--r--    1 oracle11 oinstall         50 Aug 18 10:21 xttnewdatafiles.txt
drwxr-xr-x    2 oracle11 oinstall        256 Aug 18 10:21 setupgetfile_Aug18_Fri_10_21_17_169
-rw-r--r--    1 oracle11 oinstall         68 Aug 18 10:21 getfile.sql
-rw-r--r--    1 oracle11 oinstall         50 Aug 18 10:56 xttplan.txt_tmp
-rw-r--r--    1 oracle11 oinstall        106 Aug 18 10:56 xttnewdatafiles.txt.added_temp
-rw-r--r--    1 oracle11 oinstall         50 Aug 18 10:56 xttnewdatafiles.txt.added
-rw-r--r--    1 oracle11 oinstall         68 Aug 18 10:56 getfile.sql.added
-rw-r--r--    1 oracle11 oinstall         54 Aug 18 10:56 xttplan.txt.new
-rw-r--r--    1 oracle11 oinstall         50 Aug 18 10:56 tsbkupmap.txt
drwxr-xr-x    2 oracle11 oinstall       4096 Aug 18 10:56 incremental_Aug18_Fri_10_56_44_606
-rw-r--r--    1 oracle11 oinstall         60 Aug 18 10:56 incrbackups.txt
226 Transfer complete.
ftp> lcd /u01/xtts_script
Local directory now /u01/xtts_script
ftp> get tsbkupmap.txt
local: tsbkupmap.txt remote: tsbkupmap.txt
227 Entering Passive Mode (10,138,129,2,43,208)
150 Opening data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 4.1e-05 seconds (1.2e+03 Kbytes/s)
ftp> get xttplan.txt
local: xttplan.txt remote: xttplan.txt
227 Entering Passive Mode (10,138,129,2,43,213)
150 Opening data connection for xttplan.txt (50 bytes).
226 Transfer complete.
50 bytes received in 4.8e-05 seconds (1e+03 Kbytes/s)

[oracle@jyrac1 xtts_script]$ cat tsbkupmap.txt
LDJC::7:::1=07sc73ng_1_1
CDZJ::6:::1=06sc73nf_1_1
[oracle@jyrac1 xtts_script]$ cat xttplan.txt
CDZJ::::14690270660591
6
LDJC::::14690270660591
7

[oracle@jyrac1 xtts_script]$ export XTTDEBUG=1
[oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /u01/xtts_script/rollforward_Aug18_Fri_11_34_08_253//Aug18_Fri_11_34_08_253_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: +DATADG/backup
Key: platformid
Values: 6
Key: backupformat
Values: /oracle11/backup
Key: srclink
Values: ttslink
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /u01/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /u01/xtts
Key: tablespaces
Values: CDZJ,LDJC
Key: asm_home
Values: /u01/app/product/11.2.0/crs

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jyrac1
ORACLE_HOME : /u01/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /u01/app/oracle/product/11.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 2505338880 bytes
Fixed Size                  2255832 bytes
Variable Size             687866920 bytes
Database Buffers         1795162112 bytes
Redo Buffers               20054016 bytes
rdfno 6

BEFORE ROLLPLAN

datafile number : 6

datafile name   : +DATADG/jyrac/datafile/cdzj01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE+DATADG/backup/xib_06sc73nf_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm +DATADG/backup/xib_06sc73nf_1_1_6  /u01/app/product/11.2.0/crs .. +ASM1

–这里显示的信息是说在前滚后不能删除增量备份文件,可以忽略这个错误

Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
ASMCMD:

rdfno 7

BEFORE ROLLPLAN

datafile number : 7

datafile name   : +DATADG/jyrac/datafile/ldjc01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE+DATADG/backup/xib_07sc73ng_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm +DATADG/backup/xib_07sc73ng_1_1_7  /u01/app/product/11.2.0/crs .. +ASM1

–这里显示的信息是说在前滚后不能删除增量备份文件,可以忽略这个错误

Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
ASMCMD:


--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。

3.4 为下一次增量备份判断from_scn
再次生成增量数据

SQL> insert into ldjc.jy_test values(8);
1 row inserted

SQL> insert into cdzj.jy_test values(8);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    7
                    8
                    8
                    1
                    2
                    3
                    4
                    5
                    6
9 rows selected

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    7
                    8
                    1
                    2
                    3
                    4
                    5
                    6
8 rows selected

在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /oracle11/xtts_script/determinescn_Aug18_Fri_11_21_56_544//Aug18_Fri_11_21_56_544_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
New /oracle11/xtts_script/xttplan.txt with FROM SCN's generated

这步操作会计算下一个from_scn,并记录在xttplan.txt文件中,当下次创建增量备份时会使用这个scn

IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
 CDZJ::::14690270749458
 6
 LDJC::::14690270749458
 7

3.5 再次重复前滚阶段或执行传输阶段
这里有两种选择:
1.如果如果将目标数据库中的数据文件与源数据库中的数据文件进行最接近的同步,那么就重复执行前滚操作。
2.如果目标数据库中的数据文件与源数据库中的数据文件已经达到所期望的接近,那么执行传输阶段的操作。

注意:如果从上一次增量备份后增加了一个新的表空间或者一个新的表空间名增加到xtt.properties文件中,那么将会出现以下错误:

Error:
------
The incremental backup was not taken as a datafile has been added to the tablespace:

Please Do the following:
--------------------------
1. Copy fixnewdf.txt from source to destination temp dir

2. Copy backups:

from  to the  in destination

3. On Destination, run $ORACLE_HOME/perl/bin/perl xttdriver.pl --fixnewdf

4. Re-execute the incremental backup in source:
$ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpincr

NOTE: Before running incremental backup, delete FAILED in source temp dir or
run xttdriver.pl with -L option:

$ORACLE_HOME/perl/bin/perl xttdriver.pl -L --bkpincr

These instructions must be followed exactly as listed. The next incremental backup will include the new datafile.

我这里再次执行前滚操作
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /oracle11/xtts_script/incremental_Aug18_Fri_11_23_16_532//Aug18_Fri_11_23_16_532_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /u01/xtts
xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 11:23:16 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:23:16 2017
Prepare source for Tablespaces:
                  'LDJC'  /u01/xtts
xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 11:23:16 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:23:16 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 11:23:16 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:23:17 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 11:23:17 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:23:17 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 11:23:17 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:23:17 2017
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''''''''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt
tsbkupmap.txt的内容如下:
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
LDJC::7:::1=09sc7598_1_1
CDZJ::6:::1=08sc7597_1_1
文件中的内容记录了表空间与增量备份的关联关系
incrbackups.txt的内容如下:

IBMP740-2:/oracle11/xtts_script$cat incrbackups.txt
/oracle11/backup/09sc7598_1_1
/oracle11/backup/08sc7597_1_1

文件中的内容显示了生成的增量备份文件信息

IBMP740-2:/oracle11/backup$ls -lrt
-rw-r-----    1 oracle11 oinstall      49152 Aug 18 11:23 08sc7597_1_1
-rw-r-----    1 oracle11 oinstall     204800 Aug 18 11:23 09sc7598_1_1

将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/u01/xtts)中。

[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2
Connected to 10.138.129.2.
220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready.
502 authentication type cannot be set to GSSAPI
502 authentication type cannot be set to KERBEROS_V4
KERBEROS_V4 rejected as an authentication type
Name (10.138.129.2:oracle): oracle
331 Password required for oracle.
Password:
230-Last unsuccessful login: Wed Dec  3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31
230-Last login: Fri Aug 18 11:02:13 BEIST 2017 on ftp from ::ffff:10.138.130.151
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /oracle11/backup
250 CWD command successful.
ftp> ls -lrt
227 Entering Passive Mode (10,138,129,2,46,249)
150 Opening data connection for /bin/ls.
total 1120
-rw-r-----    1 oracle11 oinstall      65536 Aug 18 10:56 06sc73nf_1_1
-rw-r-----    1 oracle11 oinstall     253952 Aug 18 10:56 07sc73ng_1_1
-rw-r-----    1 oracle11 oinstall      49152 Aug 18 11:23 08sc7597_1_1
-rw-r-----    1 oracle11 oinstall     204800 Aug 18 11:23 09sc7598_1_1
226 Transfer complete.
ftp> lcd /u01/xtts
Local directory now /u01/xtts
ftp> bin
200 Type set to I.
ftp> get 08sc7597_1_1
local: 08sc7597_1_1 remote: 08sc7597_1_1
227 Entering Passive Mode (10,138,129,2,47,4)
150 Opening data connection for 08sc7597_1_1 (49152 bytes).
226 Transfer complete.
49152 bytes received in 0.0013 seconds (3.7e+04 Kbytes/s)
ftp> get 09sc7598_1_1
local: 09sc7598_1_1 remote: 09sc7598_1_1
227 Entering Passive Mode (10,138,129,2,47,9)
150 Opening data connection for 09sc7598_1_1 (204800 bytes).
226 Transfer complete.
204800 bytes received in 0.0029 seconds (7e+04 Kbytes/s)

在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

ftp> cd /oracle11/xtts_script
250 CWD command successful.
ftp> lcd /u01/xtts_script
Local directory now /u01/xtts_script
ftp> bin
200 Type set to I.
ftp> get xttplan.txt
local: xttplan.txt remote: xttplan.txt
227 Entering Passive Mode (10,138,129,2,47,32)
150 Opening data connection for xttplan.txt (54 bytes).
226 Transfer complete.
54 bytes received in 2.7e-05 seconds (2e+03 Kbytes/s)
ftp> get tsbkupmap.txt
local: tsbkupmap.txt remote: tsbkupmap.txt
227 Entering Passive Mode (10,138,129,2,47,39)
150 Opening data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 3.2e-05 seconds (1.5e+03 Kbytes/s)
[oracle@jyrac1 xtts_script]$ cat xttplan.txt
 CDZJ::::14690270749458
 6
 LDJC::::14690270749458
 7
[oracle@jyrac1 xtts_script]$ cat tsbkupmap.txt
LDJC::7:::1=09sc7598_1_1
CDZJ::6:::1=08sc7597_1_1

[oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /u01/xtts_script/rollforward_Aug18_Fri_11_50_48_600//Aug18_Fri_11_50_48_600_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: +DATADG/backup
Key: platformid
Values: 6
Key: backupformat
Values: /oracle11/backup
Key: srclink
Values: ttslink
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /u01/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /u01/xtts
Key: tablespaces
Values: CDZJ,LDJC
Key: asm_home
Values: /u01/app/product/11.2.0/crs

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jyrac1
ORACLE_HOME : /u01/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /u01/app/oracle/product/11.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 2505338880 bytes
Fixed Size                  2255832 bytes
Variable Size             687866920 bytes
Database Buffers         1795162112 bytes
Redo Buffers               20054016 bytes
rdfno 6

BEFORE ROLLPLAN

datafile number : 6

datafile name   : +DATADG/jyrac/datafile/cdzj01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE+DATADG/backup/xib_08sc7597_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm +DATADG/backup/xib_08sc7597_1_1_6  /u01/app/product/11.2.0/crs .. +ASM1

Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
ASMCMD:

rdfno 7

BEFORE ROLLPLAN

datafile number : 7

datafile name   : +DATADG/jyrac/datafile/ldjc01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE+DATADG/backup/xib_09sc7598_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm +DATADG/backup/xib_09sc7598_1_1_7  /u01/app/product/11.2.0/crs .. +ASM1

Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
ASMCMD:


--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。

为下一次增量备份判断from_scn
再次生成增量数据

SQL> insert into ldjc.jy_test values(9);
1 row inserted

SQL> insert into cdzj.jy_test values(9);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    7
                    8
                    8
                    9
                    1
                    2
                    3
                    4
                    5
                    6
10 rows selected

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    7
                    8
                    9
                    1
                    2
                    3
                    4
                    5
                    6
9 rows selected

在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /oracle11/xtts_script/determinescn_Aug18_Fri_11_31_22_441//Aug18_Fri_11_31_22_441_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
New /oracle11/xtts_script/xttplan.txt with FROM SCN's generated

IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
 CDZJ::::14690270749827
 6
 LDJC::::14690270749845

4.传输阶段
在执行传输阶段操作时,源数据库中被传输表空间要设置为read only状态,并且通过创建与应用最后一次的增量备份使用目标数据库中的数据文件与源数据库中的数据文件内容保持一致。在目标数据库数据文件与源数据库数据文件内容达成一致后,在源系统中执行正常的传输表空间操作来导出元数据,然后将元数据导入到目标数据库中。直到传输阶段操作完成之前,被传输的数据只能以read only模式被访问。

4.1 将源数据库中被传输表空间设置为read only状态
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令将表空间设置为read only:

SQL> alter tablespace ldjc read only;
Tablespace altered

SQL> alter tablespace cdzj read only;
Tablespace altered

SQL> select tablespace_name,status from dba_tablespaces;
TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
CDZJ                           READ ONLY
LDJC                           READ ONLY
8 rows selected

4.2 最后一次创建增量备份,并传输到目标系统且执行转换并应用到目标数据文件
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /oracle11/xtts_script/incremental_Aug18_Fri_11_33_18_477//Aug18_Fri_11_33_18_477_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /u01/xtts
xttpreparesrc.sql for 'CDZJ' started at Fri Aug 18 11:33:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:33:18 2017
Prepare source for Tablespaces:
                  'LDJC'  /u01/xtts
xttpreparesrc.sql for 'LDJC' started at Fri Aug 18 11:33:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:33:18 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 11:33:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:33:18 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 11:33:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:33:18 2017
Prepare source for Tablespaces:
                  ''''  /u01/xtts
xttpreparesrc.sql for '''' started at Fri Aug 18 11:33:18 2017
xttpreparesrc.sql for  ended at Fri Aug 18 11:33:18 2017
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''''''''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
LDJC::7:::1=0bsc75s2_1_1
CDZJ::6:::1=0asc75s0_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

IBMP740-2:/oracle11/xtts_script$cat incrbackups.txt
/oracle11/backup/0bsc75s2_1_1
/oracle11/backup/0asc75s0_1_1

将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/u01/xtts)中。

[oracle@jyrac1 xtts_script]$ ftp 10.138.129.2
Connected to 10.138.129.2.
220 IBMP740-2 FTP server (Version 4.2 Mon Nov 28 14:12:02 CST 2011) ready.
502 authentication type cannot be set to GSSAPI
502 authentication type cannot be set to KERBEROS_V4
KERBEROS_V4 rejected as an authentication type
Name (10.138.129.2:oracle): oracle
331 Password required for oracle.
Password:
230-Last unsuccessful login: Wed Dec  3 10:20:09 BEIST 2014 on /dev/pts/0 from 10.138.130.31
230-Last login: Fri Aug 18 11:26:03 BEIST 2017 on ftp from ::ffff:10.138.130.151
230 User oracle logged in.
Remote system type is UNIX.
Using binary mode to transfer files.
ftp> cd /oracle11/backup
250 CWD command successful.
ftp> ls -lrt
227 Entering Passive Mode (10,138,129,2,48,62)
150 Opening data connection for /bin/ls.
total 1632
-rw-r-----    1 oracle11 oinstall      65536 Aug 18 10:56 06sc73nf_1_1
-rw-r-----    1 oracle11 oinstall     253952 Aug 18 10:56 07sc73ng_1_1
-rw-r-----    1 oracle11 oinstall      49152 Aug 18 11:23 08sc7597_1_1
-rw-r-----    1 oracle11 oinstall     204800 Aug 18 11:23 09sc7598_1_1
-rw-r-----    1 oracle11 oinstall      49152 Aug 18 11:33 0asc75s0_1_1
-rw-r-----    1 oracle11 oinstall     212992 Aug 18 11:33 0bsc75s2_1_1
226 Transfer complete.
ftp> lcd /u01/xtts
Local directory now /u01/xtts
ftp> get 0asc75s0_1_1
local: 0asc75s0_1_1 remote: 0asc75s0_1_1
227 Entering Passive Mode (10,138,129,2,48,73)
150 Opening data connection for 0asc75s0_1_1 (49152 bytes).
226 Transfer complete.
49152 bytes received in 0.0015 seconds (3.3e+04 Kbytes/s)
ftp> get 0bsc75s2_1_1
local: 0bsc75s2_1_1 remote: 0bsc75s2_1_1
227 Entering Passive Mode (10,138,129,2,48,76)
150 Opening data connection for 0bsc75s2_1_1 (212992 bytes).
226 Transfer complete.
212992 bytes received in 0.0032 seconds (6.6e+04 Kbytes/s)

在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

ftp> cd /oracle11/xtts_script
250 CWD command successful.
ftp> lcd /u01/xtts_script
Local directory now /u01/xtts_script
ftp> bin
200 Type set to I.
ftp> get xttplan.txt
local: xttplan.txt remote: xttplan.txt
227 Entering Passive Mode (10,138,129,2,48,100)
150 Opening data connection for xttplan.txt (54 bytes).
226 Transfer complete.
54 bytes received in 3.4e-05 seconds (1.6e+03 Kbytes/s)
ftp> get tsbkupmap.txt
local: tsbkupmap.txt remote: tsbkupmap.txt
227 Entering Passive Mode (10,138,129,2,48,107)
150 Opening data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 6.4e-05 seconds (7.6e+02 Kbytes/s)

[oracle@jyrac1 xtts_script]$ cat xttplan.txt
 CDZJ::::14690270749827
 6
 LDJC::::14690270749845
 7
[oracle@jyrac1 xtts_script]$ cat tsbkupmap.txt
LDJC::7:::1=0bsc75s2_1_1
CDZJ::6:::1=0asc75s0_1_1

[oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /u01/xtts_script/rollforward_Aug18_Fri_12_00_02_120//Aug18_Fri_12_00_02_120_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: +DATADG/backup
Key: platformid
Values: 6
Key: backupformat
Values: /oracle11/backup
Key: srclink
Values: ttslink
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /u01/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /u01/xtts
Key: tablespaces
Values: CDZJ,LDJC
Key: asm_home
Values: /u01/app/product/11.2.0/crs

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jyrac1
ORACLE_HOME : /u01/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /u01/app/oracle/product/11.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 2505338880 bytes
Fixed Size                  2255832 bytes
Variable Size             687866920 bytes
Database Buffers         1795162112 bytes
Redo Buffers               20054016 bytes
rdfno 6

BEFORE ROLLPLAN

datafile number : 6

datafile name   : +DATADG/jyrac/datafile/cdzj01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE+DATADG/backup/xib_0asc75s0_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm +DATADG/backup/xib_0asc75s0_1_1_6  /u01/app/product/11.2.0/crs .. +ASM1

Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
ASMCMD:

rdfno 7

BEFORE ROLLPLAN

datafile number : 7

datafile name   : +DATADG/jyrac/datafile/ldjc01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE+DATADG/backup/xib_0bsc75s2_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
asmcmd rm +DATADG/backup/xib_0bsc75s2_1_1_7  /u01/app/product/11.2.0/crs .. +ASM1

Can't locate strict.pm in @INC (@INC contains: /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/lib /u01/app/product/11.2.0/crs/lib/asmcmd /u01/app/product/11.2.0/crs/rdbms/lib/asmcmd /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0/x86_64-linux-thread-multi /u01/app/product/11.2.0/crs/perl/lib/site_perl/5.10.0 /u01/app/product/11.2.0/crs/perl/lib/site_perl .) at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
BEGIN failed--compilation aborted at /u01/app/product/11.2.0/crs/bin/asmcmdcore line 143.
ASMCMD:


--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

4.3 在目标数据库中导入元数据
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来生成Data Pump TTS命令:

[oracle@jyrac1 xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -e
============================================================
trace file is /u01/xtts_script/generate_Aug18_Fri_12_01_00_366//Aug18_Fri_12_01_00_366_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: +DATADG/backup
Key: platformid
Values: 6
Key: backupformat
Values: /oracle11/backup
Key: srclink
Values: ttslink
Key: asm_sid
Values: +ASM1
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /u01/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /u01/xtts
Key: tablespaces
Values: CDZJ,LDJC
Key: asm_home
Values: /u01/app/product/11.2.0/crs

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jyrac1
ORACLE_HOME : /u01/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Generating plugin
--------------------------------------------------------------------


--------------------------------------------------------------------
Done generating plugin file /u01/xtts_script/xttplugin.txt
--------------------------------------------------------------------

[oracle@jyrac1 xtts_script]$ cat xttplugin.txt
impdp directory= logfile= \
network_link= transport_full_check=no \
transport_tablespaces=CDZJ,LDJC \
transport_datafiles='+DATADG/jyrac/datafile/cdzj01','+DATADG/jyrac/datafile/ldjc01'

上面的命令会生成一个名叫xttplugin.txt的文件,文件创建了一个使用network_link参数执行传输表空间导入元数据的命令。命令中的transport_tablespaces与transport_datafiles参数已经设置正确。注意network_link模式指示导入通过使用dblink来完成,就不需要执行导出或使用dump文件。如果选择执行这个命令来完成表空间的传输就需要修改directory,logfile与network_link参数

SQL> create directory dump_dir as '/u01/xtts_script';

Directory created.
SQL> grant read,write on directory dump_dir to public;

Grant succeeded.

在目标数据库中创建用户方案LDJC,CDZJ

SQL> create user ldjc identified by "ldjc";

User created.

SQL> grant dba,connect,resource to ldjc;

Grant succeeded.

SQL> create user cdzj identified by "cdzj";

User created.


SQL> grant dba,connect,resource to cdzj;

Grant succeeded.

[oracle@jyrac1 xtts_script]$ impdp system/abcd directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles='+DATADG/jyrac/datafile/cdzj01','+DATADG/jyrac/datafile/ldjc01'

Import: Release 11.2.0.4.0 - Production on Fri Aug 18 12:05:05 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03":  system/******** directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles=+DATADG/jyrac/datafile/cdzj01,+DATADG/jyrac/datafile/ldjc01
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/COMMENT
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_03" successfully completed at Fri Aug 18 12:07:05 2017 elapsed 0 00:01:52

[oracle@jyrac1 xtts_script]$ impdp system/abcd directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink

Import: Release 11.2.0.4.0 - Production on Fri Aug 18 12:09:15 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP,
Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"LDJC" already exists
ORA-31684: Object type USER:"CDZJ" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Processing object type SCHEMA_EXPORT/DB_LINK
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/VIEW/VIEW
ORA-39082: Object type VIEW:"LDJC"."TEMP_AAB002" created with compilation warnings
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_PKG" created with compilation warnings
ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_SQLTRACE" created with compilation warnings
Processing object type SCHEMA_EXPORT/JOB
Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCOBJ
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 5 error(s) at Fri Aug 18 12:09:46 2017 elapsed 0 00:00:30


SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    7
                    8
                    8
                    9
                    1
                    2
                    3
                    4
                    5
                    6
10 rows selected

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    7
                    8
                    9
                    1
                    2
                    3
                    4
                    5
                    6
9 rows selected

元数据导入后,可以将源数据库中的表空间ldjc,cdzj修改为read write状态

SQL> alter tablespace ldjc read write;

Tablespace altered.

SQL>  alter tablespace cdzj read write;

Tablespace altered.

如果不使用network_link执行导入,那么可以执行传输表空间模式的data pump导出元数据,然后将元数据复制到目标数据库,再执行导入。

4.4 将目标数据库中的表空间ldjc,cdzj修改为read write状态

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
CDZJ                           READ ONLY
LDJC                           READ ONLY

8 rows selected.

SQL> alter tablespace ldjc read write;

Tablespace altered.

SQL> alter tablespace cdzj read write;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
CDZJ                           ONLINE
LDJC                           ONLINE

8 rows selected.

4.5 验证传输的数据
在这一步,在目标数据库中被传输过来的表空间设置为read only状态,然后运行应用程序来进行验证。也可以使用RMAN来检查物理与逻辑块损坏的情况。

[oracle@jyrac1 dbs]$ export ORACLE_SID=jyrac1
[oracle@jyrac1 dbs]$ rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Fri Aug 18 12:13:13 2017

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

connected to target database: JYRAC (DBID=2655496871)

RMAN> validate tablespace LDJC,CDZJ check logical;

Starting validate at 18-AUG-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=139 instance=jyrac1 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00012 name=+DATADG/jyrac/datafile/ldjc01
input datafile file number=00011 name=+DATADG/jyrac/datafile/cdzj01
channel ORA_DISK_1: validation complete, elapsed time: 00:01:05
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
11   OK     0              255625       262144          14690270752496
  File Name: +DATADG/jyrac/datafile/cdzj01
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              6239
  Index      0              0
  Other      0              280

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
12   OK     0              3746         655360          14690292001658
  File Name: +DATADG/jyrac/datafile/ldjc01
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              361625
  Index      0              286299
  Other      0              3690

Finished validate at 18-AUG-17

5.清除阶段
如果为了迁移创建了单独的转换home与实例,那么在传输表空间操作完成之后可以关闭实例并删除软件。为了执行跨平台增量备份传输表空间而创建的文件与目录也可以删除了,例如:
.源系统中的dfcopydir目录
.源系统中的backupformat目录
.目标系统中的stageondest目录
.目标系统中的backupondest目录
.源系统与目标系统中的$TMPDIR环境变量

Perl脚本xttdriver.pl选项
-S 准备传输源:-S选项只有当使用dbms_file_transfer方法传输数据文件时使用。这个准备操作在源系统中只对源数据库执行一次。这步操作将创建xttnewdatafiles.txt与getfile.sql文件

-G 从源系统获取数据文件:-G选项只有当使用dbms_file_transfer方法传输数据文件时使用。获取数据文件操作在目标系统中对目标数据库只执行一次。-S选项必须在它之前执行一次,并将生成的xttnewdatafiles.txt与getfile.sql文件传输到目标系统。-G选项会连接到目标数据库并执行脚本getfile.sql。getfile.sql将调用dbms_file_transfer.get_file()过程通过使用dblink(srclink)来从源数据库的目录对象(srcdir)中获取要被传输的数据文件到目标数据库的目录对象(dstdir)中。

-p 准备对源数据库执行备份:-p选项只有当使用RMAN备份方法来生成数据文件副本时才使用。这步操作在源系统中对源数据库只执行一次。这步操作会连接到源数据库并对要被传输的每个表空间执行一次xttpreparesrc.sql脚本。xttpreparesrc.sql会执行以下操作:
1.验证表空间是否处于online,read write模式与是否不包含脱机数据文件
2.标识第一次执行增量备份操作时所需要使用的SCN信息并将它们写入$TMPDIR目录中的xttplan.txt文件中
3.在源系统中会在xtt.properties文件的dfcopydir参数所指定的目录中创建初始化数据文件副本。这些数据文件副本必须手动传输到目标每张
4.创建RMAN脚本$TMPDIR/rmanconvert.cmd,在目标系统中它将被用来将数据文件副本的字节序转换为目标系统所使用的字节序

-c 转换数据文件:-c选项只有当使用RMAN备份创建初始化数据文件副本时才使用。在目标系统中转换数据文件副本只执行一次。这步操作将使用rmanconvert.cmd文件来将数据文件副本转换为目标系统所使用的字节序。转换后的数据文件副本会被存储到xtt.properties文件的storageondest参数所指定的目录中,也就是最终目标数据库存储数据文件的目录。

-i 创建增量备份: 创建增量备份可以对源数据库执行一次或多次。这个步骤会读取$TMPDIR/xttplan.txt中所记录的SCN并生成用于前滚目标系统上数据文件副本的增量备份文件。

-r 前滚数据文件:对于创建的每个增量备份都会对目标数据库的数据文件进行前滚操作。这步操作会连接到cnvinst_home与cnvinst_sid所定义的增量转换实例,转换所创建的增量备份,那么连接到目标数据库对数据文件应用增量备份进行前滚操作。

-s 判断新的from_scn:对源数据库判断新的from_scn可以执行一次或多次。这步操作会计算下次增量备份所需要的from_scn,并将其记录在xttplan.txt文件中,然后当下一次创建增量备份的就会使用它。

-e 生成Data Pump TTS命令:在目标系统中对目标数据库只执行一次来生成Data Pump TTS命令。这步操作将创建一个使用dblink来导入元数据的Data Pump Import命令

-d debug:-d选项能以debug模式来执行xttdriver.pl与RMAN命令。要启用debug模式需要设置环境变量XTTDEBUG=1

xtt.properties文件参数说明
tablespaces:用逗号来分隔从源数据库要被传输到目标数据库的表空间列表,例如tablespaces=TS1,TS2

platformid:从v$database.platform_id获得的源数据库的platform id,例如platformid=13

srcdir:源数据库中的目录对象,它指向源数据库中存储数据文件的目录。多个目录可以使用逗号进行分隔。srcdir与dstdir的映射可以是N:1或N:N。例如可以有多个源目录且文件存储到单个目标目录或者文件来自一个特定源目录将被存储到一个特定的目标目录。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srcdir=SOURCEDIR,srcdir=SRC1,SRC2

dstdir:目标数据库中的目录对象,它指向目标数据库中存储数据文件的目录。如果使用了多个源目录(srcdir),那么可以定义多个目标目录以便将特定源目录中的文件写入特定的目标目录中。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如dstdir=DESTDIR,dstdir=DST1,DST2

srclink:目标数据库中连接到源数据库的dblink。使用dbms_file_transfer传输数据文件时会使用这个dblink。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srclink=ttslink

dfcopydir:源系统中用来存储xttdriver.pl -p操作所生成的数据文件副本目录。这个目录要有足够的空间来存储所有被传输表空间的数据文件副本。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。 这个参数只有使用RMAN备份生成数据文件副本时才使用,例如dfcopydir=/stage_source

backupformat:源系统中存储增量备份文件的目录。这个目录必须要有足够的空间来存储所有创建的增量备份文件。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。例如,backupformat=/stage_source

stageondest:目标系统中存储从源系统中手动传输过来的数据文件副本。这个目录要有足够的空间来存储数据文件副本。这个目录同时也是用来存储从源系统传输过来的增量备份文件的目录。在目标系统上执行xttdriver.pl -c转换数据文件与执行xttdriver.pl -r前滚数据文件时会从这个目录中读取数据文件副本与增量备份文件。这个目标也可以是一个DBFS-mounted文件系统。个目录可以是源系统上通过NFS-mounted文件系统所挂载到目标系统中的一个目录,在这种情况下,源系统中的backupformat参数与dfcopydir参数就会引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。例如stageondest=/stage_dest

storageondest:目标系统中用来存储xttdriver.pl -c转换操作后所生成的数据文件副本的目录,也就是目标数据库最终存储数据文件的目录。这个目录要有足够的空间来永久存储数据文件。这个参数当使用RMAN备份来生成初始化数据文件副本时才使用,例如
storageondest=+DATA或者storageondest=/oradata/test

backupondest:目录系统中用来存储xttdriver.pl -r前滚操作所转换后的增量备份文件的目录。这个目录要有足够的空间来存储转换后的增量备份文件。注意,如果这个参数指向ASM磁盘目录,那么需要在xtt.properties参数文件中定义asm_home与asm_sid参数。如果这个参数指向文件系统目录,那么就从xtt.properties参数文件中删除asm_home与asm_sid参数。例如,backupondest=+RECO

cnvinst_home:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_HOME,例如cnvinst_home=/u01/app/oracle/product/11.2.0.4/xtt_home

cnvinst_sid:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_SID,例如cnvinst_xtt

asm_home:目标系统中ASM实例的ORACLE_HOME。注意如果backupondest设置为文件系统目录,那么就要删除asm_home与asm_sid参数,例如asm_home=/u01/app/11.2.0.4/grid

asm_sid:目标系统中ASM实例的ORACLE_SID。例如asm_sid=+ASM1

parallel:定义rmanconvert.cmd命令文件中rman convert命令的并行度。如果不设置这个参数,那么xttdriver.pl将使用parallel=8的缺省并行度。例如,parallel=3

rollparallel:定义xttdriver.pl -r前滚操作的并行度,例如rollparallel=2

getfileparallel:定义xttdriver.pl -G获取数据文件副本操作的并行度,缺省值是1,最大值为8,例如getfileparallel=4

11g使用增量备份来执行跨平台传输表空间减少停机时间(xtts_dbms_file_transfer)

使用跨平台传输表空间来迁移数据所需要的停机时间与被迁移的数据量成正比。然而,当使用增量备份跨平台迁移可以显著减小迁移数据所需要的停机时间。

传统跨平台传输表空间的主要步骤:
1.将源数据库中所被转输的表空间设置为read only
2.将所被传输表空间所相关的数据文件传输到目标主机上
3.将数据文件转换为目标主机所使用的字节序
4.使用data pump从源数据库导出所被传输表空间所存储对象的元数据
5.在目标数据库中使用data pump导入所被传输表空间所存储对象的元数据
6.使用目标数据库中的被传输表空间设置为read write

因为数据传输时表空间必须为read only,应用程序所拥有的数据在传输时不能被用户使用。因为操作是串行操作,所以停机时间依赖于数据量的大小。如果数据量大,数据文件传输与转换的时间将会很长,所以停机时间也就会很长。

使用跨平台增量备份来减少停机时间
为了减少停机时间需要使用XTTS,Oracle为跨平台传输增强了RMAN的能力来使用增量备份前滚数据文件副本。通过使用一些列的增量备份,每一份增量备份都比上一次的小,在需要停机之前,目标系统中的数据几乎可以从源系统中获得。数据文件传输与转换所需要的停机时间就由源系统中在最后一次增量备份之后被改变的数据量所决定。

跨平台增量备份不会影响XTTS所执行其它操作所花费的时间,比如元数据的导出与导入。因此,当数据库有大量的元数据时将会看到使用跨平台增量备份执行迁移的好处会受到影响,因为迁移所需时间通常是由元数据操作所决定的,而不是由数据文件传输与转换操作所决定的。

只有物理存储被迁移数据库对象的表空间需要被传输到目标系统。如果需要被迁移的其它对象,存储在不同表空间(比如,pl/sql对象,序列,等等,存储在system表空间中),可以使用data pump来复制这些对象到目标系统。

使用跨平台增量备份传输表空间的主要步骤如下:
1.准备阶段(源数据保持为online状态)
.传输被迁移表空间所相关的数据文件到目标系统
.如果需要,将数据文件转换成目标系统所使用的字节序

2.前滚阶段(源数据保持为online状态-可以根据需要重复达个阶段多次来使用目标数据文件匹配上源数据库文件)
.在源系统中创建增量备份
.传输增量备份到目标系统
.将增量备份转换为目标系统所使用的字节序并将备份应用到目标数据文件副本

注意,对于版本号为3的脚本,如果一个数据文件被增加到表空间或者一个新的表空间名被增加到xtt.properties文件中,一个告警信息与额外的指令需要被执行。

3.传输阶段(源数据为read only)
.将源数据库中需要被传输的表空间设置为read only
.最后一次执行前滚阶段的操作,这步操作可以确保目标数据文件副本与源数据库中的数据文件处于一致状态。这步操作所花费的时间要比传
统XTTS方法所需要的时间短,因为使用增量备份。
.使用data pump从源数据库中志出相关表空间中所存储对象的元数据
.在目标系统中使用data pump导出表空间所存储对象的元数据
.将目标数据库中的相关表空间设置为read write

这篇文章提供了一个例子来介绍如何使用跨平台增量备份来减少传输表空间的停机时间。

源系统可以是先决条件所引用的和平台与数据库所满足的列表中所列出任何平台。如果从一种小字节序平台迁移到Oracle Linux,那么最应该考虑的方法是使用Data Guard,可以参考Note 413484.1关于在当前小字节序平台与Oracle Linux之间Data Guard所支持的异构平台。对于Oracle 12c来说,请使用Note 2005729.1 12C – Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup.或者NOTE: Neither method supports 12c multitenant databases. Enhancement bug 22570430 addresses this limitation.

这里将介绍如何从Redhat Linux平台上将表空间cdzj,ldjc使用跨平台增量备份的传输表空间方法来迁移到Aix平台。在执行完初始化阶段后执行以下三个阶段来执行数据的迁移操作:
准备阶段
在准备阶段,要传输的表空间的数据文件会被传输到目标系统并被转换为目标系统所使用的字节序。在准备阶段应用程序是完全可以访问源数据的。准备阶段使用RMAN备份或dbms_file_transfer,后面将会详细介绍如何选择准备阶段所要使用的方法。

前滚阶段
在前滚阶段,在准备阶段被转换后的数据文件将会使用来自源数据库的增量备份来进行前滚操作。通过多次执行该阶段的操作,每次成功的增量备份将会更小与更快的应用到数据文件副本,允许目标系统中的数据都是来自源系统中。在执行前滚阶段时应用程序可以完全访问源数据。

传输阶段
在传输阶段,在源数据库中将要被传输的表空间设置为read only状态,并且在源平台上执行最后一次增量备份并且将它传输到目标平台上并应用到数据文件副本,使用目标系统中的数据文件副本与源数据库中的数据文件保护一致。一旦数据文件状态一致,从源数据库中导出所传输表空间所存储对象的元数据,并且在目标平台导入这些元数据。最后在目标数据库中将传输过来的表空间设置为read write状态。在传输阶段应用程序是不能更新源数据的。

跨平台增量备份所支持的脚本
跨平台增量备份的核心功能是基于Oracle 11.2.0.4与之后的版本。请查看条件与建议部分了解详细信息。另外有一组支持脚本存储在rman-xttconvert_2.0.zip。其中有两个主要支持的脚本:
.Perl脚本xttdriver.pl 这个脚本用来执行跨平台增量备份传输表空间的主要步骤。
.参数文件xtt.properties 这个文件包含自已平台特定配置

执行跨平台增量备份传输表空间的条件与建议
执行跨平台增量备份传输表空间的条件
在执行跨平台增量备份传输表空间之前需要检查是否满足以下条件:
.传输表空间的限制
.其它必须满足的条件
当前版本不支持windows
源数据库的compatible参数必须设置为10.2.0或更高版本
源数据库的compatible参数必须不能比目标数据库的compatible参数的值大
源数据库必须启用了archivelog模式
尽管首选目标系统是Linux操作系统(可以是64位的Oracle Linux或者是已经认证的Redhat Linux),但这个过程也可以在其它Unix操作系统中执行。然而,对于任何non-Linux操作系统来说数据库的版本必须是11.2.0.4
源数据库的版本必须小于或等于目标数据库的版本
RMAN的缺省设备类型应该被配置为DISK
源数据库的RMAN不能对DEVICE TYPE DISK使用COMPRESSED配置。如果使用COMPRESSED配置,执行操作时可能会返回:ORA-19994: cross-platform backup of compressed backups different endianess.
源数据库中将要被迁移的表空间必须是online,并且不能包含脱机数据文件。表空间必须为read write状态。表空间为read only那么可以使用正常的XTTS方法进行迁移。

.所有步骤中执行操作的用户必须是Oracle用户并且它是OSDBA组的成员。操作系统审计被用来连接源数据库与目标数据库。
.如果准备阶段方法选择dbms_file_transfer,那么目标数据库版本必须至少为11.2.0.4。
.如果准备阶段方法选择RMAN,那么在源系统与目标系统中都要创建预备区域
.对于备库或快照备库是不支持这种操作的
.如果目标数据库版本是11.2.0.3或更低的版本,那么在目标系统中需要有一个11.2.0.4的数据库home目录来运行11.2.0.4的实例来执行增量备份的转换操作。如果目标数据库版本是11.2.0.3或更低版本,那么需要一个版本为11.2.0.4的单独的增量转换Home目录与实例。如果ASM使用11.2.0.4的转换Home,那么ASM的版本也必须是11.2.0.4,否则会触发ORA-15295(ORA-15295: ASM instance software version 11.2.0.3.0 less than client version 11.2.0.4.0)。

整个数据库迁移
如果跨平台增量备份传输表空间被用来减少整个数据库的迁移时间,那么请参考MAA提供的XTTS指南Platform Migration Using Transportable Tablespaces(maa-wp-11g-platformmigrationtts-129269.pdf),这种迁移方法也可以用于Oracle 12c,然而对于12c有一种替代的方法可参考Note 2005729.1 12C – Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup.

选择准备阶段方法
在准备阶段,要被传输的表空间的数据文件会被传输到目标系统并且通过执行xttdriver.pl脚本进行转换。这里有两种可用的方法:
1.使用dbms_file_transfer(DFT)传输(使用xttdriver.pl -S与-G选项)
2.使用RMAN备份(使用xttdriver.pl -p与-c选项)

dbms_file_transfer方法使用dbms_file_transfer.get_file()过程来通过dblink从源系统中将数据文件传输到目标系统。dbms_file_transfer方法相比RMAN方法有以下优点:
1.不需要在源系统或目标系统中创建预备目录
2.在传输数据文件时会自动执行数据文件的转换–这里不需要再执行转换操作。

dbms_file_transfer方法要满足以下条件才能使用:
.目标数据库必须是11.2.0.4的版本。注意增量转换Home目录或实例不参与dbms_file_transfer的文件传输操作。
.在源数据库中有一个数据库目录对象它指向要被复制的数据文件
.原目标数据库中有一个数据库目录对象它指向要被存放的数据文件
.在目标数据库中有一个dblink连接到源数据库

RMAN备份方法在源系统中执行RMAN来对要被传输的数据文件生成备份。生成的备份文件必须手动跨网络传输到目标系统。在目标系统中通过执行RMAN对数据文件进行转换,如果需要,RMAN转换操作会将输出的数据文件存放在目标数据库最终存储数据文件的目录中。在原版本的xttdriver.pl中,只支持这种方法。RMAN备份方法要满足以下条件:
.在源系统与目标系统中需要为RMAN所创建的数据文件副本创建预备目录。预备目录在xtt.properties文件中分别指向参数dfcopydir与stageondest。被转换后的数据文件最终存放目录在xtt.properties文件中指向参数storageondest。

关于这些方法被提供的指令的详细信息后面会介绍,建议使用dbms_file_transfer方法。

目标数据库版本为11.2.0.3或更低版本需要安装一个单独的增量转换home与实例
跨平台增量备份的核心功能(例如,增量备份转换)是基于Oracle 11.2.0.4及以后版本的。如果目标数据库版本为11.2.0.4及以后版本,那么目标数据库可以执行这种功能。然而,如果目标数据库版本为11.2.0.3或更低版本,那么为了执行增量备份转换,需要安装一个单独的11.2.0.4的软件home目录,叫作增量转换home目录,并创建一个增量转换实例,并且该实例必须启动到时nomount状态。增量转换home目录与增量转换实例是临时使用,并且只在迁移操作期间使用。

因为dbms_file_transfer准备阶段方法要求目标数据库的版本为11.2.0.4,它可以被用来执行增量备份转换功能(如上所述),增量转换home目录与增量转换实例通常只有当使用RMAN备份方法来才会使用。对于如何设置一个临时增量转换实例参考阶段1。

诊断
为了启用诊断模式,可以使用-d参数来执行xttdriver.pl脚本,或者在执行xttdriver.pl脚本之前设置环境变量XTTDEBUG=1。Debug模式会启用额外的屏幕输出并且造成所有RMAN操作使用debug命令行选项。

已知问题
1.如果源数据库包含使用键压缩的嵌套的IOTs表,那么在目标数据库home中必须安装修复Bug 14835322的补丁
2.如果想在创建增量备份时对源数据库使用块改变跟踪功能,那么需要在源数据库home中安装修复Bug 16850197的补丁
3.如果前滚阶段(xttdriver.pl -r)失败并显示以下错误信息,那么验证RMAN的DEVICE TYPE DISK不能使用COMPRESSED配置

Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: RestoreSetPiece
DECLARE
*
ERROR at line 1:
ORA-19624: operation failed, retry possible
ORA-19870: error while restoring backup piece
/dbfs_direct/FS1/xtts/incrementals/xtts_incr_backup
ORA-19608: /dbfs_direct/FS1/xtts/incrementals/xtts_incr_backup is not a backup
piece
ORA-19837: invalid blocksize 0 in backup piece header
ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 2338
ORA-06512: at line 40

使用跨平台增量备份传输表空间来减少停机时间
跨平台增量备份传输表空间主要有以下四个阶段:
1.初始化设置阶段
2.准备阶段
3.前滚阶段
4.传输阶段

源系统为Redhat Linux,Oracle为11.2.0.4,目标系统为AIX,Oracle为11.2.0.4

1.初始化设置阶段
为了使用跨平台增量备份传输表空间执行以下操作来完成操作环境的配置:
1.1 安装目标数据库软件并创建目标数据库
在目标系统上安装所需要的数据库软件版本来运行目标数据库。强烈建议使用Oracle 11.2.0.4或之后的版本。注意dbms_file_transfer方法要求目标数据库为11.2.0.4。在目标系统中识别或创建一个数据库并创建需要传输的表空间及用户方案。我这里目标数据库为11.2.0.4,要被传输的用户方案为cdzj,ldjc,表空间为cdzj,ldjc。

1.2 如果需要,配置增量转换home与实例
如果目标数据库是11.2.0.3或之前版本,需要安装一个单独的增量转换home与实例。如果目标数据库是11.2.0.4或之后的版本,可以跳过这一步。注意dbms_file_transfer方法要求目标数据库的版本为11.2.0.4。如果目标数据库是11.2.0.3或之前版本,那么必须通过执行以下操作来配置一个单独的增量转换实例:
.在目标系统中安装一个新的11.2.0.4的数据库home。这就是增量转换home
.使用增量转换home启动一个实例到nomount状态,这个实例就是增量转换实例。对于增量转换实例不需要创建相应的数据库,只需要运行一个增量转换实例。

下面操作可以用来创建一个名叫xtt的增量转换实例,增量转换home为/oracle11/app/oracle/product/11.2.0/db:

IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$export ORACLE_HOME=/oracle11/app/oracle/product/11.2.0/db
IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$export ORACLE_SID=xtt
IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$cat < < EOF > $ORACLE_HOME/dbs/init$ORACLE_SID.ora
> db_name=xtt
> compatible=11.2.0.4.0
> EOF

IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 16 10:47:59 2017

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

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  797712384 bytes
Fixed Size                  2250200 bytes
Variable Size             490736168 bytes
Database Buffers          268435456 bytes
Redo Buffers               36290560 bytes

如果ASM被用于存储xtt.properties文件中的参数backupondest,那么实例的compatible参数的值必须等于或大于ASM磁盘组所使用的rdbms.compatible的值。

1.3 识别要被传输的表空间
识别源数据库中将要被传输的表空间。我这里要被传输的表空间为cdzj,ldjc。

1.4 如果使用dbms_file_transfer方法,那么配置目录对象与dblink
注意dbms_file_transfer方法要求目标数据库的版本为11.2.0.4,如果使用dbms_file_transfer访求,那么必须创建以下三个数据库对象:
.在源数据库中创建一个数据库目录对象,它指向要被复制的数据文件所存放的目录
.在目标数据库中创建一个数据库目录对象,它指向将要存放数据文件的目录
.在目标数据库中创建一个dblink连接到源数据库

源数据库目录对象引用源数据库中当前存放数据文件的目录。例如,下面创建目录对象指向,数据文件存放目录/home/app/oracle/product/11.2.0/dbs/,连接到源数据库房执行以下命令:

[oracle@sjjh ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Aug 15 17:10:58 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select a.NAME,b.NAME from v$tablespace a,v$datafile b where a.TS#=b.TS# and a.NAME in('CDZJ','LDJC');
NAME                           NAME
------------------------------ --------------------------------------------------------------------------------
LDJC                           /home/app/oracle/product/11.2.0/dbs/ldjc01
CDZJ                           /home/app/oracle/product/11.2.0/dbs/cdzj01

SQL> create directory sourcedir as '/home/app/oracle/product/11.2.0/dbs';

Directory created.

目标数据库目录对象引用目标数据库中将要存储数据文件的目录。这个目录是最终目标数据库将要存放数据文件的目录/oracle11/oradata/jycs/jycs/,连接到目标数据库执行以下命令

IBMP740-2:/oracle11$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 16 11:23:03 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/oracle11/oradata/jycs/jycs/system01.dbf
/oracle11/oradata/jycs/jycs/sysaux01.dbf
/oracle11/oradata/jycs/jycs/undotbs01.dbf
/oracle11/oradata/jycs/jycs/users01.dbf
/oracle11/oradata/jycs/jycs/example01.dbf

SQL> create directory destdir as '/oracle11/oradata/jycs/jycs';

Directory created.

在目标数据库中创建一个dblink连接到源数据库。例如创建一个名叫ttslink的dblink,执行以下命令:

SQL> create public database link ttslink
  2    connect to system identified by "xxzx7817600"
  3    using '(DESCRIPTION =
  4      (ADDRESS_LIST =
  5        (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.130.101)(PORT = 1521))
  6      )
  7      (CONNECT_DATA =
  8        (SERVER = DEDICATED)
  9        (SERVICE_NAME =sjjh)
 10      )
 11    )';

Database link created.

创建dblink后验证是否可以能过dblink访问源数据库

SQL> select * from dual@ttslink;

D
-
X

1.5 创建预备目录
在源系统与目标系统中创建预备目录,它们将被设置为xtt.properties文件中的backupformat(源系统中存放增量备份文件的目录),backupondest(目标系统中存放转换后的增量备份文件的目录)参数的值。如果使用RMAN备份方法,在源系统与目标系统中还需要为
xtt.properties文件中的dfcopydir(源系统中存放数据文件副本的目录,只有使用rman备份才使用),stageondest(目标系统中存放从源系统传输过来的数据文件副本与增量备份的目录,只有使用rman备份才使用)。

在源系统中执行下面的命令分别创建backupformat目录(/home/backup),dfcopydir目录(/home/dfcopydir)

[oracle@sjjh home]$ mkdir backup
[oracle@sjjh home]$ mkdir dfcopydir

在目标系统中执行下面的命令分别创建backupondest目录(/oracle11/backup),stagenodest目录(/oracle11/xtts)

IBMP740-2:/oracle11$mkdir backup
IBMP740-2:/oracle11$mkdir xtts

1.6在源系统中安装xttconver脚本
在源系统中,使用Oracle软件用户,下裁与解压脚本

[oracle@sjjh xtts_script]$ unzip rman_xttconvert_v3.zip
Archive:  rman_xttconvert_v3.zip
  inflating: xtt.properties          
  inflating: xttcnvrtbkupdest.sql    
  inflating: xttdbopen.sql           
  inflating: xttdriver.pl            
  inflating: xttprep.tmpl            
 extracting: xttstartupnomount.sql   
[oracle@sjjh xtts_script]$ ls -lrt
total 208
-rw-r--r-- 1 oracle oinstall   1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     52 May 24 16:57 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall  11710 May 24 16:57 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall 139331 May 24 16:57 xttdriver.pl
-rw-r--r-- 1 oracle oinstall     71 May 24 16:57 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall   7969 Jun  5 08:47 xtt.properties
-rw-r--r-- 1 oracle oinstall  33949 Aug 14 17:25 rman_xttconvert_v3.zip

1.7 在源系统中配置xtt.properties文件

[oracle@sjjh xtts_script]$ vi .xtt.properties
tablespaces=CDZJ,LDJC
platformid=13
srcdir=SOURCEDIR
dstdir=DESTDIR
srclink=ttslink
#dfcopydir=/home/dfcopydir
backupformat=/home/backup
stageondest=/oracle11/xtts
backupondest=/oracle11/backup
#storageondest=/oracle11/oradata/jycs/jycs
cnvinst_home=/oracle11/app/oracle/product/11.2.0/db
cnvinst_sid=xtt

1.8 将源系统中的转换脚本与xtt.properties文件复制到目标系统中

IBMP740-2:/oracle11/xtts_script$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password: 
230 Login successful.
ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 501      501          1390 May 24 08:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 501      501         11710 May 24 08:57 xttprep.tmpl
-rw-r--r--    1 501      501            52 May 24 08:57 xttstartupnomount.sql
-rw-r--r--    1 501      501            71 May 24 08:57 xttdbopen.sql
-rw-r--r--    1 501      501        139331 May 24 08:57 xttdriver.pl
-rw-r--r--    1 501      501          7969 Jun 05 00:47 xtt.properties.bak
-rw-r--r--    1 501      501         33949 Aug 14 09:25 rman_xttconvert_v3.zip
-rw-r--r--    1 501      501           255 Aug 16 06:58 xtt.properties
226 Directory send OK.

ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> get xttcnvrtbkupdest.sql
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttcnvrtbkupdest.sql (1390 bytes).
226 Transfer complete.
1390 bytes received in 7.6e-05 seconds (1.786e+04 Kbytes/s)
local: xttcnvrtbkupdest.sql remote: xttcnvrtbkupdest.sql
ftp> get xttprep.tmpl
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttprep.tmpl (11710 bytes).
226 Transfer complete.
11710 bytes received in 0.000196 seconds (5.834e+04 Kbytes/s)
local: xttprep.tmpl remote: xttprep.tmpl
ftp> get xttstartupnomount.sql
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttstartupnomount.sql (52 bytes).
226 Transfer complete.
52 bytes received in 0.000103 seconds (493 Kbytes/s)
local: xttstartupnomount.sql remote: xttstartupnomount.sql
ftp> get xttdbopen.sql
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttdbopen.sql (71 bytes).
226 Transfer complete.
71 bytes received in 0.000106 seconds (654.1 Kbytes/s)
local: xttdbopen.sql remote: xttdbopen.sql
ftp> get xttdriver.pl
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttdriver.pl (139331 bytes).
226 Transfer complete.
139331 bytes received in 0.001805 seconds (7.538e+04 Kbytes/s)
local: xttdriver.pl remote: xttdriver.pl
ftp> get xtt.properties
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xtt.properties (255 bytes).
226 Transfer complete.
255 bytes received in 0.00012 seconds (2075 Kbytes/s)
local: xtt.properties remote: xtt.properties

IBMP740-2:/oracle11/xtts_script$ls -lrt
total 336
-rw-r--r--    1 oracle11 oinstall       1390 Aug 16 15:44 xttcnvrtbkupdest.sql
-rw-r--r--    1 oracle11 oinstall      11710 Aug 16 15:45 xttprep.tmpl
-rw-r--r--    1 oracle11 oinstall         52 Aug 16 15:45 xttstartupnomount.sql
-rw-r--r--    1 oracle11 oinstall         71 Aug 16 15:45 xttdbopen.sql
-rw-r--r--    1 oracle11 oinstall     139331 Aug 16 15:45 xttdriver.pl
-rw-r--r--    1 oracle11 oinstall        255 Aug 16 15:46 xtt.properties

1.9 在源系统与目标系统中设置环境变TMPDIR,它指向转换脚本所在的目录。为了执行Perl脚本xttdriver.pl设置如下。如果TMPDIR没有设置,那么脚本生成的输出文件将会存放在/tmp目录中。

 
[oracle@sjjh xtts_script]$ export TMPDIR=/home/xtts_script

IBMP740-2:/oracle11$export TMPDIR=/oracle11/xtts_script

2.准备阶段
在准备阶段,被传输表空间的数据文件会被传输到目标系统并且通过执行xttdriver.pl脚本进行转换。有以下两种方法可以使用:
1. dbms_file_transfer方法
2. RMAN备份方法

对于大量数据文件使用dbms_file_transfer方法要比传输数据文件到目标系统更快。

2a.使用dbms_file_transfer方法
2a.1在源系统中执行准备操作
在源系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令:

[oracle@sjjh xtts_script]$ export ORACLE_HOME=/home/app/oracle/product/11.2.0
[oracle@sjjh xtts_script]$ export ORACLE_SID=sjjh
[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -S
============================================================
trace file is /home/xtts_script/setupgetfile_Aug17_Thu_08_58_56_833//Aug17_Thu_08_58_56_833_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Starting prepare phase
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /oracle11/xtts
xttpreparesrc.sql for 'CDZJ' started at Thu Aug 17 08:58:56 2017
xttpreparesrc.sql for  ended at Thu Aug 17 08:58:56 2017
Prepare source for Tablespaces:
                  'LDJC'  /oracle11/xtts
xttpreparesrc.sql for 'LDJC' started at Thu Aug 17 08:58:56 2017
xttpreparesrc.sql for  ended at Thu Aug 17 08:58:56 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 08:58:56 2017
xttpreparesrc.sql for  ended at Thu Aug 17 08:58:56 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 08:58:56 2017
xttpreparesrc.sql for  ended at Thu Aug 17 08:58:56 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 08:58:56 2017
xttpreparesrc.sql for  ended at Thu Aug 17 08:58:57 2017

--------------------------------------------------------------------
Done with prepare phase
--------------------------------------------------------------------

准备操作将在源系统中执行以下操作
.验证表空间是否online,read write且不包含脱机数据文件
.将创建后面所要使用的以下文件:
xttnewdatafiles.txt
getfile.sql

[oracle@sjjh xtts_script]$ cat xttnewdatafiles.txt
::CDZJ
7,DESTDIR:/cdzj01
::LDJC
6,DESTDIR:/ldjc01

[oracle@sjjh xtts_script]$ cat getfile.sql
0,SOURCEDIR,cdzj01,DESTDIR,cdzj01
1,SOURCEDIR,ldjc01,DESTDIR,ldjc01

要被传输的一组表空间必须是online,read write状态且不包含脱机数据文件。如果在源数据库中被传输表空间的一个或多个数据文件是脱机状态或read only就会触发错误。如果表空间在整个表空间传输过程中都保持read only状态,那么就使用传统的跨平台传输表空间,不要使用跨平台增量备份传输表空间。

2a.2 传输数据文件到目标系统中
在目标系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并复制上一步生成的xttnewdatafiles.txt与getfile.sql文件到目标系统并执行操作来获取数据文件

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password: 
230 Login successful.
ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 501      501          1390 May 24 08:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 501      501         11710 May 24 08:57 xttprep.tmpl
-rw-r--r--    1 501      501            52 May 24 08:57 xttstartupnomount.sql
-rw-r--r--    1 501      501            71 May 24 08:57 xttdbopen.sql
-rw-r--r--    1 501      501        139331 May 24 08:57 xttdriver.pl
-rw-r--r--    1 501      501          7969 Jun 05 00:47 xtt.properties.jy
-rw-r--r--    1 501      501         33949 Aug 14 09:25 rman_xttconvert_v3.zip
-rw-r--r--    1 501      501           304 Aug 17 00:57 xtt.properties
-rw-r--r--    1 501      501            50 Aug 17 00:58 xttplan.txt
-rw-r--r--    1 501      501           122 Aug 17 00:58 xttnewdatafiles.txt_temp
-rw-r--r--    1 501      501            68 Aug 17 00:58 getfile.sql
-rw-r--r--    1 501      501            50 Aug 17 00:58 xttnewdatafiles.txt
drwxr-xr-x    2 501      501          4096 Aug 17 00:58 setupgetfile_Aug17_Thu_08_58_56_833
226 Directory send OK.
ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> get xttnewdatafiles.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttnewdatafiles.txt (50 bytes).
226 Transfer complete.
50 bytes received in 8.1e-05 seconds (602.8 Kbytes/s)
local: xttnewdatafiles.txt remote: xttnewdatafiles.txt
ftp> get getfile.sql
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for getfile.sql (68 bytes).
226 Transfer complete.
68 bytes received in 0.000113 seconds (587.7 Kbytes/s)
local: getfile.sql remote: getfile.sql

# MUST set environment to destination database
IBMP740-2:/oracle11/xtts_script$export ORACLE_HOME=/oracle11/app/oracle/product/11.2.0/db
IBMP740-2:/oracle11/xtts_script$export ORACLE_SID=jycs

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -G
============================================================
trace file is /oracle11/xtts_script/getfile_Aug17_Thu_09_51_46_30//Aug17_Thu_09_51_46_30_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: srclink
Values: ttslink
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT srcdir
ARGUMENT dstdir
ARGUMENT srclink

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Getting datafiles from source
--------------------------------------------------------------------

fetchCheckDirObjectsDST: Check dir path 

fetchDirEntry: remotelink not present


--------------------------------------------------------------------
Executing getfile for /oracle11/xtts_script/getfile_Aug17_Thu_09_51_46_30//getfile_sourcedir_cdzj01_0.sql
--------------------------------------------------------------------


--------------------------------------------------------------------
Executing getfile for /oracle11/xtts_script/getfile_Aug17_Thu_09_51_46_30//getfile_sourcedir_ldjc01_1.sql
--------------------------------------------------------------------

PL/SQL procedure successfully completed.
PL/SQL procedure successfully completed.

--------------------------------------------------------------------
Completed getting datafiles from source
--------------------------------------------------------------------

IBMP740-2:/oracle11/oradata/jycs/jycs$ls -lrt

-rw-r-----    1 oracle11 oinstall 2147491840 Aug 17 09:52 cdzj01
-rw-r-----    1 oracle11 oinstall 5368717312 Aug 17 09:53 ldjc01

当这步操作完成后,要被传输的数据文件会存放在目标系统最终存放数据文件的目录中。转换操作会自动执行。下面就要执行前滚阶段的操作了。

3.前滚阶段
下面在源数据库中创建增量数据

SQL> insert into ldjc.jy_test values(4);
1 row inserted

SQL> insert into cdzj.jy_test values(4);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3
                    4

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3
                    4

在这个阶段,会在源系统中对源数据库创建增量备份,然后将生成的增量备份传输到目标系统中,并将增量备份转换为目标系统所使用的字节序,然后将转换后的增量备份应用到转换后的数据文件进行前滚操作。这个阶段的操作可以执行多次,每一次成功的增量备份应该比之前的增量备份花费更少的时间,并且让目标系统中的数据文件的内容更加接近源数据库的内容。在这个阶段源数据库中被传输的数据完全可以被访问。

3.1 在源系统中对被传输的表空间LDJC,CDZJ创建增量备份
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /home/xtts_script/incremental_Aug17_Thu_09_27_17_44//Aug17_Thu_09_27_17_44_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /oracle11/xtts
xttpreparesrc.sql for 'CDZJ' started at Thu Aug 17 09:27:17 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:27:17 2017
Prepare source for Tablespaces:
                  'LDJC'  /oracle11/xtts
xttpreparesrc.sql for 'LDJC' started at Thu Aug 17 09:27:17 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:27:17 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:27:17 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:27:18 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:27:18 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:27:18 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:27:18 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:27:18 2017
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''''''''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

[root@sjjh xtts_script]# cat tsbkupmap.txt
LDJC::6:::1=37sc4a3r_1_1
CDZJ::7:::1=36sc4a3o_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

[root@sjjh xtts_script]# cat incrbackups.txt
/home/backup/37sc4a3r_1_1
/home/backup/36sc4a3o_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@sjjh backup]$ ls -lrt
total 272
-rw-r----- 1 oracle oinstall  49152 Aug 17 09:27 36sc4a3o_1_1
-rw-r----- 1 oracle oinstall 229376 Aug 17 09:27 37sc4a3r_1_1

3.2 将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password: 
230 Login successful.
ftp> cd /home/backup
250 Directory successfully changed.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r-----    1 501      501         49152 Aug 17 01:27 36sc4a3o_1_1
-rw-r-----    1 501      501        229376 Aug 17 01:27 37sc4a3r_1_1
226 Directory send OK.
ftp> lcd /oracle11/xtts
Local directory now /oracle11/xtts
ftp> bin
200 Switching to Binary mode.
ftp> get 36sc4a3o_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 36sc4a3o_1_1 (49152 bytes).
226 Transfer complete.
49152 bytes received in 0.000788 seconds (6.091e+04 Kbytes/s)
local: 36sc4a3o_1_1 remote: 36sc4a3o_1_1
ftp> get 37sc4a3r_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 37sc4a3r_1_1 (229376 bytes).
226 Transfer complete.
229376 bytes received in 0.002345 seconds (9.552e+04 Kbytes/s)
local: 37sc4a3r_1_1 remote: 37sc4a3r_1_1

IBMP740-2:/oracle11/xtts$ls -lrt
total 552
-rw-r--r--    1 oracle11 oinstall      49152 Aug 17 10:13 36sc4a3o_1_1
-rw-r--r--    1 oracle11 oinstall     229376 Aug 17 10:13 37sc4a3r_1_1

3.3 在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password: 
230 Login successful.
ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 501      501          1390 May 24 08:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 501      501         11710 May 24 08:57 xttprep.tmpl
-rw-r--r--    1 501      501            52 May 24 08:57 xttstartupnomount.sql
-rw-r--r--    1 501      501            71 May 24 08:57 xttdbopen.sql
-rw-r--r--    1 501      501        139331 May 24 08:57 xttdriver.pl
-rw-r--r--    1 501      501          7969 Jun 05 00:47 xtt.properties.jy
-rw-r--r--    1 501      501         33949 Aug 14 09:25 rman_xttconvert_v3.zip
-rw-r--r--    1 501      501           304 Aug 17 00:57 xtt.properties
-rw-r--r--    1 501      501            50 Aug 17 00:58 xttplan.txt
-rw-r--r--    1 501      501           122 Aug 17 00:58 xttnewdatafiles.txt_temp
-rw-r--r--    1 501      501            68 Aug 17 00:58 getfile.sql
-rw-r--r--    1 501      501            50 Aug 17 00:58 xttnewdatafiles.txt
drwxr-xr-x    2 501      501          4096 Aug 17 00:58 setupgetfile_Aug17_Thu_08_58_56_833
-rw-r--r--    1 501      501            50 Aug 17 01:27 xttplan.txt_tmp
-rw-r--r--    1 501      501           122 Aug 17 01:27 xttnewdatafiles.txt.added_temp
-rw-r--r--    1 501      501            50 Aug 17 01:27 xttnewdatafiles.txt.added
-rw-r--r--    1 501      501            54 Aug 17 01:27 xttplan.txt.new
-rw-r--r--    1 501      501            68 Aug 17 01:27 getfile.sql.added
drwxr-xr-x    2 501      501          4096 Aug 17 01:27 incremental_Aug17_Thu_09_27_17_44
-rw-r--r--    1 501      501            50 Aug 17 01:27 tsbkupmap.txt
-rw-r--r--    1 501      501            52 Aug 17 01:27 incrbackups.txt
226 Directory send OK.
ftp> bin
200 Switching to Binary mode.
ftp> get xttplan.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttplan.txt (50 bytes).
226 Transfer complete.
50 bytes received in 5.1e-05 seconds (957.4 Kbytes/s)
local: xttplan.txt remote: xttplan.txt
ftp> get tsbkupmap.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 6.3e-05 seconds (775 Kbytes/s)
local: tsbkupmap.txt remote: tsbkupmap.txt

IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
CDZJ::::14690206228470
7
LDJC::::14690206228470
6
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
LDJC::6:::1=37sc4a3r_1_1
CDZJ::7:::1=36sc4a3o_1_1

IBMP740-2:/oracle11/xtts_script$export XTTDEBUG=1
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /oracle11/xtts_script/rollforward_Aug17_Thu_10_19_56_134//Aug17_Thu_10_19_56_134_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: srclink
Values: ttslink
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /oracle11/app/oracle/product/11.2.0/db 

convert instance: xtt 

ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2253216 bytes
Variable Size             922750560 bytes
Database Buffers         3305111552 bytes
Redo Buffers               45666304 bytes
rdfno 7

BEFORE ROLLPLAN

datafile number : 7  

datafile name   : /oracle11/oradata/jycs/jycs/cdzj01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_36sc4a3o_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
rdfno 6

BEFORE ROLLPLAN

datafile number : 6  

datafile name   : /oracle11/oradata/jycs/jycs/ldjc01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_37sc4a3r_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。

3.4 为下一次增量备份判断from_scn
再次生成增量数据

SQL> insert into ldjc.jy_test values(5);
1 row inserted

SQL> insert into cdzj.jy_test values(5);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3
                    4
                    5

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3
                    4
                    5

在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /home/xtts_script/determinescn_Aug17_Thu_09_38_55_687//Aug17_Thu_09_38_55_687_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
New /home/xtts_script/xttplan.txt with FROM SCN's generated

这步操作会计算下一个from_scn,并记录在xttplan.txt文件中,当下次创建增量备份时会使用这个scn

[root@sjjh xtts_script]# cat xttplan.txt
 CDZJ::::14690206228470
 7
 LDJC::::14690206228470

3.5 再次重复前滚阶段或执行传输阶段
这里有两种选择:
1.如果如果将目标数据库中的数据文件与源数据库中的数据文件进行最接近的同步,那么就重复执行前滚操作。
2.如果目标数据库中的数据文件与源数据库中的数据文件已经达到所期望的接近,那么执行传输阶段的操作。

注意:如果从上一次增量备份后增加了一个新的表空间或者一个新的表空间名增加到xtt.properties文件中,那么将会出现以下错误:

Error:
------
The incremental backup was not taken as a datafile has been added to the tablespace:

Please Do the following:
--------------------------
1. Copy fixnewdf.txt from source to destination temp dir

2. Copy backups:

from  to the  in destination

3. On Destination, run $ORACLE_HOME/perl/bin/perl xttdriver.pl --fixnewdf

4. Re-execute the incremental backup in source:
$ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpincr

NOTE: Before running incremental backup, delete FAILED in source temp dir or
run xttdriver.pl with -L option:

$ORACLE_HOME/perl/bin/perl xttdriver.pl -L --bkpincr

These instructions must be followed exactly as listed. The next incremental backup will include the new datafile.  

我这里再次执行前滚操作
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /home/xtts_script/incremental_Aug17_Thu_09_40_18_342//Aug17_Thu_09_40_18_342_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /oracle11/xtts
xttpreparesrc.sql for 'CDZJ' started at Thu Aug 17 09:40:18 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:40:18 2017
Prepare source for Tablespaces:
                  'LDJC'  /oracle11/xtts
xttpreparesrc.sql for 'LDJC' started at Thu Aug 17 09:40:18 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:40:18 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:40:18 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:40:18 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:40:18 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:40:19 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:40:19 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:40:19 2017
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''''''''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt
tsbkupmap.txt的内容如下:

[root@sjjh xtts_script]# cat tsbkupmap.txt
LDJC::6:::1=39sc4as8_1_1
CDZJ::7:::1=38sc4as5_1_1

文件中的内容记录了表空间与增量备份的关联关系
incrbackups.txt的内容如下:

[root@sjjh xtts_script]# cat incrbackups.txt
/home/backup/39sc4as8_1_1
/home/backup/38sc4as5_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@sjjh backup]$ ls -lrt
-rw-r----- 1 oracle oinstall  49152 Aug 17 09:40 38sc4as5_1_1
-rw-r----- 1 oracle oinstall 270336 Aug 17 09:40 39sc4as8_1_1

将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password: 
230 Login successful.
ftp> cd /home/backup
250 Directory successfully changed.
ftp> lcd /oracle11/xtts
Local directory now /oracle11/xtts
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r-----    1 501      501         49152 Aug 17 01:27 36sc4a3o_1_1
-rw-r-----    1 501      501        229376 Aug 17 01:27 37sc4a3r_1_1
-rw-r-----    1 501      501         49152 Aug 17 01:40 38sc4as5_1_1
-rw-r-----    1 501      501        270336 Aug 17 01:40 39sc4as8_1_1
226 Directory send OK.
ftp> bin
200 Switching to Binary mode.
ftp> get 38sc4as5_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 38sc4as5_1_1 (49152 bytes).
226 Transfer complete.
49152 bytes received in 0.000712 seconds (6.742e+04 Kbytes/s)
local: 38sc4as5_1_1 remote: 38sc4as5_1_1
ftp> get 39sc4as8_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 39sc4as8_1_1 (270336 bytes).
226 Transfer complete.
270336 bytes received in 0.002906 seconds (9.085e+04 Kbytes/s)
local: 39sc4as8_1_1 remote: 39sc4as8_1_1

IBMP740-2:/oracle11/xtts$ls -lrt
-rw-r--r--    1 oracle11 oinstall      49152 Aug 17 10:26 38sc4as5_1_1
-rw-r--r--    1 oracle11 oinstall     270336 Aug 17 10:26 39sc4as8_1_1

在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password: 
230 Login successful.
ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 501      501          1390 May 24 08:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 501      501         11710 May 24 08:57 xttprep.tmpl
-rw-r--r--    1 501      501            52 May 24 08:57 xttstartupnomount.sql
-rw-r--r--    1 501      501            71 May 24 08:57 xttdbopen.sql
-rw-r--r--    1 501      501        139331 May 24 08:57 xttdriver.pl
-rw-r--r--    1 501      501          7969 Jun 05 00:47 xtt.properties.jy
-rw-r--r--    1 501      501         33949 Aug 14 09:25 rman_xttconvert_v3.zip
-rw-r--r--    1 501      501           304 Aug 17 00:57 xtt.properties
-rw-r--r--    1 501      501           122 Aug 17 00:58 xttnewdatafiles.txt_temp
-rw-r--r--    1 501      501            68 Aug 17 00:58 getfile.sql
-rw-r--r--    1 501      501            50 Aug 17 00:58 xttnewdatafiles.txt
drwxr-xr-x    2 501      501          4096 Aug 17 00:58 setupgetfile_Aug17_Thu_08_58_56_833
drwxr-xr-x    2 501      501          4096 Aug 17 01:27 incremental_Aug17_Thu_09_27_17_44
-rw-r--r--    1 501      501            54 Aug 17 01:38 xttplan.txt
drwxr-xr-x    2 501      501          4096 Aug 17 01:38 determinescn_Aug17_Thu_09_38_55_687
-rw-r--r--    1 501      501            50 Aug 17 01:40 xttplan.txt_tmp
-rw-r--r--    1 501      501           122 Aug 17 01:40 xttnewdatafiles.txt.added_temp
-rw-r--r--    1 501      501            50 Aug 17 01:40 xttnewdatafiles.txt.added
-rw-r--r--    1 501      501            54 Aug 17 01:40 xttplan.txt.new
-rw-r--r--    1 501      501            68 Aug 17 01:40 getfile.sql.added
drwxr-xr-x    2 501      501          4096 Aug 17 01:40 incremental_Aug17_Thu_09_40_18_342
-rw-r--r--    1 501      501            50 Aug 17 01:40 tsbkupmap.txt
-rw-r--r--    1 501      501            52 Aug 17 01:40 incrbackups.txt
226 Directory send OK.
ftp> bin
200 Switching to Binary mode.
ftp> get xttplan.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttplan.txt (54 bytes).
226 Transfer complete.
54 bytes received in 4.7e-05 seconds (1122 Kbytes/s)
local: xttplan.txt remote: xttplan.txt
ftp> get tsbkupmap.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 5e-05 seconds (976.6 Kbytes/s)
local: tsbkupmap.txt remote: tsbkupmap.txt


IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
 CDZJ::::14690206228470
 7
 LDJC::::14690206228470
 6
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
LDJC::6:::1=39sc4as8_1_1
CDZJ::7:::1=38sc4as5_1_1

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /oracle11/xtts_script/rollforward_Aug17_Thu_10_32_10_553//Aug17_Thu_10_32_10_553_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: srclink
Values: ttslink
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /oracle11/app/oracle/product/11.2.0/db 

convert instance: xtt 

ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2253216 bytes
Variable Size             922750560 bytes
Database Buffers         3305111552 bytes
Redo Buffers               45666304 bytes
rdfno 7

BEFORE ROLLPLAN

datafile number : 7  

datafile name   : /oracle11/oradata/jycs/jycs/cdzj01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_38sc4as5_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
rdfno 6

BEFORE ROLLPLAN

datafile number : 6  

datafile name   : /oracle11/oradata/jycs/jycs/ldjc01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_39sc4as8_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。

为下一次增量备份判断from_scn
再次生成增量数据

SQL> insert into ldjc.jy_test values(6);
1 row inserted

SQL> insert into cdzj.jy_test values(6);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3
                    4
                    5
                    6
6 rows selected

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3
                    4
                    5
                    6
6 rows selected

在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /home/xtts_script/determinescn_Aug17_Thu_09_51_39_530//Aug17_Thu_09_51_39_530_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
New /home/xtts_script/xttplan.txt with FROM SCN's generated

[root@sjjh xtts_script]# cat xttplan.txt
 CDZJ::::14690214364189
 7
 LDJC::::14690214364209
 6

4.传输阶段
在执行传输阶段操作时,源数据库中被传输表空间要设置为read only状态,并且通过创建与应用最后一次的增量备份使用目标数据库中的数据文件与源数据库中的数据文件内容保持一致。在目标数据库数据文件与源数据库数据文件内容达成一致后,在源系统中执行正常的传输表空间操作来导出元数据,然后将元数据导入到目标数据库中。直到传输阶段操作完成之前,被传输的数据只能以read only模式被访问。

4.1 将源数据库中被传输表空间设置为read only状态
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令将表空间设置为read only:

SQL> alter tablespace ldjc read only;

Tablespace altered.

SQL> alter tablespace cdzj read only;

Tablespace altered.

SQL> alter tablespace ldjc read only;

Tablespace altered.

SQL> alter tablespace cdzj read only;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
LDJC                           READ ONLY
CDZJ                           READ ONLY
SWPT                           ONLINE
YLZWS                          ONLINE
ESB                            ONLINE

< ?pre>
4.2 最后一次创建增量备份,并传输到目标系统且执行转换并应用到目标数据文件
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:
[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /home/xtts_script/incremental_Aug17_Thu_09_53_24_31//Aug17_Thu_09_53_24_31_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /oracle11/xtts
xttpreparesrc.sql for 'CDZJ' started at Thu Aug 17 09:53:24 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:53:25 2017
Prepare source for Tablespaces:
                  'LDJC'  /oracle11/xtts
xttpreparesrc.sql for 'LDJC' started at Thu Aug 17 09:53:25 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:53:25 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:53:25 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:53:25 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:53:25 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:53:25 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Thu Aug 17 09:53:25 2017
xttpreparesrc.sql for  ended at Thu Aug 17 09:53:25 2017
============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''''''''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

[root@sjjh xtts_script]# cat tsbkupmap.txt
CDZJ::7:::1=3asc4bkn_1_1
LDJC::6:::1=3bsc4bkq_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

[root@sjjh xtts_script]# cat incrbackups.txt
/home/backup/3asc4bkn_1_1
/home/backup/3bsc4bkq_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@sjjh backup]$ ls -lrt
-rw-r----- 1 oracle oinstall  49152 Aug 17 09:53 3asc4bkn_1_1
-rw-r----- 1 oracle oinstall 188416 Aug 17 09:53 3bsc4bkq_1_1

将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password: 
230 Login successful.
ftp> cd /home/backup
250 Directory successfully changed.
ftp> lcd /oracle11/xtts
Local directory now /oracle11/xtts
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r-----    1 501      501         49152 Aug 17 01:27 36sc4a3o_1_1
-rw-r-----    1 501      501        229376 Aug 17 01:27 37sc4a3r_1_1
-rw-r-----    1 501      501         49152 Aug 17 01:40 38sc4as5_1_1
-rw-r-----    1 501      501        270336 Aug 17 01:40 39sc4as8_1_1
-rw-r-----    1 501      501         49152 Aug 17 01:53 3asc4bkn_1_1
-rw-r-----    1 501      501        188416 Aug 17 01:53 3bsc4bkq_1_1
226 Directory send OK.
ftp> bin
200 Switching to Binary mode.
ftp> get 3asc4bkn_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 3asc4bkn_1_1 (49152 bytes).
226 Transfer complete.
49152 bytes received in 0.000935 seconds (5.134e+04 Kbytes/s)
local: 3asc4bkn_1_1 remote: 3asc4bkn_1_1
ftp> get 3bsc4bkq_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 3bsc4bkq_1_1 (188416 bytes).
226 Transfer complete.
188416 bytes received in 0.001948 seconds (9.446e+04 Kbytes/s)
local: 3bsc4bkq_1_1 remote: 3bsc4bkq_1_1

IBMP740-2:/oracle11/xtts$ls -lrt
-rw-r--r--    1 oracle11 oinstall      49152 Aug 17 10:39 3asc4bkn_1_1
-rw-r--r--    1 oracle11 oinstall     188416 Aug 17 10:39 3bsc4bkq_1_1

在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> get xttplan.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttplan.txt (54 bytes).
226 Transfer complete.
54 bytes received in 9.9e-05 seconds (532.7 Kbytes/s)
local: xttplan.txt remote: xttplan.txt
ftp> get tsbkupmap.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 9.9e-05 seconds (493.2 Kbytes/s)
local: tsbkupmap.txt remote: tsbkupmap.txt

IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
 CDZJ::::14690214364189
 7
 LDJC::::14690214364209
 6
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
CDZJ::7:::1=3asc4bkn_1_1
LDJC::6:::1=3bsc4bkq_1_1

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /oracle11/xtts_script/rollforward_Aug17_Thu_10_42_33_35//Aug17_Thu_10_42_33_35_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: srclink
Values: ttslink
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /oracle11/app/oracle/product/11.2.0/db 

convert instance: xtt 

ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2253216 bytes
Variable Size             922750560 bytes
Database Buffers         3305111552 bytes
Redo Buffers               45666304 bytes
rdfno 7

BEFORE ROLLPLAN

datafile number : 7  

datafile name   : /oracle11/oradata/jycs/jycs/cdzj01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_3asc4bkn_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
rdfno 6

BEFORE ROLLPLAN

datafile number : 6  

datafile name   : /oracle11/oradata/jycs/jycs/ldjc01

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_3bsc4bkq_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

4.3 在目标数据库中导入元数据
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来生成Data Pump TTS命令:

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -e
============================================================
trace file is /oracle11/xtts_script/generate_Aug17_Thu_10_43_24_460//Aug17_Thu_10_43_24_460_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: srclink
Values: ttslink
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dstdir
Values: DESTDIR
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: srcdir
Values: SOURCEDIR
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Generating plugin
--------------------------------------------------------------------


--------------------------------------------------------------------
Done generating plugin file /oracle11/xtts_script/xttplugin.txt
--------------------------------------------------------------------

IBMP740-2:/oracle11/xtts_script$cat /oracle11/xtts_script/xttplugin.txt
impdp directory= logfile= \
network_link= transport_full_check=no \
transport_tablespaces=CDZJ,LDJC \
transport_datafiles='/oracle11/oradata/jycs/jycs/cdzj01','/oracle11/oradata/jycs/jycs/ldjc01'

上面的命令会生成一个名叫xttplugin.txt的文件,文件创建了一个使用network_link参数执行传输表空间导入元数据的命令。命令中的transport_tablespaces与transport_datafiles参数已经设置正确。注意network_link模式指示导入通过使用dblink来完成,就不需要执行导出或使用dump文件。如果选择执行这个命令来完成表空间的传输就需要修改directory,logfile与network_link参数

SQL> create directory dump_dir as '/oracle11/xtts_script';

Directory created.
SQL> grant read,write on directory dump_dir to public;

Grant succeeded.

在目标数据库中创建用户方案LDJC,CDZJ

SQL> create user ldjc identified by "ldjc";

User created.

SQL> grant dba,connect,resource to ldjc;

Grant succeeded.

SQL> create user cdzj identified by "cdzj";

User created.


SQL> grant dba,connect,resource to cdzj;

Grant succeeded.

IBMP740-2:/oracle11/xtts_script$vi xttplugin.txt
impdp system/xxzx7817600 directory=dump_dir logfile=tts_imp.log 
network_link=ttslink transport_full_check=no 
transport_tablespaces=CDZJ,LDJC 
transport_datafiles='/oracle11/oradata/jycs/jycs/cdzj01','/oracle11/oradata/jycs/jycs/ldjc01'


IBMP740-2:/oracle11/xtts_script$impdp system/abcd directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles='/oracle11/oradata/jycs/jycs/cdzj01','/oracle11/oradata/jycs/jycs/ldjc01'

Import: Release 11.2.0.4.0 - Production on Thu Aug 17 10:50:02 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01":  system/******** directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles=/oracle11/oradata/jycs/jycs/cdzj01,/oracle11/oradata/jycs/jycs/ldjc01 
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/COMMENT
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Thu Aug 17 10:51:07 2017 elapsed 0 00:01:05

IBMP740-2:/home/oracle11$impdp system/abcd directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink

Import: Release 11.2.0.4.0 - Production on Fri Aug 18 08:40:01 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink 
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"LDJC" already exists
ORA-31684: Object type USER:"CDZJ" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Processing object type SCHEMA_EXPORT/DB_LINK
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/VIEW/VIEW
ORA-39082: Object type VIEW:"LDJC"."DB03" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AA10" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AA12" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_USER" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_WEB_NSLOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB02_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB01_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB02_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB03" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB03H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB03_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB04" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB04H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB04_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB05" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB05H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB05_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BC02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BC02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BC02_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BD01_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BD02_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BD03_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BF01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BF01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ01_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ02_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ03" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ03H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ04" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ04H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ04_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ05" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ05H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ05_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ06" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ06H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ07" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ07H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ07_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ08" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ08H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ09" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ09H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ09_TEMP" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ10" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ10H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ10_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ11_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."OAE300_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."TEMP_AAB002" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."V_JCXT_AJGL_JABP" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."JCXT_AJGL_ZWNR" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."V_JCXT_AJGL_LABP" created with compilation warnings
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_PKG" created with compilation warnings
ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_SQLTRACE" created with compilation warnings
Processing object type SCHEMA_EXPORT/JOB
Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCOBJ
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 72 error(s) at Fri Aug 18 08:40:22 2017 elapsed 0 00:00:20




SQL> select * from ldjc.jy_test;

   USER_ID
----------
         1
         2
         3
         4
         5
         6

6 rows selected.

SQL> select * from cdzj.jy_test;

   USER_ID
----------
         1
         2
         3
         4
         5
         6

6 rows selected.

元数据导入后,可以将源数据库中的表空间ldjc,cdzj修改为read write状态

SQL> alter tablespace ldjc read write;

Tablespace altered.

SQL>  alter tablespace cdzj read write;

Tablespace altered.

如果不使用network_link执行导入,那么可以执行传输表空间模式的data pump导出元数据,然后将元数据复制到目标数据库,再执行导入。

4.4 将目标数据库中的表空间ldjc,cdzj修改为read write状态

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
CDZJ                           READ ONLY
LDJC                           READ ONLY

8 rows selected.

SQL> alter tablespace ldjc read write;

Tablespace altered.

SQL> alter tablespace cdzj read write;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
CDZJ                           ONLINE
LDJC                           ONLINE

8 rows selected.

4.5 验证传输的数据
在这一步,在目标数据库中被传输过来的表空间设置为read only状态,然后运行应用程序来进行验证。也可以使用RMAN来检查物理与逻辑块损坏的情况。

IBMP740-2:/oracle11/xtts$export ORACLE_SID=jycs
IBMP740-2:/oracle11/xtts$rman target/

Recovery Manager: Release 11.2.0.4.0 - Production on Thu Aug 17 10:53:35 2017

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

connected to target database: JYCS (DBID=551365347)

RMAN> validate tablespace LDJC,CDZJ check logical;

Starting validate at 2017-08-17 10:53:46
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=117 device type=DISK
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00007 name=/oracle11/oradata/jycs/jycs/ldjc01
input datafile file number=00006 name=/oracle11/oradata/jycs/jycs/cdzj01
channel ORA_DISK_1: validation complete, elapsed time: 00:00:25
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
6    OK     0              255625       262144          14690217786416
  File Name: /oracle11/oradata/jycs/jycs/cdzj01
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              6239            
  Index      0              0               
  Other      0              280             

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7    OK     0              3746         655360          14690216217839
  File Name: /oracle11/oradata/jycs/jycs/ldjc01
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              361625          
  Index      0              286299          
  Other      0              3690            

Finished validate at 2017-08-17 10:54:12

5.清除阶段
如果为了迁移创建了单独的转换home与实例,那么在传输表空间操作完成之后可以关闭实例并删除软件。为了执行跨平台增量备份传输表空间而创建的文件与目录也可以删除了,例如:
.源系统中的dfcopydir目录
.源系统中的backupformat目录
.目标系统中的stageondest目录
.目标系统中的backupondest目录
.源系统与目标系统中的$TMPDIR环境变量

Perl脚本xttdriver.pl选项
-S 准备传输源:-S选项只有当使用dbms_file_transfer方法传输数据文件时使用。这个准备操作在源系统中只对源数据库执行一次。这步操作将创建xttnewdatafiles.txt与getfile.sql文件

-G 从源系统获取数据文件:-G选项只有当使用dbms_file_transfer方法传输数据文件时使用。获取数据文件操作在目标系统中对目标数据库只执行一次。-S选项必须在它之前执行一次,并将生成的xttnewdatafiles.txt与getfile.sql文件传输到目标系统。-G选项会连接到目标数据库并执行脚本getfile.sql。getfile.sql将调用dbms_file_transfer.get_file()过程通过使用dblink(srclink)来从源数据库的目录对象(srcdir)中获取要被传输的数据文件到目标数据库的目录对象(dstdir)中。

-p 准备对源数据库执行备份:-p选项只有当使用RMAN备份方法来生成数据文件副本时才使用。这步操作在源系统中对源数据库只执行一次。这步操作会连接到源数据库并对要被传输的每个表空间执行一次xttpreparesrc.sql脚本。xttpreparesrc.sql会执行以下操作:
1.验证表空间是否处于online,read write模式与是否不包含脱机数据文件
2.标识第一次执行增量备份操作时所需要使用的SCN信息并将它们写入$TMPDIR目录中的xttplan.txt文件中
3.在源系统中会在xtt.properties文件的dfcopydir参数所指定的目录中创建初始化数据文件副本。这些数据文件副本必须手动传输到目标每张
4.创建RMAN脚本$TMPDIR/rmanconvert.cmd,在目标系统中它将被用来将数据文件副本的字节序转换为目标系统所使用的字节序

-c 转换数据文件:-c选项只有当使用RMAN备份创建初始化数据文件副本时才使用。在目标系统中转换数据文件副本只执行一次。这步操作将使用rmanconvert.cmd文件来将数据文件副本转换为目标系统所使用的字节序。转换后的数据文件副本会被存储到xtt.properties文件的storageondest参数所指定的目录中,也就是最终目标数据库存储数据文件的目录。

-i 创建增量备份: 创建增量备份可以对源数据库执行一次或多次。这个步骤会读取$TMPDIR/xttplan.txt中所记录的SCN并生成用于前滚目标系统上数据文件副本的增量备份文件。

-r 前滚数据文件:对于创建的每个增量备份都会对目标数据库的数据文件进行前滚操作。这步操作会连接到cnvinst_home与cnvinst_sid所定义的增量转换实例,转换所创建的增量备份,那么连接到目标数据库对数据文件应用增量备份进行前滚操作。

-s 判断新的from_scn:对源数据库判断新的from_scn可以执行一次或多次。这步操作会计算下次增量备份所需要的from_scn,并将其记录在xttplan.txt文件中,然后当下一次创建增量备份的就会使用它。

-e 生成Data Pump TTS命令:在目标系统中对目标数据库只执行一次来生成Data Pump TTS命令。这步操作将创建一个使用dblink来导入元数据的Data Pump Import命令

-d debug:-d选项能以debug模式来执行xttdriver.pl与RMAN命令。要启用debug模式需要设置环境变量XTTDEBUG=1

xtt.properties文件参数说明
tablespaces:用逗号来分隔从源数据库要被传输到目标数据库的表空间列表,例如tablespaces=TS1,TS2

platformid:从v$database.platform_id获得的源数据库的platform id,例如platformid=13

srcdir:源数据库中的目录对象,它指向源数据库中存储数据文件的目录。多个目录可以使用逗号进行分隔。srcdir与dstdir的映射可以是N:1或N:N。例如可以有多个源目录且文件存储到单个目标目录或者文件来自一个特定源目录将被存储到一个特定的目标目录。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srcdir=SOURCEDIR,srcdir=SRC1,SRC2

dstdir:目标数据库中的目录对象,它指向目标数据库中存储数据文件的目录。如果使用了多个源目录(srcdir),那么可以定义多个目标目录以便将特定源目录中的文件写入特定的目标目录中。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如
dstdir=DESTDIR,dstdir=DST1,DST2

srclink:目标数据库中连接到源数据库的dblink。使用dbms_file_transfer传输数据文件时会使用这个dblink。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srclink=ttslink

dfcopydir:源系统中用来存储xttdriver.pl -p操作所生成的数据文件副本目录。这个目录要有足够的空间来存储所有被传输表空间的数据文件副本。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。 这个参数只有使用RMAN备份生成数据文件副本时才使用,例如dfcopydir=/stage_source

backupformat:源系统中存储增量备份文件的目录。这个目录必须要有足够的空间来存储所有创建的增量备份文件。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。例如,backupformat=/stage_source

stageondest:目标系统中存储从源系统中手动传输过来的数据文件副本。这个目录要有足够的空间来存储数据文件副本。这个目录同时也是用来存储从源系统传输过来的增量备份文件的目录。在目标系统上执行xttdriver.pl -c转换数据文件与执行xttdriver.pl -r前滚数据文件时会从这个目录中读取数据文件副本与增量备份文件。这个目标也可以是一个DBFS-mounted文件系统。个目录可以是源系统上通过NFS-mounted文件系统所挂载到目标系统中的一个目录,在这种情况下,源系统中的backupformat参数与dfcopydir参数就会引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。例如stageondest=/stage_dest

storageondest:目标系统中用来存储xttdriver.pl -c转换操作后所生成的数据文件副本的目录,也就是目标数据库最终存储数据文件的目录。这个目录要有足够的空间来永久存储数据文件。这个参数当使用RMAN备份来生成初始化数据文件副本时才使用,例如
storageondest=+DATA或者storageondest=/oradata/test

backupondest:目录系统中用来存储xttdriver.pl -r前滚操作所转换后的增量备份文件的目录。这个目录要有足够的空间来存储转换后的增量备份文件。注意,如果这个参数指向ASM磁盘目录,那么需要在xtt.properties参数文件中定义asm_home与asm_sid参数。如果这个参数指向文件系统目录,那么就从xtt.properties参数文件中删除asm_home与asm_sid参数。例如,backupondest=+RECO

cnvinst_home:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_HOME,例如cnvinst_home=/u01/app/oracle/product/11.2.0.4/xtt_home

cnvinst_sid:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_SID,例如cnvinst_xtt

asm_home:目标系统中ASM实例的ORACLE_HOME。注意如果backupondest设置为文件系统目录,那么就要删除asm_home与asm_sid参数,例如asm_home=/u01/app/11.2.0.4/grid

asm_sid:目标系统中ASM实例的ORACLE_SID。例如asm_sid=+ASM1

parallel:定义rmanconvert.cmd命令文件中rman convert命令的并行度。如果不设置这个参数,那么xttdriver.pl将使用parallel=8的缺省并行度。例如,parallel=3

rollparallel:定义xttdriver.pl -r前滚操作的并行度,例如rollparallel=2

getfileparallel:定义xttdriver.pl -G获取数据文件副本操作的并行度,缺省值是1,最大值为8,例如getfileparallel=4

11g 使用增量备份来执行跨平台传输表空间减少停机时间(xtts_rman)

使用跨平台传输表空间来迁移数据所需要的停机时间与被迁移的数据量成正比。然而,当使用增量备份跨平台迁移可以显著减小迁移数据所需要的停机时间。

传统跨平台传输表空间的主要步骤:
1.将源数据库中所被转输的表空间设置为read only
2.将所被传输表空间所相关的数据文件传输到目标主机上
3.将数据文件转换为目标主机所使用的字节序
4.使用data pump从源数据库导出所被传输表空间所存储对象的元数据
5.在目标数据库中使用data pump导入所被传输表空间所存储对象的元数据
6.使用目标数据库中的被传输表空间设置为read write

因为数据传输时表空间必须为read only,应用程序所拥有的数据在传输时不能被用户使用。因为操作是串行操作,所以停机时间依赖于数据量的大小。如果数据量大,数据文件传输与转换的时间将会很长,所以停机时间也就会很长。

使用跨平台增量备份来减少停机时间
为了减少停机时间需要使用XTTS,Oracle为跨平台传输增强了RMAN的能力来使用增量备份前滚数据文件副本。通过使用一些列的增量备份,每一份增量备份都比上一次的小,在需要停机之前,目标系统中的数据几乎可以从源系统中获得。数据文件传输与转换所需要的停机时间就由源系统中在最后一次增量备份之后被改变的数据量所决定。

跨平台增量备份不会影响XTTS所执行其它操作所花费的时间,比如元数据的导出与导入。因此,当数据库有大量的元数据时将会看到使用跨平台增量备份执行迁移的好处会受到影响,因为迁移所需时间通常是由元数据操作所决定的,而不是由数据文件传输与转换操作所决定的。

只有物理存储被迁移数据库对象的表空间需要被传输到目标系统。如果需要被迁移的其它对象,存储在不同表空间(比如,pl/sql对象,序列,等等,存储在system表空间中),可以使用data pump来复制这些对象到目标系统。

使用跨平台增量备份传输表空间的主要步骤如下:
1.准备阶段(源数据保持为online状态)
.传输被迁移表空间所相关的数据文件到目标系统
.如果需要,将数据文件转换成目标系统所使用的字节序

2.前滚阶段(源数据保持为online状态-可以根据需要重复达个阶段多次来使用目标数据文件匹配上源数据库文件)
.在源系统中创建增量备份
.传输增量备份到目标系统
.将增量备份转换为目标系统所使用的字节序并将备份应用到目标数据文件副本

注意,对于版本号为3的脚本,如果一个数据文件被增加到表空间或者一个新的表空间名被增加到xtt.properties文件中,一个告警信息与额外的指令需要被执行。

3.传输阶段(源数据为read only)
.将源数据库中需要被传输的表空间设置为read only
.最后一次执行前滚阶段的操作,这步操作可以确保目标数据文件副本与源数据库中的数据文件处于一致状态。这步操作所花费的时间要比传统XTTS方法所需要的时间短,因为使用增量备份。
.使用data pump从源数据库中志出相关表空间中所存储对象的元数据
.在目标系统中使用data pump导出表空间所存储对象的元数据
.将目标数据库中的相关表空间设置为read write

这篇文章提供了一个例子来介绍如何使用跨平台增量备份来减少传输表空间的停机时间。

源系统可以是先决条件所引用的和平台与数据库所满足的列表中所列出任何平台。如果从一种小字节序平台迁移到Oracle Linux,那么最应该考虑的方法是使用Data Guard,可以参考Note 413484.1关于在当前小字节序平台与Oracle Linux之间Data Guard所支持的异构平台。对于Oracle 12c来说,请使用Note 2005729.1 12C – Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup.或者NOTE: Neither method supports 12c multitenant databases. Enhancement bug 22570430 addresses this limitation.

这里将介绍如何从Redhat Linux 平台上将表空间cdzj,ldjc使用跨平台增量备份的传输表空间方法来迁移到Aix平台。在执行完初始化阶段后执行以下三个阶段来执行数据的迁移操作:
准备阶段
在准备阶段,要传输的表空间的数据文件会被传输到目标系统并被转换为目标系统所使用的字节序。在准备阶段应用程序是完全可以访问源数据的。准备阶段使用RMAN备份或dbms_file_transfer,后面将会详细介绍如何选择准备阶段所要使用的方法。

前滚阶段
在前滚阶段,在准备阶段被转换后的数据文件将会使用来自源数据库的增量备份来进行前滚操作。通过多次执行该阶段的操作,每次成功的增量备份将会更小与更快的应用到数据文件副本,允许目标系统中的数据都是来自源系统中。在执行前滚阶段时应用程序可以完全访问源数据。

传输阶段
在传输阶段,在源数据库中将要被传输的表空间设置为read only状态,并且在源平台上执行最后一次增量备份并且将它传输到目标平台上并应用到数据文件副本,使用目标系统中的数据文件副本与源数据库中的数据文件保护一致。一旦数据文件状态一致,从源数据库中导出所传输表空间所存储对象的元数据,并且在目标平台导入这些元数据。最后在目标数据库中将传输过来的表空间设置为read write状态。在传输阶段应用程序是不能更新源数据的。

跨平台增量备份所支持的脚本
跨平台增量备份的核心功能是基于Oracle 11.2.0.4与之后的版本。请查看条件与建议部分了解详细信息。另外有一组支持脚本存储在rman-xttconvert_2.0.zip。其中有两个主要支持的脚本:
.Perl脚本xttdriver.pl 这个脚本用来执行跨平台增量备份传输表空间的主要步骤。
.参数文件xtt.properties 这个文件包含自已平台特定配置

执行跨平台增量备份传输表空间的条件与建议
执行跨平台增量备份传输表空间的条件
在执行跨平台增量备份传输表空间之前需要检查是否满足以下条件:
.传输表空间的限制
.其它必须满足的条件
当前版本不支持windows
源数据库的compatible参数必须设置为10.2.0或更高版本
源数据库的compatible参数必须不能比目标数据库的compatible参数的值大
源数据库必须启用了archivelog模式
尽管首选目标系统是Linux操作系统(可以是64位的Oracle Linux或者是已经认证的Redhat Linux),但这个过程也可以在其它Unix操作系统中执行。然而,对于任何non-Linux操作系统来说数据库的版本必须是11.2.0.4
源数据库的版本必须小于或等于目标数据库的版本
RMAN的缺省设备类型应该被配置为DISK
源数据库的RMAN不能对DEVICE TYPE DISK使用COMPRESSED配置。如果使用COMPRESSED配置,执行操作时可能会返回:ORA-19994: cross-platform backup of compressed backups different endianess.
源数据库中将要被迁移的表空间必须是online,并且不能包含脱机数据文件。表空间必须为read write状态。表空间为read only那么可以使用正常的XTTS方法进行迁移。

.所有步骤中执行操作的用户必须是Oracle用户并且它是OSDBA组的成员。操作系统审计被用来连接源数据库与目标数据库。
.如果准备阶段方法选择dbms_file_transfer,那么目标数据库版本必须至少为11.2.0.4。
.如果准备阶段方法选择RMAN,那么在源系统与目标系统中都要创建预备区域
.对于备库或快照备库是不支持这种操作的
.如果目标数据库版本是11.2.0.3或更低的版本,那么在目标系统中需要有一个11.2.0.4的数据库home目录来运行11.2.0.4的实例来执行增量备份的转换操作。如果目标数据库版本是11.2.0.3或更低版本,那么需要一个版本为11.2.0.4的单独的增量转换Home目录与实例。如果ASM使用11.2.0.4的转换Home,那么ASM的版本也必须是11.2.0.4,否则会触发ORA-15295(ORA-15295: ASM instance software version 11.2.0.3.0 less than client version 11.2.0.4.0)。

整个数据库迁移
如果跨平台增量备份传输表空间被用来减少整个数据库的迁移时间,那么请参考MAA提供的XTTS指南Platform Migration UsingTransportable Tablespaces(maa-wp-11g-platformmigrationtts-129269.pdf),这种迁移方法也可以用于Oracle 12c,然而对于12c有一种替代的方法可参考Note 2005729.1 12C – Reduce Transportable Tablespace Downtime using Cross Platform Incremental Backup.

选择准备阶段方法
在准备阶段,要被传输的表空间的数据文件会被传输到目标系统并且通过执行xttdriver.pl脚本进行转换。这里有两种可用的方法:
1.使用dbms_file_transfer(DFT)传输(使用xttdriver.pl -S与-G选项)
2.使用RMAN备份(使用xttdriver.pl -p与-c选项)

dbms_file_transfer方法使用dbms_file_transfer.get_file()过程来通过dblink从源系统中将数据文件传输到目标系统。dbms_file_transfer方法相比RMAN方法有以下优点:
1.不需要在源系统或目标系统中创建预备目录
2.在传输数据文件时会自动执行数据文件的转换–这里不需要再执行转换操作。

dbms_file_transfer方法要满足以下条件才能使用:
.目标数据库必须是11.2.0.4的版本。注意增量转换Home目录或实例不参与dbms_file_transfer的文件传输操作。
.在源数据库中有一个数据库目录对象它指向要被复制的数据文件
.原目标数据库中有一个数据库目录对象它指向要被存放的数据文件
.在目标数据库中有一个dblink连接到源数据库

RMAN备份方法在源系统中执行RMAN来对要被传输的数据文件生成备份。生成的备份文件必须手动跨网络传输到目标系统。在目标系统中通过执行RMAN对数据文件进行转换,如果需要,RMAN转换操作会将输出的数据文件存放在目标数据库最终存储数据文件的目录中。在原版本的xttdriver.pl中,只支持这种方法。RMAN备份方法要满足以下条件:
.在源系统与目标系统中需要为RMAN所创建的数据文件副本创建预备目录。预备目录在xtt.properties文件中分别指向参数dfcopydir与stageondest。被转换后的数据文件最终存放目录在xtt.properties文件中指向参数storageondest。

关于这些方法被提供的指令的详细信息后面会介绍,建议使用dbms_file_transfer方法。

目标数据库版本为11.2.0.3或更低版本需要安装一个单独的增量转换home与实例跨平台增量备份的核心功能(例如,增量备份转换)是基于Oracle 11.2.0.4及以后版本的。如果目标数据库版本为11.2.0.4及以后版本,那么目标数据库可以执行这种功能。然而,如果目标数据库版本为11.2.0.3或更低版本,那么为了执行增量备份转换,需要安装一个单独的11.2.0.4的软件home目录,叫作增量转换home目录,并创建一个增量转换实例,并且该实例必须启动到时nomount状态。增量转换home目录与增量转换实例是临时使用,并且只在迁移操作期间使用。

因为dbms_file_transfer准备阶段方法要求目标数据库的版本为11.2.0.4,它可以被用来执行增量备份转换功能(如上所述),增量转换home目录与增量转换实例通常只有当使用RMAN备份方法来才会使用。对于如何设置一个临时增量转换实例参考阶段1。

诊断
为了启用诊断模式,可以使用-d参数来执行xttdriver.pl脚本,或者在执行xttdriver.pl脚本之前设置环境变量XTTDEBUG=1。Debug模式会启用额外的屏幕输出并且造成所有RMAN操作使用debug命令行选项。

已知问题
1.如果源数据库包含使用键压缩的嵌套的IOTs表,那么在目标数据库home中必须安装修复Bug 14835322的补丁
2.如果想在创建增量备份时对源数据库使用块改变跟踪功能,那么需要在源数据库home中安装修复Bug 16850197的补丁
3.如果前滚阶段(xttdriver.pl -r)失败并显示以下错误信息,那么验证RMAN的DEVICE TYPE DISK不能使用COMPRESSED配置

Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: RestoreSetPiece
DECLARE
*
ERROR at line 1:
ORA-19624: operation failed, retry possible
ORA-19870: error while restoring backup piece
/dbfs_direct/FS1/xtts/incrementals/xtts_incr_backup
ORA-19608: /dbfs_direct/FS1/xtts/incrementals/xtts_incr_backup is not a backup
piece
ORA-19837: invalid blocksize 0 in backup piece header
ORA-06512: at "SYS.X$DBMS_BACKUP_RESTORE", line 2338
ORA-06512: at line 40

使用跨平台增量备份传输表空间来减少停机时间
跨平台增量备份传输表空间主要有以下四个阶段:
1.初始化设置阶段
2.准备阶段
3.前滚阶段
4.传输阶段

源系统为Redhat Linux,Oracle为11.2.0.4,目标系统为AIX,Oracle为11.2.0.4

1.初始化设置阶段
为了使用跨平台增量备份传输表空间执行以下操作来完成操作环境的配置:
1.1 安装目标数据库软件并创建目标数据库
在目标系统上安装所需要的数据库软件版本来运行目标数据库。强烈建议使用Oracle 11.2.0.4或之后的版本。注意dbms_file_transfer方法要求目标数据库为11.2.0.4。在目标系统中识别或创建一个数据库并创建需要传输的表空间及用户方案。我这里目标数据库为11.2.0.4,要被传输的用户方案为cdzj,ldjc,表空间为cdzj,ldjc。

1.2 如果需要,配置增量转换home与实例
如果目标数据库是11.2.0.3或之前版本,需要安装一个单独的增量转换home与实例。如果目标数据库是11.2.0.4或之后的版本,可以跳过这一步。注意dbms_file_transfer方法要求目标数据库的版本为11.2.0.4。如果目标数据库是11.2.0.3或之前版本,那么必须通过执行以下操作来配置一个单独的增量转换实例:
.在目标系统中安装一个新的11.2.0.4的数据库home。这就是增量转换home
.使用增量转换home启动一个实例到nomount状态,这个实例就是增量转换实例。对于增量转换实例不需要创建相应的数据库,只需要运行一个增量转换实例。

下面操作可以用来创建一个名叫xtt的增量转换实例,增量转换home为/oracle11/app/oracle/product/11.2.0/db:

IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$export ORACLE_HOME=/oracle11/app/oracle/product/11.2.0/db
IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$export ORACLE_SID=xtt
IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$cat < < EOF > $ORACLE_HOME/dbs/init$ORACLE_SID.ora
> db_name=xtt
> compatible=11.2.0.4.0
> EOF

IBMP740-2:/oracle11/app/oracle/product/11.2.0/db/dbs$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 16 10:47:59 2017

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

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  797712384 bytes
Fixed Size                  2250200 bytes
Variable Size             490736168 bytes
Database Buffers          268435456 bytes
Redo Buffers               36290560 bytes

如果ASM被用于存储xtt.properties文件中的参数backupondest,那么实例的compatible参数的值必须等于或大于ASM磁盘组所使用的rdbms.compatible的值。

1.3 识别要被传输的表空间
识别源数据库中将要被传输的表空间。我这里要被传输的表空间为cdzj,ldjc。

1.4 如果使用dbms_file_transfer方法,那么配置目录对象与dblink
注意dbms_file_transfer方法要求目标数据库的版本为11.2.0.4,如果使用dbms_file_transfer访求,那么必须创建以下三个数据库对象:
.在源数据库中创建一个数据库目录对象,它指向要被复制的数据文件所存放的目录
.在目标数据库中创建一个数据库目录对象,它指向将要存放数据文件的目录
.在目标数据库中创建一个dblink连接到源数据库

源数据库目录对象引用源数据库中当前存放数据文件的目录。例如,下面创建目录对象指向,数据文件存放目录/home/app/oracle/product/11.2.0/dbs/,连接到源数据库房执行以下命令:

[oracle@sjjh ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Tue Aug 15 17:10:58 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select a.NAME,b.NAME from v$tablespace a,v$datafile b where a.TS#=b.TS# and a.NAME in('CDZJ','LDJC');
NAME                           NAME
------------------------------ --------------------------------------------------------------------------------
LDJC                           /home/app/oracle/product/11.2.0/dbs/ldjc01
CDZJ                           /home/app/oracle/product/11.2.0/dbs/cdzj01

SQL> create directory sourcedir as '/home/app/oracle/product/11.2.0/dbs';

Directory created.

目标数据库目录对象引用目标数据库中将要存储数据文件的目录。这个目录是最终目标数据库将要存放数据文件的目录/oracle11/oradata/jycs/jycs/,连接到目标数据库执行以下命令

IBMP740-2:/oracle11$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.4.0 Production on Wed Aug 16 11:23:03 2017

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


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------
/oracle11/oradata/jycs/jycs/system01.dbf
/oracle11/oradata/jycs/jycs/sysaux01.dbf
/oracle11/oradata/jycs/jycs/undotbs01.dbf
/oracle11/oradata/jycs/jycs/users01.dbf
/oracle11/oradata/jycs/jycs/example01.dbf

SQL> create directory destdir as '/oracle11/oradata/jycs/jycs';

Directory created.

在目标数据库中创建一个dblink连接到源数据库。例如创建一个名叫ttslink的dblink,执行以下命令:

SQL> create public database link ttslink
  2    connect to system identified by "xxzx7817600"
  3    using '(DESCRIPTION =
  4      (ADDRESS_LIST =
  5        (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.130.101)(PORT = 1521))
  6      )
  7      (CONNECT_DATA =
  8        (SERVER = DEDICATED)
  9        (SERVICE_NAME =sjjh)
 10      )
 11    )';

Database link created.

创建dblink后验证是否可以能过dblink访问源数据库

SQL> select * from dual@ttslink;

D
-
X

1.5 创建预备目录
在源系统与目标系统中创建预备目录,它们将被设置为xtt.properties文件中的backupformat(源系统中存放增量备份文件的目录),backupondest(目标系统中存放转换后的增量备份文件的目录)参数的值。如果使用RMAN备份方法,在源系统与目标系统中还需要为xtt.properties文件中的dfcopydir(源系统中存放数据文件副本的目录,只有使用rman备份才使用),stageondest(目标系统中存放从源系统传输过来的数据文件副本与增量备份的目录,只有使用rman备份才使用)。

在源系统中执行下面的命令分别创建backupformat目录(/home/backup),dfcopydir目录(/home/dfcopydir)

[oracle@sjjh home]$ mkdir backup
[oracle@sjjh home]$ mkdir dfcopydir

在目标系统中执行下面的命令分别创建backupondest目录(/oracle11/backup),stagenodest目录(/oracle11/xtts)

IBMP740-2:/oracle11$mkdir backup
IBMP740-2:/oracle11$mkdir xtts

1.6在源系统中安装xttconver脚本
在源系统中,使用Oracle软件用户,下裁与解压脚本

[oracle@sjjh xtts_script]$ unzip rman_xttconvert_v3.zip
Archive:  rman_xttconvert_v3.zip
  inflating: xtt.properties
  inflating: xttcnvrtbkupdest.sql
  inflating: xttdbopen.sql
  inflating: xttdriver.pl
  inflating: xttprep.tmpl
 extracting: xttstartupnomount.sql
[oracle@sjjh xtts_script]$ ls -lrt
total 208
-rw-r--r-- 1 oracle oinstall   1390 May 24 16:57 xttcnvrtbkupdest.sql
-rw-r--r-- 1 oracle oinstall     52 May 24 16:57 xttstartupnomount.sql
-rw-r--r-- 1 oracle oinstall  11710 May 24 16:57 xttprep.tmpl
-rw-r--r-- 1 oracle oinstall 139331 May 24 16:57 xttdriver.pl
-rw-r--r-- 1 oracle oinstall     71 May 24 16:57 xttdbopen.sql
-rw-r--r-- 1 oracle oinstall   7969 Jun  5 08:47 xtt.properties
-rw-r--r-- 1 oracle oinstall  33949 Aug 14 17:25 rman_xttconvert_v3.zip

1.7 在源系统中配置xtt.properties文件

[oracle@sjjh xtts_script]$ vi .xtt.properties
tablespaces=CDZJ,LDJC                                  --源数据库中要被传输的表空间名
platformid=13                                          --源数据库的platform_id
dfcopydir=/home/dfcopydir                              --源系统中存放数据文件副本的目录
backupformat=/home/backup                              --源系统中存储增量备份的目录
stageondest=/oracle11/xtts                             --目标系统中存储数据文件副本与增量备份的目录
backupondest=/oracle11/backup                          --目标系统中存储转换后的增量备份目录,只在使用RMAN备份方法才使用
storageondest=/oracle11/oradata/jycs/jycs              --目标系统中最终存储转换后数据文件的目录
cnvinst_home=/oracle11/app/oracle/product/11.2.0/db    --转换Home目录
cnvinst_sid=xtt                                        --转换实例SID

1.8 将源系统中的转换脚本与xtt.properties文件复制到目标系统中

IBMP740-2:/oracle11/xtts_script$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 501      501          1390 May 24 08:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 501      501         11710 May 24 08:57 xttprep.tmpl
-rw-r--r--    1 501      501            52 May 24 08:57 xttstartupnomount.sql
-rw-r--r--    1 501      501            71 May 24 08:57 xttdbopen.sql
-rw-r--r--    1 501      501        139331 May 24 08:57 xttdriver.pl
-rw-r--r--    1 501      501          7969 Jun 05 00:47 xtt.properties.bak
-rw-r--r--    1 501      501         33949 Aug 14 09:25 rman_xttconvert_v3.zip
-rw-r--r--    1 501      501           255 Aug 16 06:58 xtt.properties
226 Directory send OK.

ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> get xttcnvrtbkupdest.sql
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttcnvrtbkupdest.sql (1390 bytes).
226 Transfer complete.
1390 bytes received in 7.6e-05 seconds (1.786e+04 Kbytes/s)
local: xttcnvrtbkupdest.sql remote: xttcnvrtbkupdest.sql
ftp> get xttprep.tmpl
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttprep.tmpl (11710 bytes).
226 Transfer complete.
11710 bytes received in 0.000196 seconds (5.834e+04 Kbytes/s)
local: xttprep.tmpl remote: xttprep.tmpl
ftp> get xttstartupnomount.sql
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttstartupnomount.sql (52 bytes).
226 Transfer complete.
52 bytes received in 0.000103 seconds (493 Kbytes/s)
local: xttstartupnomount.sql remote: xttstartupnomount.sql
ftp> get xttdbopen.sql
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttdbopen.sql (71 bytes).
226 Transfer complete.
71 bytes received in 0.000106 seconds (654.1 Kbytes/s)
local: xttdbopen.sql remote: xttdbopen.sql
ftp> get xttdriver.pl
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttdriver.pl (139331 bytes).
226 Transfer complete.
139331 bytes received in 0.001805 seconds (7.538e+04 Kbytes/s)
local: xttdriver.pl remote: xttdriver.pl
ftp> get xtt.properties
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xtt.properties (255 bytes).
226 Transfer complete.
255 bytes received in 0.00012 seconds (2075 Kbytes/s)
local: xtt.properties remote: xtt.properties

IBMP740-2:/oracle11/xtts_script$ls -lrt
total 336
-rw-r--r--    1 oracle11 oinstall       1390 Aug 16 15:44 xttcnvrtbkupdest.sql
-rw-r--r--    1 oracle11 oinstall      11710 Aug 16 15:45 xttprep.tmpl
-rw-r--r--    1 oracle11 oinstall         52 Aug 16 15:45 xttstartupnomount.sql
-rw-r--r--    1 oracle11 oinstall         71 Aug 16 15:45 xttdbopen.sql
-rw-r--r--    1 oracle11 oinstall     139331 Aug 16 15:45 xttdriver.pl
-rw-r--r--    1 oracle11 oinstall        255 Aug 16 15:46 xtt.properties

1.9 在源系统与目标系统中设置环境变TMPDIR,它指向转换脚本所在的目录。为了执行Perl脚本xttdriver.pl设置如下。如果TMPDIR没有设置,那么脚本生成的输出文件将会存放在/tmp目录中

[oracle@sjjh ~]$ export TMPDIR=/home/xtts_script

IBMP740-2:/oracle11$export TMPDIR=/oracle11/xtts_script

2.准备阶段
在准备阶段,被传输表空间的数据文件会被传输到目标系统并且通过执行xttdriver.pl脚本进行转换。有以下两种方法可以使用:
1. dbms_file_transfer方法
2. RMAN备份方法

对于大量数据文件使用dbms_file_transfer方法要比传输数据文件到目标系统更快。

2a.使用dbms_file_transfer方法
2a.1在源系统中执行准备操作
在源系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令:

[oracle@source]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -S

准备操作将在源系统中执行以下操作
.验证表空间是否online,read write且不包含脱机数据文件
.将创建后面所要使用的以下文件:
xttnewdatafiles.txt
getfile.sql

要被传输的一组表空间必须是online,read write状态且不包含脱机数据文件。如果在源数据库中被传输表空间的一个或多个数据文件是脱机状态或read only就会触发错误。如果表空间在整个表空间传输过程中都保持read only状态,那么就使用传统的跨平台传输表空间,不要使用跨平台增量备份传输表空间。

2a.2 传输数据文件到目标系统中
在目标系统中,使用Oracle软件用户登录并设置相关环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并复制上一步生成的xttnewdatafiles.txt与getfile.sql文件到目标系统并执行操作来获取数据文件

[oracle@dest]$ scp oracle@source:/home/oracle/xtt/xttnewdatafiles.txt /home/oracle/xtt
[oracle@dest]$ scp oracle@source:/home/oracle/xtt/getfile.sql /home/oracle/xtt

# MUST set environment to destination database
[oracle@dest]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -G

当这步操作完成后,要被传输的数据文件会存放在目标系统最终存放数据文件的目录中。转换操作会自动执行。

2b.使用RMAN备份方法
在这个阶段表空间的数据文件副本将被传输到目标系统中,并执行转换操作,且将转换后的数据文件存放在目标数据库最终存放数据文件的目录中。这个阶段的操作只会执行一次。在执行这个阶段的操作时被传输的数据在源数据库中完全可以被访问。

2b.1在源系统中执行准备操作
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令

[oracle@sjjh ~]$ cd /home/xtts_script
[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -p
============================================================
trace file is /home/xtts_script/prepare_Aug16_Wed_15_50_19_497//Aug16_Wed_15_50_19_497_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Starting prepare phase
--------------------------------------------------------------------

Prepare source for Tablespaces:
                  'CDZJ'  /oracle11/xtts
xttpreparesrc.sql for 'CDZJ' started at Wed Aug 16 15:50:19 2017
xttpreparesrc.sql for  ended at Wed Aug 16 15:50:19 2017
Prepare source for Tablespaces:
                  'LDJC'  /oracle11/xtts
xttpreparesrc.sql for 'LDJC' started at Wed Aug 16 15:51:08 2017
xttpreparesrc.sql for  ended at Wed Aug 16 15:51:08 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Wed Aug 16 15:52:05 2017
xttpreparesrc.sql for  ended at Wed Aug 16 15:52:05 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Wed Aug 16 15:52:06 2017
xttpreparesrc.sql for  ended at Wed Aug 16 15:52:06 2017
Prepare source for Tablespaces:
                  ''''  /oracle11/xtts
xttpreparesrc.sql for '''' started at Wed Aug 16 15:52:07 2017
xttpreparesrc.sql for  ended at Wed Aug 16 15:52:07 2017

--------------------------------------------------------------------
Done with prepare phase
--------------------------------------------------------------------


--------------------------------------------------------------------
Find list of datafiles in system
--------------------------------------------------------------------


--------------------------------------------------------------------
Done finding list of datafiles in system
--------------------------------------------------------------------

这个准备操作在源系统中执行以下操作:
.创建要被传输表空间的数据文件副本并且将它们存储在xtt.properties文件中dfcopydir所指定的目录中

[root@sjjh dfcopydir]# ls -lrt
total 7340056
-rw-r----- 1 oracle oinstall 2147491840 Aug 16 15:50 CDZJ_7.tf
-rw-r----- 1 oracle oinstall 5368717312 Aug 16 15:52 LDJC_6.tf

.验证表空间是否为online,read write状态,并且不包含脱机数据文件
.创建后面所需要用到的以下文件

 xttplan.txt
 rmanconvert.cmd

xttplan.txt文件的内容如下:

[root@sjjh xtts_script]# cat xttplan.txt
CDZJ::::14690156586805
7
LDJC::::14690156586805
6

该文件中的数值,数据库的SCN。如果后面再次运行脚本进行增量操作时,该值会发现改变。

rmanconvert.cmd的内容如下:

[root@sjjh xtts_script]# cat rmanconvert.cmd
host 'echo ts::CDZJ';
  convert from platform 'Linux x86 64-bit'
  datafile
   '/oracle11/xtts/CDZJ_7.tf'
  format '/oracle11/oradata/jycs/jycs/%N_%f.dbf'
 parallelism 8;
host 'echo ts::LDJC';
  convert from platform 'Linux x86 64-bit'
  datafile
   '/oracle11/xtts/LDJC_6.tf'
  format '/oracle11/oradata/jycs/jycs/%N_%f.dbf'
 parallelism 8;

上述脚本是perl脚本产生的rman convert脚本,需要将该脚本传递到目标端主机。注意,上述脚本文件格式需要注意,同时并行度是默认的,可以进行调整。

要被传输的一组表空间必须是online,read write状态且不包含脱机数据文件。如果在源数据库中被传输表空间的一个或多个数据文件是脱机状态或read only就会触发错误。如果表空间在整个表空间传输过程中都保持read only状态,那么就使用传统的跨平台传输表空间,不要使用跨平台增量备份传输表空间。

2b.2 将数据文件副本传输到目标系统中
在目标系统中以Oracle软件用户登录,从源系统中将上一步生成的数据文件副本传输到目标系统中。源系统中数据文件副本存储在xtt.properties文件中dfcopydir参数所指定的目录(home/dfcopydir)中。在目标系统中数据文件副本必须存放xtt.properties文件中stageondest目录(/oracle11/xtts)中。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> cd /home/dfcopydir
250 Directory successfully changed.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r-----    1 501      501      2147491840 Aug 16 07:50 CDZJ_7.tf
-rw-r-----    1 501      501      5368717312 Aug 16 07:52 LDJC_6.tf
226 Directory send OK.
ftp> lcd /oracle11/xtts
Local directory now /oracle11/xtts
ftp> bin
200 Switching to Binary mode.
ftp> get LDJC_6.tf
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for LDJC_6.tf (5368717312 bytes).
226 Transfer complete.
5368717312 bytes received in 45.68 seconds (1.148e+05 Kbytes/s)
local: LDJC_6.tf remote: LDJC_6.tf
ftp> get CDZJ_7.tf
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for CDZJ_7.tf (2147491840 bytes).
226 Transfer complete.
2147491840 bytes received in 18.52 seconds (1.132e+05 Kbytes/s)
local: CDZJ_7.tf remote: CDZJ_7.tf


IBMP740-2:/oracle11/xtts$ls -lrt
total 14680112
-rw-r--r--    1 oracle11 oinstall 5368717312 Aug 16 16:53 LDJC_6.tf
-rw-r--r--    1 oracle11 oinstall 2147491840 Aug 16 16:54 CDZJ_7.tf

2b.3 在目标系统中转换数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,将步骤2b.1中生成的脚本文件复制到目标系统中,然后执行以下命令来转换数据文件:

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 501      501          1390 May 24 08:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 501      501         11710 May 24 08:57 xttprep.tmpl
-rw-r--r--    1 501      501            52 May 24 08:57 xttstartupnomount.sql
-rw-r--r--    1 501      501            71 May 24 08:57 xttdbopen.sql
-rw-r--r--    1 501      501        139331 May 24 08:57 xttdriver.pl
-rw-r--r--    1 501      501          7969 Jun 05 00:47 xtt.properties.bak
-rw-r--r--    1 501      501         33949 Aug 14 09:25 rman_xttconvert_v3.zip
-rw-r--r--    1 501      501           255 Aug 16 06:58 xtt.properties
-rw-r--r--    1 501      501            50 Aug 16 07:51 xttplan.txt
-rw-r--r--    1 501      501           354 Aug 16 07:51 rmanconvert.cmd
-rw-r--r--    1 501      501            96 Aug 16 07:52 xttnewdatafiles.txt
drwxr-xr-x    2 501      501          4096 Aug 16 07:52 prepare_Aug16_Wed_15_50_19_497
226 Directory send OK.
ftp> get xttplan.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttplan.txt (50 bytes).
226 Transfer complete.
50 bytes received in 5e-05 seconds (976.6 Kbytes/s)
local: xttplan.txt remote: xttplan.txt
ftp> get rmanconvert.cmd
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for rmanconvert.cmd (354 bytes).
226 Transfer complete.
354 bytes received in 5.9e-05 seconds (5859 Kbytes/s)
local: rmanconvert.cmd remote: rmanconvert.cmd
ftp> get xttnewdatafiles.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttnewdatafiles.txt (96 bytes).
226 Transfer complete.
96 bytes received in 5.5e-05 seconds (1705 Kbytes/s)
local: xttnewdatafiles.txt remote: xttnewdatafiles.txt


IBMP740-2:/oracle11$export TMPDIR=/oracle11/xtts_script
IBMP740-2:/oracle11$cd /oracle11/xtts_script
IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -c
============================================================
trace file is /oracle11/xtts_script/convert_Aug16_Wed_17_02_24_689//Aug16_Wed_17_02_24_689_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Performing convert
--------------------------------------------------------------------

IBMP740-2:/oracle11/oradata/jycs/jycs$ls -lrt

-rw-r-----    1 oracle11 oinstall 2147491840 Aug 16 17:02 CDZJ_7.dbf
-rw-r-----    1 oracle11 oinstall 5368717312 Aug 16 17:03 LDJC_6.dbf

转换操作会将存储在目标系统xtt.properties文件中stageondest参数所指定目录(/oracle11/xtts)中的数据文件副本的字节序转换为目标系统所使用的字节序。转后的数据文件副本会被存储在xtt.properties文件中storageondest参数所指定目录
(/oracle11/oradata/jycs/jycs)目录中。这个目录是目标数据库最终存储数据文件的目录。当这个步骤完成后,在目标系统中xtt.properties文件中stageondest参数所指定目录(/oracle11/xtts)中的数据文件副本不再需要可以删除。

3.前滚阶段
下面在源数据库中创建增量数据

SQL> create table ldjc.jy_test(user_id number(20));
Table created

SQL> insert into ldjc.jy_test values(1);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    1

SQL> create table cdzj.jy_test(user_id number(20));
Table created

SQL> insert into cdzj.jy_test values(1);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    1

在这个阶段,会在源系统中对源数据库创建增量备份,然后将生成的增量备份传输到目标系统中,并将增量备份转换为目标系统所使用的字节序,然后将转换后的增量备份应用到转换后的数据文件进行前滚操作。这个阶段的操作可以执行多次,每一次成功的增量备份应该比之前的增量备份花费更少的时间,并且让目标系统中的数据文件的内容更加接近源数据库的内容。在这个阶段源数据库中被传输的数据完全可以被访问。

3.1 在源系统中对被传输的表空间LDJC,CDZJ创建增量备份
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /home/xtts_script/incremental_Aug16_Wed_16_39_56_791//Aug16_Wed_16_39_56_791_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

[root@sjjh xtts_script]# cat tsbkupmap.txt
CDZJ::7:::1=30sc2f2u_1_1
LDJC::6:::1=31sc2f31_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

[root@sjjh xtts_script]# cat incrbackups.txt
/home/backup/30sc2f2u_1_1
/home/backup/31sc2f31_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@sjjh backup]$ ls -lrt
total 888
-rw-r----- 1 oracle oinstall 122880 Aug 16 16:39 30sc2f2u_1_1
-rw-r----- 1 oracle oinstall 786432 Aug 16 16:40 31sc2f31_1_1

3.2 将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> cd /home/backup
250 Directory successfully changed.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r-----    1 501      501        122880 Aug 16 08:39 30sc2f2u_1_1
-rw-r-----    1 501      501        786432 Aug 16 08:40 31sc2f31_1_1
226 Directory send OK.
ftp> lcd /oracle11/xtts
Local directory now /oracle11/xtts
ftp> bin
200 Switching to Binary mode.
ftp> get 30sc2f2u_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 30sc2f2u_1_1 (122880 bytes).
226 Transfer complete.
122880 bytes received in 0.001414 seconds (8.487e+04 Kbytes/s)
local: 30sc2f2u_1_1 remote: 30sc2f2u_1_1
ftp> get 31sc2f31_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 31sc2f31_1_1 (786432 bytes).
226 Transfer complete.
786432 bytes received in 0.007007 seconds (1.096e+05 Kbytes/s)
local: 31sc2f31_1_1 remote: 31sc2f31_1_1


IBMP740-2:/oracle11/xtts$ls -lrt
total 1776
-rw-r--r--    1 oracle11 oinstall     122880 Aug 16 17:37 30sc2f2u_1_1
-rw-r--r--    1 oracle11 oinstall     786432 Aug 16 17:37 31sc2f31_1_1

3.3 在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> cd  /home/xtts_script
250 Directory successfully changed.
ftp> ls -lrt
200 PORT command successful. Consider using PASV.
150 Here comes the directory listing.
-rw-r--r--    1 501      501          1390 May 24 08:57 xttcnvrtbkupdest.sql
-rw-r--r--    1 501      501         11710 May 24 08:57 xttprep.tmpl
-rw-r--r--    1 501      501            52 May 24 08:57 xttstartupnomount.sql
-rw-r--r--    1 501      501            71 May 24 08:57 xttdbopen.sql
-rw-r--r--    1 501      501        139331 May 24 08:57 xttdriver.pl
-rw-r--r--    1 501      501          7969 Jun 05 00:47 xtt.properties.bak
-rw-r--r--    1 501      501         33949 Aug 14 09:25 rman_xttconvert_v3.zip
-rw-r--r--    1 501      501           255 Aug 16 06:58 xtt.properties
-rw-r--r--    1 501      501            50 Aug 16 07:51 xttplan.txt
-rw-r--r--    1 501      501           354 Aug 16 07:51 rmanconvert.cmd
-rw-r--r--    1 501      501            96 Aug 16 07:52 xttnewdatafiles.txt
drwxr-xr-x    2 501      501          4096 Aug 16 07:52 prepare_Aug16_Wed_15_50_19_497
-rw-r--r--    1 501      501            54 Aug 16 08:39 xttplan.txt.new
-rw-r--r--    1 501      501            50 Aug 16 08:40 tsbkupmap.txt
-rw-r--r--    1 501      501            52 Aug 16 08:40 incrbackups.txt
drwxr-xr-x    2 501      501          4096 Aug 16 08:40 incremental_Aug16_Wed_16_39_56_791
226 Directory send OK.
ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> get xttplan.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttplan.txt (50 bytes).
226 Transfer complete.
50 bytes received in 7.9e-05 seconds (618.1 Kbytes/s)
local: xttplan.txt remote: xttplan.txt
ftp> get tsbkupmap.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 0.00011 seconds (443.9 Kbytes/s)
local: tsbkupmap.txt remote: tsbkupmap.txt

IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
CDZJ::::14690156586805
7
LDJC::::14690156586805
6
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
CDZJ::7:::1=30sc2f2u_1_1
LDJC::6:::1=31sc2f31_1_1




IBMP740-2:/home/oracle11$export TMPDIR=/oracle11/xtts_script
IBMP740-2:/home/oracle11$cd /oracle11/xtts_script
IBMP740-2:/oracle11/xtts_script$export ORACLE_SID=jycs
IBMP740-2:/oracle11/xtts_script$export XTTDEBUG=1
IBMP740-2:/oracle11/xtts_script$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /oracle11/xtts_script/rollforward_Aug16_Wed_18_19_46_764//Aug16_Wed_18_19_46_764_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dfcopydir
Values: /home/dfcopydir
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : xtt
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /oracle11/app/oracle/product/11.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area  797712384 bytes
Fixed Size                  2250200 bytes
Variable Size             490736168 bytes
Database Buffers          268435456 bytes
Redo Buffers               36290560 bytes
rdfno 7

BEFORE ROLLPLAN

datafile number : 7

datafile name   : /oracle11/oradata/jycs/jycs/CDZJ_7.dbf

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_30sc2f2u_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
rdfno 6

BEFORE ROLLPLAN

datafile number : 6

datafile name   : /oracle11/oradata/jycs/jycs/LDJC_6.dbf

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_31sc2f31_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。

3.4 为下一次增量备份判断from_scn
再次生成增量数据

SQL> insert into ldjc.jy_test values(2);
1 row inserted

SQL> insert into cdzj.jy_test values(2);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    1
                    2

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    1
                    2

在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /home/xtts_script/determinescn_Aug16_Wed_17_52_34_308//Aug16_Wed_17_52_34_308_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
New /home/xtts_script/xttplan.txt with FROM SCN's generated

这步操作会计算下一个from_scn,并记录在xttplan.txt文件中,当下次创建增量备份时会使用这个scn

[root@sjjh xtts_script]# cat xttplan.txt
 CDZJ::::14690180717851
 7
 LDJC::::14690180727235
 6

3.5 再次重复前滚阶段或执行传输阶段
这里有两种选择:
1.如果如果将目标数据库中的数据文件与源数据库中的数据文件进行最接近的同步,那么就重复执行前滚操作。
2.如果目标数据库中的数据文件与源数据库中的数据文件已经达到所期望的接近,那么执行传输阶段的操作。

注意:如果从上一次增量备份后增加了一个新的表空间或者一个新的表空间名增加到xtt.properties文件中,那么将会出现以下错误:

Error:
------
The incremental backup was not taken as a datafile has been added to the tablespace:

Please Do the following:
--------------------------
1. Copy fixnewdf.txt from source to destination temp dir

2. Copy backups:

from  to the  in destination

3. On Destination, run $ORACLE_HOME/perl/bin/perl xttdriver.pl --fixnewdf

4. Re-execute the incremental backup in source:
$ORACLE_HOME/perl/bin/perl xttdriver.pl --bkpincr

NOTE: Before running incremental backup, delete FAILED in source temp dir or
run xttdriver.pl with -L option:

$ORACLE_HOME/perl/bin/perl xttdriver.pl -L --bkpincr

These instructions must be followed exactly as listed. The next incremental backup will include the new datafile.

我这里再次执行前滚操作
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /home/xtts_script/incremental_Aug16_Wed_18_04_22_221//Aug16_Wed_18_04_22_221_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt
tsbkupmap.txt的内容如下:

[root@sjjh xtts_script]# cat tsbkupmap.txt
LDJC::6:::1=33sc2k1b_1_1
CDZJ::7:::1=32sc2k18_1_1

文件中的内容记录了表空间与增量备份的关联关系
incrbackups.txt的内容如下:

[root@sjjh xtts_script]# cat incrbackups.txt
/home/backup/33sc2k1b_1_1
/home/backup/32sc2k18_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@sjjh backup]$ ls -lrt

-rw-r----- 1 oracle oinstall 122880 Aug 16 18:04 32sc2k18_1_1
-rw-r----- 1 oracle oinstall 729088 Aug 16 18:04 33sc2k1b_1_1

将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> cd /home/backup
250 Directory successfully changed.
ftp> lcd /oracle11/xtts
Local directory now /oracle11/xtts
ftp> bin
200 Switching to Binary mode.
ftp> get 32sc2k18_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 32sc2k18_1_1 (122880 bytes).
226 Transfer complete.
122880 bytes received in 0.001608 seconds (7.463e+04 Kbytes/s)
local: 32sc2k18_1_1 remote: 32sc2k18_1_1
ftp> get 33sc2k1b_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 33sc2k1b_1_1 (729088 bytes).
226 Transfer complete.
729088 bytes received in 0.006469 seconds (1.101e+05 Kbytes/s)
local: 33sc2k1b_1_1 remote: 33sc2k1b_1_1

IBMP740-2:/oracle11/xtts$ls -lrt

-rw-r--r--    1 oracle11 oinstall     122880 Aug 16 18:52 32sc2k18_1_1
-rw-r--r--    1 oracle11 oinstall     729088 Aug 16 18:52 33sc2k1b_1_1

在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.

ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> cd  /home/xtts_script
250 Directory successfully changed.
ftp> get xttplan.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttplan.txt (54 bytes).
226 Transfer complete.
54 bytes received in 9.4e-05 seconds (561 Kbytes/s)
local: xttplan.txt remote: xttplan.txt
ftp> get tsbkupmap.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 0.000107 seconds (456.3 Kbytes/s)
local: tsbkupmap.txt remote: tsbkupmap.txt


IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
 CDZJ::::14690180717851
 7
 LDJC::::14690180727235
 6
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
LDJC::6:::1=33sc2k1b_1_1
CDZJ::7:::1=32sc2k18_1_1


IBMP740-2:/oracle11/xtts_script$export TMPDIR=/oracle11/xtts_script
IBMP740-2:/oracle11/xtts_script$cd /oracle11/xtts_script
IBMP740-2:/oracle11/xtts_script$export ORACLE_SID=jycs
IBMP740-2:/oracle11/xtts_script$export XTTDEBUG=1
IBMP740-2:/oracle11/xtts_script$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /oracle11/xtts_script/rollforward_Aug16_Wed_19_02_23_450//Aug16_Wed_19_02_23_450_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dfcopydir
Values: /home/dfcopydir
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /oracle11/app/oracle/product/11.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2253216 bytes
Variable Size             922750560 bytes
Database Buffers         3305111552 bytes
Redo Buffers               45666304 bytes
rdfno 7

BEFORE ROLLPLAN

datafile number : 7

datafile name   : /oracle11/oradata/jycs/jycs/CDZJ_7.dbf

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_32sc2k18_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
rdfno 6

BEFORE ROLLPLAN

datafile number : 6

datafile name   : /oracle11/oradata/jycs/jycs/LDJC_6.dbf

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_33sc2k1b_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

这步前滚数据文件的操作,会以sys用户连接到增量转换实例,转换完增量备份后,然后连接到目标数据库并将增量备份应用到每个表空间注意:对于每一次增量备份都需要将xttplan.txt与tsbkupmap.txt文件复制一次,不要对脚本所生成的xttplan.txt.new文件进行修改,复制或者其它任何改变。执行这步操作时目标实例会进行重启操作。

为下一次增量备份判断from_scn
再次生成增量数据

SQL> insert into ldjc.jy_test values(3);
1 row inserted

SQL> insert into cdzj.jy_test values(3);
1 row inserted

SQL> commit;
Commit complete

SQL> select * from ldjc.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3

SQL> select * from cdzj.jy_test;
              USER_ID
---------------------
                    1
                    2
                    3

在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,执行以下命令来判断from_scn:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -s
============================================================
trace file is /home/xtts_script/determinescn_Aug16_Wed_18_25_13_253//Aug16_Wed_18_25_13_253_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
New /home/xtts_script/xttplan.txt with FROM SCN's generated

[root@sjjh xtts_script]# cat xttplan.txt
 CDZJ::::14690185295398
 7
 LDJC::::14690185295430
 6

4.传输阶段
在执行传输阶段操作时,源数据库中被传输表空间要设置为read only状态,并且通过创建与应用最后一次的增量备份使用目标数据库中的数据文件与源数据库中的数据文件内容保持一致。在目标数据库数据文件与源数据库数据文件内容达成一致后,在源系统中执行正常的传输表空间操作来导出元数据,然后将元数据导入到目标数据库中。直到传输阶段操作完成之前,被传输的数据只能以read only模式被访问。

4.1 将源数据库中被传输表空间设置为read only状态
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令将表空间设置为read only:

SQL> alter tablespace ldjc read only;

Tablespace altered.

SQL> alter tablespace cdzj read only;

Tablespace altered.

4.2 最后一次创建增量备份,并传输到目标系统且执行转换并应用到目标数据文件
在源系统中,以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向源数据库,并执行以下命令来创建增量备份:

[oracle@sjjh xtts_script]$ $ORACLE_HOME/perl/bin/perl xttdriver.pl -i
============================================================
trace file is /home/xtts_script/incremental_Aug16_Wed_18_33_49_991//Aug16_Wed_18_33_49_991_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Backup incremental
--------------------------------------------------------------------

============================================================
No new datafiles added
=============================================================
Prepare newscn for Tablespaces: 'CDZJ'
Prepare newscn for Tablespaces: 'LDJC'
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''
Prepare newscn for Tablespaces: ''''

--------------------------------------------------------------------
Starting incremental backup
--------------------------------------------------------------------


--------------------------------------------------------------------
Done backing up incrementals
--------------------------------------------------------------------

上面的操作会执行RMAN命令对xtt.properties文件中所指定的所有表空间生成增量备份文件。并且还将创建以下文件供后面的操作使用:
.tsbkupmap.txt
.incrbackups.txt

tsbkupmap.txt的内容如下:

[root@sjjh xtts_script]# cat tsbkupmap.txt
CDZJ::7:::1=34sc2lof_1_1
LDJC::6:::1=35sc2loi_1_1

文件中的内容记录了表空间与增量备份的关联关系

incrbackups.txt的内容如下:

[root@sjjh xtts_script]# cat incrbackups.txt
/home/backup/34sc2lof_1_1
/home/backup/35sc2loi_1_1

文件中的内容显示了生成的增量备份文件信息

[oracle@sjjh backup]$ ls -lrt

-rw-r----- 1 oracle oinstall  49152 Aug 16 18:33 34sc2lof_1_1
-rw-r----- 1 oracle oinstall 450560 Aug 16 18:33 35sc2loi_1_1

将增量备份传输到目标系统中
将上一步生成的增量备份传输到目标系统中由xtt.properties文件中的stageondest目录(/oracle11/xtts)中。

IBMP740-2:/oracle11/xtts$ftp 10.138.130.101
Connected to 10.138.130.101.
220 (vsFTPd 2.2.2)
Name (10.138.130.101:root): oracle
331 Please specify the password.
Password:
230 Login successful.
ftp> cd /home/backup
250 Directory successfully changed.
ftp> lcd /oracle11/xtts
Local directory now /oracle11/xtts
ftp> bin
200 Switching to Binary mode.
ftp> get 34sc2lof_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 34sc2lof_1_1 (49152 bytes).
226 Transfer complete.
49152 bytes received in 0.000707 seconds (6.789e+04 Kbytes/s)
local: 34sc2lof_1_1 remote: 34sc2lof_1_1
ftp> get 35sc2loi_1_1
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for 35sc2loi_1_1 (450560 bytes).
226 Transfer complete.
450560 bytes received in 0.004065 seconds (1.082e+05 Kbytes/s)
local: 35sc2loi_1_1 remote: 35sc2loi_1_1

IBMP740-2:/oracle11/xtts$ls -lrt

-rw-r--r--    1 oracle11 oinstall      49152 Aug 16 19:19 34sc2lof_1_1
-rw-r--r--    1 oracle11 oinstall     450560 Aug 16 19:20 35sc2loi_1_1

在目标系统中转换增量备份并应用到数据文件副本
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,并从源系统中将上一步生成的xttplan.txt与tsbkupmap.txt文件。

ftp> cd /home/xtts_script
250 Directory successfully changed.
ftp> lcd /oracle11/xtts_script
Local directory now /oracle11/xtts_script
ftp> bin
200 Switching to Binary mode.
ftp> get xttplan.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for xttplan.txt (54 bytes).
226 Transfer complete.
54 bytes received in 5.4e-05 seconds (976.6 Kbytes/s)
local: xttplan.txt remote: xttplan.txt
ftp> get tsbkupmap.txt
200 PORT command successful. Consider using PASV.
150 Opening BINARY mode data connection for tsbkupmap.txt (50 bytes).
226 Transfer complete.
50 bytes received in 5.1e-05 seconds (957.4 Kbytes/s)
local: tsbkupmap.txt remote: tsbkupmap.txt

IBMP740-2:/oracle11/xtts_script$cat xttplan.txt
 CDZJ::::14690185295398
 7
 LDJC::::14690185295430
 6
IBMP740-2:/oracle11/xtts_script$cat tsbkupmap.txt
CDZJ::7:::1=34sc2lof_1_1
LDJC::6:::1=35sc2loi_1_1

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -r
============================================================
trace file is /oracle11/xtts_script/rollforward_Aug16_Wed_19_24_53_790//Aug16_Wed_19_24_53_790_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dfcopydir
Values: /home/dfcopydir
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest
ARGUMENT backupondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Start rollforward
--------------------------------------------------------------------

convert instance: /oracle11/app/oracle/product/11.2.0/db

convert instance: xtt

ORACLE instance started.

Total System Global Area 4275781632 bytes
Fixed Size                  2253216 bytes
Variable Size             922750560 bytes
Database Buffers         3305111552 bytes
Redo Buffers               45666304 bytes
rdfno 7

BEFORE ROLLPLAN

datafile number : 7

datafile name   : /oracle11/oradata/jycs/jycs/CDZJ_7.dbf

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_34sc2lof_1_1_7

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.
rdfno 6

BEFORE ROLLPLAN

datafile number : 6

datafile name   : /oracle11/oradata/jycs/jycs/LDJC_6.dbf

AFTER ROLLPLAN

CONVERTED BACKUP PIECE/oracle11/backup/xib_35sc2loi_1_1_6

PL/SQL procedure successfully completed.
Entering RollForward
After applySetDataFile
Done: applyDataFileTo
Done: applyDataFileTo
Done: RestoreSetPiece
Done: RestoreBackupPiece

PL/SQL procedure successfully completed.

--------------------------------------------------------------------
End of rollforward phase
--------------------------------------------------------------------

4.3 在目标数据库中导入元数据
在目标系统中以Oracle软件用户登录并设置环境变量(ORACLE_HOME与ORACLE_SID)来指向目标数据库,执行以下命令来生成Data Pump TTS命令:

IBMP740-2:/oracle11/xtts_script$$ORACLE_HOME/perl/bin/perl xttdriver.pl -e
============================================================
trace file is /oracle11/xtts_script/generate_Aug16_Wed_19_27_43_910//Aug16_Wed_19_27_43_910_.log
=============================================================

--------------------------------------------------------------------
Parsing properties
--------------------------------------------------------------------

Key: backupondest
Values: /oracle11/backup
Key: platformid
Values: 13
Key: backupformat
Values: /home/backup
Key: storageondest
Values: /oracle11/oradata/jycs/jycs
Key: dfcopydir
Values: /home/dfcopydir
Key: cnvinst_home
Values: /oracle11/app/oracle/product/11.2.0/db
Key: cnvinst_sid
Values: xtt
Key: stageondest
Values: /oracle11/xtts
Key: tablespaces
Values: CDZJ,LDJC

--------------------------------------------------------------------
Done parsing properties
--------------------------------------------------------------------


--------------------------------------------------------------------
Checking properties
--------------------------------------------------------------------

ARGUMENT tablespaces
ARGUMENT platformid
ARGUMENT backupformat
ARGUMENT stageondest

--------------------------------------------------------------------
Done checking properties
--------------------------------------------------------------------

ORACLE_SID  : jycs
ORACLE_HOME : /oracle11/app/oracle/product/11.2.0/db

--------------------------------------------------------------------
Generating plugin
--------------------------------------------------------------------


--------------------------------------------------------------------
Done generating plugin file /oracle11/xtts_script/xttplugin.txt
--------------------------------------------------------------------

IBMP740-2:/oracle11/xtts_script$cat /oracle11/xtts_script/xttplugin.txt
impdp directory= logfile= \
network_link= transport_full_check=no \
transport_tablespaces=CDZJ,LDJC \
transport_datafiles='/oracle11/oradata/jycs/jycs/CDZJ_7.dbf','/oracle11/oradata/jycs/jycs/LDJC_6.dbf'

上面的命令会生成一个名叫xttplugin.txt的文件,文件创建了一个使用network_link参数执行传输表空间导入元数据的命令。命令中的transport_tablespaces与transport_datafiles参数已经设置正确。注意network_link模式指示导入通过使用dblink来完成,就不需要执行导出或使用dump文件。如果选择执行这个命令来完成表空间的传输就需要修改directory,logfile与network_link参数

SQL> create directory dump_dir as '/oracle11/xtts_script';

Directory created.
SQL> grant read,write on directory dump_dir to public;

Grant succeeded.

在目标数据库中创建一个dblink连接到源数据库。例如创建一个名叫ttslink的dblink,执行以下命令:

SQL> create public database link ttslink
  2    connect to system identified by "xxzx7817600"
  3    using '(DESCRIPTION =
  4      (ADDRESS_LIST =
  5        (ADDRESS = (PROTOCOL = TCP)(HOST =10.138.130.101)(PORT = 1521))
  6      )
  7      (CONNECT_DATA =
  8        (SERVER = DEDICATED)
  9        (SERVICE_NAME =sjjh)
 10      )
 11    )';

Database link created.

创建dblink后验证是否可以能过dblink访问源数据库

SQL> select * from dual@ttslink;

D
-
X

在目标数据库中创建用户方案LDJC,CDZJ

SQL> create user ldjc identified by "ldjc";

User created.

SQL> grant dba,connect,resource to ldjc;

Grant succeeded.

SQL> create user cdzj identified by "cdzj";

User created.


SQL> grant dba,connect,resource to cdzj;

Grant succeeded.


IBMP740-2:/oracle11/xtts_script$impdp system/abcd directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles='/oracle11/oradata/jycs/jycs/CDZJ_7.dbf','/oracle11/oradata/jycs/jycs/LDJC_6.dbf'

Import: Release 11.2.0.4.0 - Production on Wed Aug 16 19:49:01 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01":  system/******** directory=dump_dir logfile=tts_imp.log network_link=ttslink transport_full_check=no transport_tablespaces=CDZJ,LDJC transport_datafiles=/oracle11/oradata/jycs/jycs/CDZJ_7.dbf,/oracle11/oradata/jycs/jycs/LDJC_6.dbf
Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
Processing object type TRANSPORTABLE_EXPORT/TABLE
Processing object type TRANSPORTABLE_EXPORT/INDEX/INDEX
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/INDEX_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/COMMENT
Processing object type TRANSPORTABLE_EXPORT/CONSTRAINT/REF_CONSTRAINT
Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
Job "SYSTEM"."SYS_IMPORT_TRANSPORTABLE_01" successfully completed at Wed Aug 16 19:50:19 2017 elapsed 0 00:01:17


IBMP740-2:/home/oracle11$impdp system/abcd directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink

Import: Release 11.2.0.4.0 - Production on Fri Aug 18 08:40:01 2017

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

Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
Starting "SYSTEM"."SYS_IMPORT_SCHEMA_01":  system/******** directory=dump_dir logfile=ysj.log schemas=ldjc,cdzj content=metadata_only exclude=table,index network_link=ttslink
Processing object type SCHEMA_EXPORT/USER
ORA-31684: Object type USER:"LDJC" already exists
ORA-31684: Object type USER:"CDZJ" already exists
Processing object type SCHEMA_EXPORT/SYSTEM_GRANT
Processing object type SCHEMA_EXPORT/ROLE_GRANT
Processing object type SCHEMA_EXPORT/DEFAULT_ROLE
Processing object type SCHEMA_EXPORT/PRE_SCHEMA/PROCACT_SCHEMA
Processing object type SCHEMA_EXPORT/SYNONYM/SYNONYM
Processing object type SCHEMA_EXPORT/TYPE/TYPE_SPEC
Processing object type SCHEMA_EXPORT/DB_LINK
Processing object type SCHEMA_EXPORT/SEQUENCE/SEQUENCE
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/FUNCTION
Processing object type SCHEMA_EXPORT/PACKAGE/COMPILE_PACKAGE/PACKAGE_SPEC/ALTER_PACKAGE_SPEC
Processing object type SCHEMA_EXPORT/FUNCTION/ALTER_FUNCTION
Processing object type SCHEMA_EXPORT/VIEW/VIEW
ORA-39082: Object type VIEW:"LDJC"."DB03" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AA10" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AA12" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_USER" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB01_WEB_NSLOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."AB02_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB01_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB02_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB03" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB03H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB03_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB04" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB04H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB04_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB05" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB05H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BB05_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BC02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BC02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BC02_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BD01_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BD02_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BD03_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BF01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BF01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ01" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ01H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ01_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ02" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ02H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ02_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ03" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ03H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ04" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ04H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ04_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ05" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ05H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ05_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ06" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ06H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ07" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ07H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ07_1" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ08" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ08H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ09" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ09H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ09_TEMP" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ10" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ10H" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ10_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."BZ11_WEB" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."OAE300_LOG" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."TEMP_AAB002" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."V_JCXT_AJGL_JABP" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."JCXT_AJGL_ZWNR" created with compilation warnings
ORA-39082: Object type VIEW:"LDJC"."V_JCXT_AJGL_LABP" created with compilation warnings
Processing object type SCHEMA_EXPORT/PACKAGE/PACKAGE_BODY
ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_PKG" created with compilation warnings
ORA-39082: Object type PACKAGE_BODY:"LDJC"."QUEST_SOO_SQLTRACE" created with compilation warnings
Processing object type SCHEMA_EXPORT/JOB
Processing object type SCHEMA_EXPORT/POST_SCHEMA/PROCOBJ
Job "SYSTEM"."SYS_IMPORT_SCHEMA_01" completed with 72 error(s) at Fri Aug 18 08:40:22 2017 elapsed 0 00:00:20




SQL> select * from ldjc.jy_test;

   USER_ID
----------
         1
         2
         3

SQL> select * from cdzj.jy_test;

   USER_ID
----------
         1
         2
         3

在元数据导入后,可以将源数据库中的表空间ldjc,cdzj修改为read write状态

SQL> alter tablespace ldjc read write;

Tablespace altered.

SQL>  alter tablespace cdzj read write;

Tablespace altered.

如果不使用network_link执行导入,那么可以执行传输表空间模式的data pump导出元数据,然后将元数据复制到目标数据库,再执行导入。

4.4 将目标数据库中的表空间ldjc,cdzj修改为read write状态

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
CDZJ                           READ ONLY
LDJC                           READ ONLY


SQL> alter tablespace ldjc read write;

Tablespace altered.

SQL> alter tablespace cdzj read write;

Tablespace altered.

SQL> select tablespace_name,status from dba_tablespaces;

TABLESPACE_NAME                STATUS
------------------------------ ---------
SYSTEM                         ONLINE
SYSAUX                         ONLINE
UNDOTBS1                       ONLINE
TEMP                           ONLINE
USERS                          ONLINE
EXAMPLE                        ONLINE
CDZJ                           ONLINE
LDJC                           ONLINE

4.5 验证传输的数据
在这一步,在目标数据库中被传输过来的表空间设置为read only状态,然后运行应用程序来进行验证。也可以使用RMAN来检查物理与逻辑块损坏的情况。

IBMP740-2:/oracle11/xtts$export ORACLE_SID=jycs
IBMP740-2:/oracle11/xtts$rman target/

RMAN> validate tablespace LDJC,CDZJ check logical;

Starting validate at 2017-08-16 20:00:52
using channel ORA_DISK_1
channel ORA_DISK_1: starting validation of datafile
channel ORA_DISK_1: specifying datafile(s) for validation
input datafile file number=00007 name=/oracle11/oradata/jycs/jycs/LDJC_6.dbf
input datafile file number=00006 name=/oracle11/oradata/jycs/jycs/CDZJ_7.dbf
channel ORA_DISK_1: validation complete, elapsed time: 00:00:25
List of Datafiles
=================
File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
6    OK     0              255625       262144          14690188839620
  File Name: /oracle11/oradata/jycs/jycs/CDZJ_7.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              6239
  Index      0              0
  Other      0              280

File Status Marked Corrupt Empty Blocks Blocks Examined High SCN
---- ------ -------------- ------------ --------------- ----------
7    OK     0              3818         655360          14690187700475
  File Name: /oracle11/oradata/jycs/jycs/LDJC_6.dbf
  Block Type Blocks Failing Blocks Processed
  ---------- -------------- ----------------
  Data       0              361553
  Index      0              286299
  Other      0              3690

Finished validate at 2017-08-16 20:01:17

5.清除阶段
如果为了迁移创建了单独的转换home与实例,那么在传输表空间操作完成之后可以关闭实例并删除软件。为了执行跨平台增量备份传输表空间而创建的文件与目录也可以删除了,例如:
.源系统中的dfcopydir目录
.源系统中的backupformat目录
.目标系统中的stageondest目录
.目标系统中的backupondest目录
.源系统与目标系统中的$TMPDIR环境变量

Perl脚本xttdriver.pl选项
-S 准备传输源:-S选项只有当使用dbms_file_transfer方法传输数据文件时使用。这个准备操作在源系统中只对源数据库执行一次。这步操作将创建xttnewdatafiles.txt与getfile.sql文件

-G 从源系统获取数据文件:-G选项只有当使用dbms_file_transfer方法传输数据文件时使用。获取数据文件操作在目标系统中对目标数据库只执行一次。-S选项必须在它之前执行一次,并将生成的xttnewdatafiles.txt与getfile.sql文件传输到目标系统。-G选项会连接到目标数据库并执行脚本getfile.sql。getfile.sql将调用dbms_file_transfer.get_file()过程通过使用dblink(srclink)来从源数据库的目录对象(srcdir)中获取要被传输的数据文件到目标数据库的目录对象(dstdir)中。

-p 准备对源数据库执行备份:-p选项只有当使用RMAN备份方法来生成数据文件副本时才使用。这步操作在源系统中对源数据库只执行一次。这步操作会连接到源数据库并对要被传输的每个表空间执行一次xttpreparesrc.sql脚本。xttpreparesrc.sql会执行以下操作:
1.验证表空间是否处于online,read write模式与是否不包含脱机数据文件
2.标识第一次执行增量备份操作时所需要使用的SCN信息并将它们写入$TMPDIR目录中的xttplan.txt文件中
3.在源系统中会在xtt.properties文件的dfcopydir参数所指定的目录中创建初始化数据文件副本。这些数据文件副本必须手动传输到目标每张
4.创建RMAN脚本$TMPDIR/rmanconvert.cmd,在目标系统中它将被用来将数据文件副本的字节序转换为目标系统所使用的字节序

-c 转换数据文件:-c选项只有当使用RMAN备份创建初始化数据文件副本时才使用。在目标系统中转换数据文件副本只执行一次。这步操作将使用rmanconvert.cmd文件来将数据文件副本转换为目标系统所使用的字节序。转换后的数据文件副本会被存储到xtt.properties文件的storageondest参数所指定的目录中,也就是最终目标数据库存储数据文件的目录。

-i 创建增量备份: 创建增量备份可以对源数据库执行一次或多次。这个步骤会读取$TMPDIR/xttplan.txt中所记录的SCN并生成用于前滚目标系统上数据文件副本的增量备份文件。

-r 前滚数据文件:对于创建的每个增量备份都会对目标数据库的数据文件进行前滚操作。这步操作会连接到cnvinst_home与cnvinst_sid所定义的增量转换实例,转换所创建的增量备份,那么连接到目标数据库对数据文件应用增量备份进行前滚操作。

-s 判断新的from_scn:对源数据库判断新的from_scn可以执行一次或多次。这步操作会计算下次增量备份所需要的from_scn,并将其记录在xttplan.txt文件中,然后当下一次创建增量备份的就会使用它。

-e 生成Data Pump TTS命令:在目标系统中对目标数据库只执行一次来生成Data Pump TTS命令。这步操作将创建一个使用dblink来导入元数据的Data Pump Import命令

-d debug:-d选项能以debug模式来执行xttdriver.pl与RMAN命令。要启用debug模式需要设置环境变量XTTDEBUG=1

xtt.properties文件参数说明
tablespaces:用逗号来分隔从源数据库要被传输到目标数据库的表空间列表,例如tablespaces=TS1,TS2

platformid:从v$database.platform_id获得的源数据库的platform id,例如platformid=13

srcdir:源数据库中的目录对象,它指向源数据库中存储数据文件的目录。多个目录可以使用逗号进行分隔。srcdir与dstdir的映射可以是N:1或N:N。例如可以有多个源目录且文件存储到单个目标目录或者文件来自一个特定源目录将被存储到一个特定的目标目录。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srcdir=SOURCEDIR,srcdir=SRC1,SRC2

dstdir:目标数据库中的目录对象,它指向目标数据库中存储数据文件的目录。如果使用了多个源目录(srcdir),那么可以定义多个目标目录以便将特定源目录中的文件写入特定的目标目录中。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如
dstdir=DESTDIR,dstdir=DST1,DST2

srclink:目标数据库中连接到源数据库的dblink。使用dbms_file_transfer传输数据文件时会使用这个dblink。这个参数只有使用dbms_file_transfer来传输数据文件时才使用,例如srclink=ttslink

dfcopydir:源系统中用来存储xttdriver.pl -p操作所生成的数据文件副本目录。这个目录要有足够的空间来存储所有被传输表空间的数据文件副本。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。 这个参数只有使用RMAN备份生成数据文件副本时才使用,例如dfcopydir=/stage_source

backupformat:源系统中存储增量备份文件的目录。这个目录必须要有足够的空间来存储所有创建的增量备份文件。这个目录可以是目标系统上通过NFS-mounted文件系统所挂载到源系统中的一个目录,在这种情况下,目标系统中的stageondest参数也引用这个相同的NFS目录。例如,backupformat=/stage_source

stageondest:目标系统中存储从源系统中手动传输过来的数据文件副本。这个目录要有足够的空间来存储数据文件副本。这个目录同时也是用来存储从源系统传输过来的增量备份文件的目录。在目标系统上执行xttdriver.pl -c转换数据文件与执行xttdriver.pl -r前滚数据文件时会从这个目录中读取数据文件副本与增量备份文件。这个目标也可以是一个DBFS-mounted文件系统。个目录可以是源系统上通过NFS-mounted文件系统所挂载到目标系统中的一个目录,在这种情况下,源系统中的backupformat参数与dfcopydir参数就会引用这个相同的NFS目录。可以参考See Note 359515.1 for mount option guidelines。例如stageondest=/stage_dest

storageondest:目标系统中用来存储xttdriver.pl -c转换操作后所生成的数据文件副本的目录,也就是目标数据库最终存储数据文件的目录。这个目录要有足够的空间来永久存储数据文件。这个参数当使用RMAN备份来生成初始化数据文件副本时才使用,例如
storageondest=+DATA或者storageondest=/oradata/test

backupondest:目录系统中用来存储xttdriver.pl -r前滚操作所转换后的增量备份文件的目录。这个目录要有足够的空间来存储转换后的增量备份文件。注意,如果这个参数指向ASM磁盘目录,那么需要在xtt.properties参数文件中定义asm_home与asm_sid参数。如果这个参数指向文件系统目录,那么就从xtt.properties参数文件中删除asm_home与asm_sid参数。例如,backupondest=+RECO

cnvinst_home:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_HOME,例如cnvinst_home=/u01/app/oracle/product/11.2.0.4/xtt_home

cnvinst_sid:如果需要使用一个单独的增量转换home目录时才使用。它是目标系统中运行增量转换实例的ORACLE_SID,例如cnvinst_xtt

asm_home:目标系统中ASM实例的ORACLE_HOME。注意如果backupondest设置为文件系统目录,那么就要删除asm_home与asm_sid参数,例如asm_home=/u01/app/11.2.0.4/grid

asm_sid:目标系统中ASM实例的ORACLE_SID。例如asm_sid=+ASM1

parallel:定义rmanconvert.cmd命令文件中rman convert命令的并行度。如果不设置这个参数,那么xttdriver.pl将使用parallel=8的缺省并行度。例如,parallel=3

rollparallel:定义xttdriver.pl -r前滚操作的并行度,例如rollparallel=2

getfileparallel:定义xttdriver.pl -G获取数据文件副本操作的并行度,缺省值是1,最大值为8,例如getfileparallel=4