在12C中传输表空间变得非常简单,一条语句搞定。还可以通过RMAN跨平台备份恢复数据,另外还可以通过增量备份传输表空间减少应用停机时间。
在本机上做了个表空间传输的例子,建一个表空间,RMAN备份,再删除表空间,然后恢复表空间:
1、创建表空间,并初始化表
SQL> show user;
USER is "C##AWEN"
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
/oracle/12c/oradata/orcl12c/system01.dbf
/oracle/12c/oradata/orcl12c/sysaux01.dbf
/oracle/12c/oradata/orcl12c/undotbs01.dbf
/oracle/12c/oradata/orcl12c/users01.dbf
SQL> create tablespace rman_tts datafile '/oracle/12c/oradata/orcl12c/tts.dbf' size 20m;
Tablespace created.
SQL> create table tts_tab tablespace rman_tts as select * from all_objects;
Table created.
SQL> select count(*) from tts_tab;
COUNT(*)
----------
89069
SQL> select TABLE_NAME,TABLESPACE_NAME from dba_tables where TABLE_NAME='TTS_TAB';
TABLE_NAME
--------------------------------------------------------------------------------
TABLESPACE_NAME
------------------------------
TTS_TAB
RMAN_TTS
SQL> EXIT
Disconnected from Database 12c Enterprise Edition Release 12.1.0.1.0 - 64bit Production
With the Partitioning, OLAP, Advanced Analytics and Real Application Testing options
2、rman 备份表空间,会自动调用数据泵
[oracle@ora12c ~]$ rman target sys/
Recovery Manager: Release 12.1.0.1.0 - Production on Fri Jul 26 18:25:20 2013
Copyright (c) 1982, 2013, and/or its affiliates. All rights reserved.
connected to target database: ORCL12C (DBID=649692732)
RMAN> alter tablespace rman_tts read only;
Statement processed
RMAN> BACKUP
2> FOR TRANSPORT
3> FORMAT '/tmp/tts_readonly.bck'
4> TABLESPACE rman_tts
5> DATAPUMP FORMAT '/tmp/tts_dump.bck';
Starting backup at 26-JUL-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=21 device type=DISK
Running TRANSPORT_SET_CHECK on specified tablespaces
TRANSPORT_SET_CHECK completed successfully
Performing export of metadata for specified tablespaces...
EXPDP>
WARNING: Data Pump operations are not typically needed when connected to the root or seed of a container database.
EXPDP> Starting "SYS"."TRANSPORT_EXP_ORCL12C_xqhq":
EXPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
EXPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
EXPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
EXPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
EXPDP> Master table "SYS"."TRANSPORT_EXP_ORCL12C_xqhq" successfully loaded/unloaded
EXPDP> ******************************************************************************
EXPDP> Dump file set for SYS.TRANSPORT_EXP_ORCL12C_xqhq is:
EXPDP> /oracle/12c/db1/dbs/backup_tts_ORCL12C_21284.dmp
EXPDP> ******************************************************************************
EXPDP> Datafiles required for transportable tablespace RMAN_TTS:
EXPDP> /oracle/12c/oradata/orcl12c/tts.dbf
EXPDP> Job "SYS"."TRANSPORT_EXP_ORCL12C_xqhq" successfully completed at Fri Jul 26 18:29:41 2013 elapsed 0 00:01:23
Export completed
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00012 name=/oracle/12c/oradata/orcl12c/tts.dbf
channel ORA_DISK_1: starting piece 1 at 26-JUL-13
channel ORA_DISK_1: finished piece 1 at 26-JUL-13
piece handle=/tmp/tts_readonly.bck tag=TAG20130726T182802 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backup set
input Data Pump dump file=/oracle/12c/db1/dbs/backup_tts_ORCL12C_21284.dmp
channel ORA_DISK_1: starting piece 1 at 26-JUL-13
channel ORA_DISK_1: finished piece 1 at 26-JUL-13
piece handle=/tmp/tts_dump.bck tag=TAG20130726T182802 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 26-JUL-13
3、删除表空间数据和文件
RMAN> drop tablespace rman_tts including contents and datafiles;
using target database control file instead of recovery catalog
Statement processed
RMAN> select name from v$tablespace;
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
SYSTEM
SYSAUX
TEMP
SYSTEM
SYSAUX
TEMP
USERS
EXAMPLE
13 rows selected
4、恢复到本地
RMAN> RESTORE
2> FOREIGN TABLESPACE
3> RMAN_TTS FORMAT '/tmp/tts_readonly_%U_%n'
4> FROM BACKUPSET '/tmp/tts_readonly.bck' DUMP FILE
5> DATAPUMP DESTINATION '/tmp'
6> FROM BACKUPSET '/tmp/tts_dump.bck';
Starting restore at 26-JUL-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=58 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring all files in foreign tablespace RMAN_TTS
channel ORA_DISK_1: reading from backup piece /tmp/tts_readonly.bck
channel ORA_DISK_1: restoring foreign file 12 to /tmp/tts_readonly_data_D-ORCL12C_I-649692732_TS-RMAN_TTS_FNO-12_vlofnrvk_ORCL12Cx
channel ORA_DISK_1: foreign piece handle=/tmp/tts_readonly.bck
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring Data Pump dump file to /tmp/backup_tts_ORCL12C_20957.dmp
channel ORA_DISK_1: reading from backup piece /tmp/tts_dump.bck
channel ORA_DISK_1: foreign piece handle=/tmp/tts_dump.bck
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Performing import of metadata...
IMPDP>
WARNING: Data Pump operations are not typically needed when connected to the root or seed of a container database.
IMPDP> Master table "SYS"."TSPITR_IMP_ORCL12C_mtfv" successfully loaded/unloaded
IMPDP> Starting "SYS"."TSPITR_IMP_ORCL12C_mtfv":
IMPDP> Processing object type TRANSPORTABLE_EXPORT/PLUGTS_BLK
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE
IMPDP> Processing object type TRANSPORTABLE_EXPORT/TABLE_STATISTICS
IMPDP> Processing object type TRANSPORTABLE_EXPORT/STATISTICS/MARKER
IMPDP> Processing object type TRANSPORTABLE_EXPORT/POST_INSTANCE/PLUGTS_BLK
IMPDP> Job "SYS"."TSPITR_IMP_ORCL12C_mtfv" successfully completed at Fri Jul 26 18:36:14 2013 elapsed 0 00:00:30
Import completed
Finished restore at 26-JUL-13
5、恢复后简单测试
RMAN> select name from v$tablespace;
NAME
------------------------------
SYSTEM
SYSAUX
UNDOTBS1
USERS
TEMP
SYSTEM
SYSAUX
TEMP
SYSTEM
SYSAUX
TEMP
USERS
EXAMPLE
RMAN_TTS
14 rows selected
RMAN> select count(*) from c##awen.tts_tab;
COUNT(*)
----------
89069
此外,12C还支持跨平台备份恢复数据库,通过PLATFORM参数指定平台。
下面是一个从Linux x86 64-bit上备份一个PDB,恢复到Microsoft Windows IA (64-bit)平台的示例,由于目标端没有环境,只给出了恢复的语句:
SQL> select PLATFORM_ID,PLATFORM_NAME from v$transportable_platform;
SQL> set long 10000
SQL> set pagesize 10000
SQL> set linesize 180
SQL> /
PLATFORM_ID PLATFORM_NAME
----------- ----------------------------------
1 Solaris[tm] OE (32-bit)
2 Solaris[tm] OE (64-bit)
7 Microsoft Windows IA (32-bit)
10 Linux IA (32-bit)
6 AIX-Based Systems (64-bit)
3 HP-UX (64-bit)
5 HP Tru64 UNIX
4 HP-UX IA (64-bit)
11 Linux IA (64-bit)
15 HP Open VMS
8 Microsoft Windows IA (64-bit)
9 IBM zSeries Based Linux
13 Linux x86 64-bit
16 Apple Mac OS
12 Microsoft Windows x86 64-bit
17 Solaris Operating System (x86)
18 IBM Power Based Linux
19 HP IA Open VMS
20 Solaris Operating System (x86-64)
21 Apple Mac OS (x86-64)
20 rows selected.
SQL> exit
RMAN> BACKUP TO PLATFORM='Microsoft Windows IA (64-bit)' FORMAT '/tmp/pdborcl12c.bck' pluggable database pdborcl12c;
Starting backup at 26-JUL-13
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=00009 name=/oracle/12c/oradata/orcl12c/pdborcl12c/sysaux01.dbf
input datafile file number=00011 name=/oracle/12c/oradata/orcl12c/pdborcl12c/example01.dbf
input datafile file number=00008 name=/oracle/12c/oradata/orcl12c/pdborcl12c/system01.dbf
input datafile file number=00010 name=/oracle/12c/oradata/orcl12c/pdborcl12c/SAMPLE_SCHEMA_users01.dbf
channel ORA_DISK_1: starting piece 1 at 26-JUL-13
channel ORA_DISK_1: finished piece 1 at 26-JUL-13
piece handle=/tmp/pdborcl12c.bck tag=TAG20130726T190905 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:01:25
Finished backup at 26-JUL-13
RMAN> list backup summary;
List of Backups
===============
Key TY LV S Device Type Completion Time #Pieces #Copies Compressed Tag
------- -- -- - ----------- --------------- ------- ------- ---------- ---
26 B F A DISK 25-JUL-13 1 1 NO TAG20130725T193823
27 B F A DISK 25-JUL-13 1 1 NO TAG20130725T193949
28 B F A DISK 25-JUL-13 1 1 NO TAG20130725T194749
29 B F A DISK 25-JUL-13 1 1 NO TAG20130725T194815
32 B F A DISK 26-JUL-13 1 1 NO TAG20130726T184348
RMAN> exit
Recovery Manager complete.
[oracle@ora12c ~]$ cd /tmp/
[oracle@ora12c tmp]$ ls -l |grep pdb
-rw-r----- 1 oinstall 816463872 07-26 19:10 pdborcl12c.bck
RESTORE FROM PLATFORM ='Linux x86 64-bit'
FROM PLATFORM 'Microsoft Windows IA (64-bit)'
ALL FOREIGN DATAFILES
FORMAT '/oradata/datafiles/df_%U'
FROM BACKUPSET '/tmp/pdborcl12c.bck';
阅读(1885) | 评论(0) | 转发(0) |