转载

Oracle 12C Transport a Database to a Different Platform Using Backup Sets

可以从源平台传输整个数据库到有相同字节序的不同平台。当为了传输数据库而创建跨平台备份时,可以在源平台或目标平台上执行对数据库的转换。在目标平台执行对数据库的转换的最大好处就是执行转换的开锁从源平台转 移到了目标平台。
使用备份集执行跨平台数据库传输的先决条件
在为了跨平台传输数据库而创建跨平台备份之前需要满足以下条件:
.源数据库与目标数据库的spfile文件中的compatible参数必须设置为12.0.0或更高的版本。
.源数据库必须是read-only模式打开。
.dbms_tdb.check_db过程必须成功运行。
.源平台与目标平台必须有相同的字节序。

下面的例子将使用备份集执行跨平台传输数据库,源平台为Linux 64位,目标平台为windows 64位其具体操作如下
1.在目标平台上创建数据库实例jy
设置环境变量ORACLE_SID

C:/Users/Administrator>set ORACLE_SID=jy

创建实例

C:/Users/Administrator>oradim -new -sid jy -startmode m

输入 Oracle 服务用户的口令:
实例已创建。

创建Oracle口令文件

C:/Users/Administrator>orapwd file=D:/app/oracle/product/12.2.0/dbhome_1/database/pwdjy.ora password=xxzx$7817600  sysbackup=xxzx$7817600

SID_LIST_LISTENER =
(SID_LIST =
(SID_DESC =
(SID_NAME = jy)
(ORACLE_HOME =D:/app/oracle/product/12.2.0/dbhome_1)
(GLOBAL_DBNAME=jy)
)
)

在tnsnames.ora文件中增加以下内容

JY =
  (DESCRIPTION =
    (ADDRESS = (PROTOCOL = TCP)(HOST = WIN-ROUOJ6ERFO3)(PORT = 1521))
    (CONNECT_DATA =
      (SERVER = DEDICATED)
      (SERVICE_NAME = jy)
      (UR = A)
    )
  )

2.利用源数据库的spfile文件来为目标数据库创建spfile文件

SQL> create pfile='$ORACLE_HOME/dbs/inityyl.ora' from spfile;

File created.

将上面生成的inityyl.ora文件复制到目标平台D:/app/oracle/product/12.2.0/dbhome_1/database目录下并将其内容修改成如下所示

*.audit_file_dest='D:/app/oracle/admin/jy/adump'
*.cluster_database=false
*.compatible='12.2.0'
*.control_files='D:/APP/ORACLE/ORADATA/JY/CONTROLFILE/control01.ctl'
*.db_block_size=8192
*.db_create_file_dest='D:/app/oracle/oradata/'
*.db_name='jy'
*.diagnostic_dest='D:/app/oracle/'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=jyXDB)'
*.enable_pluggable_database=true
jy2.instance_number=2
jy1.instance_number=1
*.log_archive_dest_1='location=D:/app/oracle/oradata/arch/jy'
*.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
jy2.thread=2
jy1.thread=1
*.undo_retention=8640
jy1.undo_tablespace='UNDOTBS1'
jy2.undo_tablespace='UNDOTBS2'

3.在目标平台上启动实例jy

C:/Users/Administrator>sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on 星期四 2月 1 01:23:54 2018

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

已连接到空闲例程。


SQL> startup nomount
ORACLE 例程已经启动。

Total System Global Area 2147483648 bytes
Fixed Size                  8920984 bytes
Variable Size            1392509032 bytes
Database Buffers          738197504 bytes
Redo Buffers                7856128 bytes

创建spfile参数文件并重启实例到nomount状态

SQL> create spfile from pfile='D:/app/oracle/product/12.2.0/dbhome_1/database/initjy.ora';

文件已创建。

SQL> shutdown immediate
ORA-01507: ??????


ORACLE 例程已经关闭。
SQL> startup nomount
ORACLE 例程已经启动。

Total System Global Area 2147483648 bytes
Fixed Size                  8920984 bytes
Variable Size            1392509032 bytes
Database Buffers          738197504 bytes
Redo Buffers                7856128 bytes
SQL> show parameter spfile

NAME                                 TYPE                           VALUE
------------------------------------ ----------------------         -----------------------------------------------------------
spfile                               string                         D:/APP/ORACLE/PRODUCT/12.2.0/DBHOME_1/DATABASE/SPFILEJY.ORA

测试tns连接实例jy是否能够成功

C:/Users/Administrator>sqlplus /nolog

SQL*Plus: Release 12.2.0.1.0 Production on 星期四 2月 1 18:01:52 2018

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

SQL> conn sys/abcd@jy as sysdba
已连接。

4.使用有sysdba权限的用户通过SQL*Plus连接到源数据库,并查询v$transportable_platform来查询目标平台的名字,因为传输整个数据库源平台与目标平台的字节序应该相同。

[oracle@jytest1 ~]$ sqlplus / as sysdba

SQL*Plus: Release 12.2.0.1.0 Production on Thu Feb 1 18:06:37 2018

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


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

SQL> set long 200
SQL> set linesize 200
SQL> select platform_name,endian_format from v$transportable_platform;

PLATFORM_NAME                                                                                         ENDIAN_FORMAT
----------------------------------------------------------------------------------------------------- --------------
Solaris[tm] OE (32-bit)                                                                               Big
Solaris[tm] OE (64-bit)                                                                               Big
Microsoft Windows IA (32-bit)                                                                         Little
Linux IA (32-bit)                                                                                     Little
AIX-Based Systems (64-bit)                                                                            Big
HP-UX (64-bit)                                                                                        Big
HP Tru64 UNIX                                                                                         Little
HP-UX IA (64-bit)                                                                                     Big
Linux IA (64-bit)                                                                                     Little
HP Open VMS                                                                                           Little
Microsoft Windows IA (64-bit)                                                                         Little
IBM zSeries Based Linux                                                                               Big
Linux x86 64-bit                                                                                      Little
Apple Mac OS                                                                                          Big
Microsoft Windows x86 64-bit                                                                          Little
Solaris Operating System (x86)                                                                        Little
IBM Power Based Linux                                                                                 Big
HP IA Open VMS                                                                                        Little
Solaris Operating System (x86-64)                                                                     Little
Apple Mac OS (x86-64)                                                                                 Little

20 rows selected.

我这里源平台为Linux x86 64-bit,目标平台为Microsoft Windows IA (64-bit),两个平台的字节序都是Little

5.给RMAN备份输出文件选择命名方法
使用backup命令的format子句来为备份输出文件选择输出方法。比如使用format子句来为备份输出文件指定存储目录/ora_backup/tdb并且为每个文件生成以transport_为前缀的唯一文件名。FORMAT '/ora_backup/tdb/transport_%U'

6.启动RMAN连接到源数据库(整个RAC CDB)并将重启源数据库并以只读方式打开。

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

Recovery Manager: Release 12.2.0.1.0 - Production on Thu Feb 1 18:37:04 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> shutdown immediate

starting full resync of recovery catalog
full resync complete
database closed
database dismounted
Oracle instance shut down

RMAN> startup mount

connected to target database: JY (DBID=979425723)
database is already started
starting full resync of recovery catalog
full resync complete

RMAN> alter database open read only;

starting full resync of recovery catalog
full resync complete
Statement processed

7.在backup命令中使用for transport或to platform子句来备份源数据库。下面的例子对整个数据库创建跨平台传输备份。备份可以被还原到任何与源平台有相同字节序的平台。这里源平台为Linux x86 64-bit,因为使用了 for transport子句,那么对整个数据库的转换操作将在目标平台上执行。跨平台数据库备份被存储在/ora_backup/tdb目录中。

RMAN> backup for transport format '/ora_backup/tdb/db_transport_%U' database;

Starting backup at 01-FEB-18
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00003 name=+DATA/JY/DATAFILE/sysaux.298.962209605
input datafile file number=00009 name=+DATA/JY/DATAFILE/undotbs2.312.962209605
input datafile file number=00004 name=+DATA/JY/DATAFILE/undotbs1.277.962209605
input datafile file number=00001 name=+DATA/JY/DATAFILE/system.317.962209603
input datafile file number=00007 name=+DATA/JY/DATAFILE/users.301.962209605
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7ssq5l1i_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:02:05
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00014 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/users.278.962209649
input datafile file number=00011 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/sysaux.316.962209649
input datafile file number=00013 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undo_2.268.962209649
input datafile file number=00010 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/system.271.962209649
input datafile file number=00012 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/undotbs1.264.962209649
input datafile file number=00015 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/test.275.962210609
input datafile file number=00022 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353
input datafile file number=00023 name=+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7tsq5l5g_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00017 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/sysaux.259.962469409
input datafile file number=00016 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/system.260.962469409
input datafile file number=00018 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undotbs1.265.962469409
input datafile file number=00019 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/undo_2.266.962469409
input datafile file number=00021 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/test.269.962469409
input datafile file number=00020 name=+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/DATAFILE/users.267.962469409
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7usq5l8p_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00006 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/sysaux.270.962209675
input datafile file number=00005 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/system.256.962209675
input datafile file number=00008 name=+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/DATAFILE/undotbs1.296.962209675
channel ORA_DISK_1: starting piece 1 at 01-FEB-18
channel ORA_DISK_1: finished piece 1 at 01-FEB-18
piece handle=/ora_backup/tdb/db_transport_7vsq5lbf_1_1 tag=TAG20180201T192745 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:25
Finished backup at 01-FEB-18



[oracle@jytest1 tdb]$ ls -lrt
total 5532808
-rw-r----- 1 oracle asmadmin 3146178560 Feb  1 13:27 db_transport_7ssq5l1i_1_1
-rw-r----- 1 oracle asmadmin  990789632 Feb  1 13:29 db_transport_7tsq5l5g_1_1
-rw-r----- 1 oracle asmadmin  988348416 Feb  1 13:30 db_transport_7usq5l8p_1_1
-rw-r----- 1 oracle asmadmin  540270592 Feb  1 13:31 db_transport_7vsq5lbf_1_1

备份源数据库的控制文件到跨踪文件中用于在目标平台为目标数据库重新创建控制文件

SQL> alter session set tracefile_identifier='create';

Session altered.

SQL> alter database backup controlfile to trace resetlogs;

Database altered.

[root@jytest1 /]# find / -name *create*.trc
/u01/app/oracle/diag/rdbms/jy/jy1/trace/jy1_ora_22752_create.trc

[root@jytest1 /]# cat /u01/app/oracle/diag/rdbms/jy/jy1/trace/jy1_ora_22752_create.trc
Trace file /u01/app/oracle/diag/rdbms/jy/jy1/trace/jy1_ora_22752_create.trc
Oracle Database 12c Enterprise Edition Release 12.2.0.1.0 - 64bit Production
Build label:    RDBMS_12.2.0.1.0_LINUX.X64_170125
ORACLE_HOME:    /u01/app/oracle/product/12.2.0/db
System name:    Linux
Node name:      jytest1.jydba.net
Release:        3.8.13-55.1.6.el7uek.x86_64
Version:        #2 SMP Wed Feb 11 14:18:22 PST 2015
Machine:        x86_64
Instance name: jy1
Redo thread mounted by this instance: 1
Oracle process number: 40
Unix process pid: 22752, image: oracle@jytest1.jydba.net (TNS V1-V3)


*** 2018-02-01T23:42:02.696976+08:00 (CDB$ROOT(1))
*** SESSION ID:(6.7558) 2018-02-01T23:42:02.697094+08:00
*** CLIENT ID:() 2018-02-01T23:42:02.697109+08:00
*** SERVICE NAME:(SYS$USERS) 2018-02-01T23:42:02.697120+08:00
*** MODULE NAME:(sqlplus@jytest1.jydba.net (TNS V1-V3)) 2018-02-01T23:42:02.697131+08:00
*** ACTION NAME:() 2018-02-01T23:42:02.697141+08:00
*** CLIENT DRIVER:(SQL*PLUS) 2018-02-01T23:42:02.697150+08:00
*** CONTAINER ID:(1) 2018-02-01T23:42:02.697161+08:00

-- The following are current System-scope REDO Log Archival related
-- parameters and can be included in the database initialization file.
--
-- LOG_ARCHIVE_DEST=''
-- LOG_ARCHIVE_DUPLEX_DEST=''
--
-- LOG_ARCHIVE_FORMAT=%t_%s_%r.dbf
--
-- DB_UNIQUE_NAME="jy"
--
-- LOG_ARCHIVE_CONFIG='SEND, RECEIVE, NODG_CONFIG'
-- LOG_ARCHIVE_MAX_PROCESSES=4
-- STANDBY_FILE_MANAGEMENT=MANUAL
-- STANDBY_ARCHIVE_DEST=?#/dbs/arch
-- FAL_CLIENT=''
-- FAL_SERVER=''
--
-- LOG_ARCHIVE_DEST_1='LOCATION=+TEST/arch'
-- LOG_ARCHIVE_DEST_1='OPTIONAL REOPEN=300 NODELAY'
-- LOG_ARCHIVE_DEST_1='ARCH NOAFFIRM NOVERIFY SYNC'
-- LOG_ARCHIVE_DEST_1='REGISTER NOALTERNATE NODEPENDENCY'
-- LOG_ARCHIVE_DEST_1='NOMAX_FAILURE NOQUOTA_SIZE NOQUOTA_USED NODB_UNIQUE_NAME'
-- LOG_ARCHIVE_DEST_1='VALID_FOR=(PRIMARY_ROLE,ONLINE_LOGFILES)'
-- LOG_ARCHIVE_DEST_STATE_1=ENABLE
--
-- The following commands will create a new control file and use it
-- to open the database.
-- Data used by Recovery Manager will be lost.
-- The contents of online logs will be lost and all backups will
-- be invalidated. Use this only if online logs are damaged.
-- After mounting the created controlfile, the following SQL
-- statement will place the database in the appropriate
-- protection mode:
--  ALTER DATABASE SET STANDBY DATABASE TO MAXIMIZE PERFORMANCE
STARTUP NOMOUNT
CREATE CONTROLFILE REUSE DATABASE "JY" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '+DATA/JY/ONLINELOG/group_1.261.961976319'  SIZE 200M BLOCKSIZE 512,
  GROUP 2 '+DATA/JY/ONLINELOG/group_2.302.961976321'  SIZE 200M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '+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',
  '+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/tts.257.966380353',
  '+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/DATAFILE/cs.294.966380783'
CHARACTER SET ZHS16GBK
;
-- Configure snapshot controlfile filename
EXECUTE SYS.DBMS_BACKUP_RESTORE.CFILESETSNAPSHOTNAME('+TEST/jy/snapcf_jy.f');
-- Configure RMAN configuration record 1
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('SNAPSHOT CONTROLFILE NAME','TO ''+test/jy/snapcf_jy.f''');
-- Configure RMAN configuration record 2
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE','DISK TO ''+test/rman_backup/%F''');
-- Configure RMAN configuration record 3
VARIABLE RECNO NUMBER;
EXECUTE :RECNO := SYS.DBMS_BACKUP_RESTORE.SETCONFIG('CONTROLFILE AUTOBACKUP','ON');
-- Commands to re-create incarnation table
-- Below log names MUST be changed to existing filenames on
-- disk. Any one log file from each branch can be used to
-- re-create incarnation records.
-- ALTER DATABASE REGISTER LOGFILE '+TEST/arch/1_1_934293149.dbf';
-- ALTER DATABASE REGISTER LOGFILE '+TEST/arch/1_1_961976319.dbf';
-- Recovery is required if any of the datafiles are restored backups,
-- or if the last shutdown was not normal or immediate.
RECOVER DATABASE USING BACKUP CONTROLFILE
-- Create log files for threads other than thread one.
ALTER DATABASE ADD LOGFILE THREAD 2
  GROUP 3 '+DATA/JY/ONLINELOG/group_3.263.961976697' SIZE 200M BLOCKSIZE 512 REUSE,
  GROUP 4 '+DATA/JY/ONLINELOG/group_4.262.961976705' SIZE 200M BLOCKSIZE 512 REUSE;
-- Database can now be opened zeroing the online logs.
ALTER DATABASE OPEN RESETLOGS;
-- Open all the PDBs.
ALTER PLUGGABLE DATABASE ALL OPEN;
-- Commands to add tempfiles to temporary tablespaces.
-- Online tempfiles have complete space information.
-- Other tempfiles may require adjustment.
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/JY/TEMPFILE/temp.299.961976339'
     SIZE 150994944  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = PDB$SEED;
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/JY/5F9AA264B21F3ED9E053AB828A0A6088/TEMPFILE/temp.297.962209865'
     SIZE 67108864  REUSE AUTOEXTEND ON NEXT 655360  MAXSIZE 32767M;
ALTER SESSION SET CONTAINER = JYPDB;
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/JY/5F9AC6865E87549FE053AB828A0ADE94/TEMPFILE/temp.276.962210519' REUSE;
ALTER SESSION SET CONTAINER = TESTPDB;
ALTER TABLESPACE TEMP ADD TEMPFILE '+DATA/JY/600D6F56DEB669CCE053AB828A0AAB7E/TEMPFILE/temp.258.962469435' REUSE;
ALTER SESSION SET CONTAINER = CDB$ROOT;
-- End of tempfile additions.

8.将在源平台上使用rman backup命令生成的备份集与备份的控制文件传输到目标平台的D:/app/oracle/oradata/tdb目录中

9.使用rman连接到目标数据库并确保目标数据库(单实例CDB)处于nomount状态

C:/Users/Administrator>rman target sys/abcd@jy

恢复管理器: Release 12.2.0.1.0 - Production on 星期四 2月 1 19:55:44 2018

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

已连接到目标数据库: JY (未装载)

10.使用有foreign database子句的restore命令来还原从源平台传输过来的备份集

RMAN> restore from platform 'Linux x86 64-bit' foreign database to new from backupset 'D:/app/oracle/oradata/tdb/db_transport_7ssq5l1i_1_1' backupset 'D:/app/oracle/oradata/tdb /db_transport_7tsq5l5g_1_1' backupset 'D:/app/oracle/oradata/tdb/db_transport_7usq5l8p_1_1' backupset 'D:/app/oracle/oradata/tdb/db_transport_7vsq5lbf_1_1';

从位于 02-2月 -18 的 restore 开始
使用通道 ORA_DISK_1

通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:/app/oracle/oradata/tdb/db_transport_7ssq5l1
i_1_1
通道 ORA_DISK_1: 将外部文件 3 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H4FHX_.DBF
通道 ORA_DISK_1: 将外部文件 9 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS2_F76H4FHX_.DBF
通道 ORA_DISK_1: 将外部文件 4 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H4FHX_.DBF
通道 ORA_DISK_1: 将外部文件 1 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H4FHX_.DBF
通道 ORA_DISK_1: 将外部文件 7 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H4FJF_.DBF
通道 ORA_DISK_1: 外部片段句柄 = D:/app/oracle/oradata/tdb/db_transport_7ssq5l1i_
1_1
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:56
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:/app/oracle/oradata/tdb/db_transport_7tsq5l5
g_1_1
通道 ORA_DISK_1: 将外部文件 14 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H65NX_.DBF
通道 ORA_DISK_1: 将外部文件 11 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H65NX_.DBF
通道 ORA_DISK_1: 将外部文件 13 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H65NX_.DBF
通道 ORA_DISK_1: 将外部文件 10 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H65NX_.DBF
通道 ORA_DISK_1: 将外部文件 12 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H65NX_.DBF
通道 ORA_DISK_1: 将外部文件 15 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H65NX_.DBF
通道 ORA_DISK_1: 将外部文件 22 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TTS_F76H65OF_.DBF
通道 ORA_DISK_1: 将外部文件 23 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_CS_F76H65OF_.DBF
通道 ORA_DISK_1: 外部片段句柄 = D:/app/oracle/oradata/tdb/db_transport_7tsq5l5g_
1_1
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:26
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:/app/oracle/oradata/tdb/db_transport_7usq5l8
p_1_1
通道 ORA_DISK_1: 将外部文件 17 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H70CR_.DBF
通道 ORA_DISK_1: 将外部文件 16 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H70CR_.DBF
通道 ORA_DISK_1: 将外部文件 18 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H70D8_.DBF
通道 ORA_DISK_1: 将外部文件 19 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H70D8_.DBF
通道 ORA_DISK_1: 将外部文件 21 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H70D8_.DBF
通道 ORA_DISK_1: 将外部文件 20 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H70D8_.DBF
通道 ORA_DISK_1: 外部片段句柄 = D:/app/oracle/oradata/tdb/db_transport_7usq5l8p_
1_1
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:16
通道 ORA_DISK_1: 正在开始还原数据文件备份集
通道 ORA_DISK_1: 正在指定从备份集还原的数据文件
通道 ORA_DISK_1: 正在还原备份片段中的所有外部文件
通道 ORA_DISK_1: 正在读取备份片段 D:/app/oracle/oradata/tdb/db_transport_7vsq5lb
f_1_1
通道 ORA_DISK_1: 将外部文件 6 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H7HXK_.DBF
通道 ORA_DISK_1: 将外部文件 5 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H7HXK_.DBF
通道 ORA_DISK_1: 将外部文件 8 还原到 D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H7HXK_.DBF
通道 ORA_DISK_1: 外部片段句柄 = D:/app/oracle/oradata/tdb/db_transport_7vsq5lbf_
1_1
通道 ORA_DISK_1: 已还原备份片段 1
通道 ORA_DISK_1: 还原完成, 用时: 00:00:16
在 02-2月 -18 完成了 restore

11.在目标平台上使用备份的控制文件来为目标数据库创建控制文件,将备分的控制文件记录的源数据文件修改成还原后的数据文件名,其创建语句如下

CREATE CONTROLFILE REUSE DATABASE "JY" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 192
    MAXLOGMEMBERS 3
    MAXDATAFILES 1024
    MAXINSTANCES 32
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/redo01.log'  SIZE 200M,
  GROUP 2 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/redo02.log'  SIZE 200M
-- STANDBY LOGFILE
DATAFILE
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_CS_F76H65OF_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H4FHX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H65NX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H70CR_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H7HXK_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H4FHX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H65NX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H70CR_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H7HXK_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H65NX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H70D8_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TTS_F76H65OF_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H4FHX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H65NX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H70D8_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H7HXK_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS2_F76H4FHX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H65NX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H70D8_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H4FJF_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H65NX_.DBF',
  'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H70D8_.DBF'
CHARACTER SET ZHS16GBK
;

执行上面的创建语句

SQL> CREATE CONTROLFILE REUSE DATABASE "JY" RESETLOGS  ARCHIVELOG
  2      MAXLOGFILES 192
  3      MAXLOGMEMBERS 3
  4      MAXDATAFILES 1024
  5      MAXINSTANCES 32
  6      MAXLOGHISTORY 292
  7  LOGFILE
  8    GROUP 1 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/redo01.log'  SIZE 200M,

  9    GROUP 2 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/redo02.log'  SIZE 200M
 10  -- STANDBY LOGFILE
 11  DATAFILE
 12    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_CS_F76H65OF_.DBF',
 13    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H4FHX_.DBF',
 14    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H65NX_.DBF',
 15    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H70CR_.DBF',
 16    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H7HXK_.DBF',
 17    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H4FHX_.DBF',
 18    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H65NX_.DBF',
 19    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H70CR_.DBF',
 20    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H7HXK_.DBF',
 21    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H65NX_.DBF',
 22    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H70D8_.DBF',
 23    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TTS_F76H65OF_.DBF',
 24    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H4FHX_.DBF',
 25    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H65NX_.DBF',
 26    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H70D8_.DBF',
 27    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H7HXK_.DBF',
 28    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS2_F76H4FHX_.DBF',
 29    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H65NX_.DBF',
 30    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H70D8_.DBF',
 31    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H4FJF_.DBF',
 32    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H65NX_.DBF',
 33    'D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H70D8_.DBF'
 34  CHARACTER SET ZHS16GBK
 35  ;

控制文件已创建。


SQL> select name from v$datafile;

NAME
--------------------------------------------------------------------------------

D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H4FHX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H4FHX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H4FHX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H7HXK_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H7HXK_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H4FJF_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H7HXK_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS2_F76H4FHX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H65NX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H65NX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H65NX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H65NX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H65NX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H65NX_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSTEM_F76H70CR_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_SYSAUX_F76H70CR_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDOTBS1_F76H70D8_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_UNDO_2_F76H70D8_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_USERS_F76H70D8_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TEST_F76H70D8_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_TTS_F76H65OF_.DBF
D:/APP/ORACLE/ORADATA/JY/DATAFILE/O1_MF_CS_F76H65OF_.DBF

已选择 22 行。


12.以open resetlogs选项打开数据库

SQL> alter database open resetlogs;

数据库已更改。

SQL>  alter pluggable database all open read write;

插接式数据库已变更。

SQL> select name,open_mode from v$pdbs;

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

13.给CDB数据库增加临进表空间数据文件

SQL> alter tablespace temp add tempfile 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/temp01.dbf'     size 100M  reuse autoextend on next 655360  maxsize 200m;

表空间已更改。

SQL> alter session set container = pdb$seed;

会话已更改。

SQL> alter tablespace temp add tempfile 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/temp02.dbf'   size 100M  reuse autoextend on next 655360  maxsize 200m;

表空间已更改。

SQL> alter session set container = jypdb;

会话已更改。

SQL> alter tablespace temp add tempfile 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/temp03.dbf'  size 100M reuse;

表空间已更改。

SQL> alter session set container = testpdb;

会话已更改。

SQL> alter tablespace temp add tempfile 'D:/APP/ORACLE/ORADATA/JY/DATAFILE/temp04.dbf' size 100M reuse;

表空间已更改。

SQL> alter session set container = cdb$root;

会话已更改。

到此使用备份集跨平台传输整个CDB数据库就完成了。

正文到此结束
Loading...