Oracle Transportable TableSpace(TTS) 传输表空间 说明

来源:互联网 发布:古剑奇谭ol激活码淘宝 编辑:程序博客网 时间:2024/04/30 22:44

一.TransportableTableSpace(TTS) 说明

 官网的两篇相关文章:

Transporting Tablespaces Between Databases

http://docs.oracle.com/cd/E11882_01/server.112/e25494/tspaces013.htm

 

Creating Transportable Tablespace Sets

http://docs.oracle.com/cd/E11882_01/backup.112/e10642/rcmttbsb.htm

 

TransportableTableSpaces(TTS)特性是从Oracle 8.1版本开始提供,在8i中,可以在同平台下进行TTS 操作。在10g以后TTS 得到增强,可以跨平台进行操作。

 

1.1 Introduction to Transportable Tablespaces

You can use theTransportable Tablespaces feature to copy a set of tablespaces from one OracleDatabase to another.

       --可以使用TTS 特性将表空间从一个数据库copy 到另一个数据库。

 

Note:

This method fortransporting tablespaces requires that you place the tablespaces to betransported in read-only mode until you complete the transporting process. Ifthis is undesirable, you can use the Transportable Tablespacesfrom Backup feature, described in OracleDatabase Backup and Recovery User's Guide.

       --TTS 需要将传输的表空间至于read-only格式,直到传输操作完成,如果不能将表空间设置为read-only模式,那么也可以使用基于Backup的TTS。

 

The tablespacesbeing transported can be either dictionary managed or locally managed. Startingwith Oracle9i, the transported tablespaces are not required to be of the sameblock size as the destination database standard block size.

--使用本地管理或者数据字典管理的表空间可以被传输,从Oracle 9i开始,传输的表空间不需要和目标库相同的blocksize。

 

关于表空间的类型,参考:

Oracle 自动段空间管理(ASSM:autosegment space management)

http://blog.csdn.net/tianlesoftware/article/details/4958989

 

Moving datausing transportable tablespaces is much faster than performing either anexport/import or unload/load of the same data. This is because the datafilescontaining all of the actual data are just copied to the destination location,and you use Data Pump to transfer only the metadata of the tablespace objectsto the new database.

       --使用TTS 移动数据要比export/import 或unload/load 快很多,因为TTS数据的移动仅仅是datafile的一个copy 过程,TTS的Data Pump仅移动表空间对象的metadata.

 

Note:

Beginning withOracle Database 11g Release 1, you must use Data Pump for transportabletablespaces. The only circumstance under which you can use the original importand export utilities, IMP and EXP, is for a backward migration of XMLType datato a database version 10g Release 2 or earlier.

--从Oracle 11gR1 开始,必须使用Data Pump 来进行TTS。 只有在一种情况下可以使用exp/imp 工具,那就是迁移10gR2 之前的XMLType 数据。

 

The transportabletablespace feature is useful in several scenarios, including:

--TTS 传输表空间可以使用在如下场景:

(1)    Exporting and importingpartitions in data warehousing tables

(2)    Publishing structured data onCDs

(3)    Copying multiple read-onlyversions of a tablespace on multiple databases

(4)    Archiving historical data

(5)    Performing tablespacepoint-in-time-recovery (TSPITR)

(6)    Migrating databases among RDBMSversions and OS platforms

 

 

There are two ways totransport a tablespace:

--有两种方法使用TTS:

(1)Manually, following the stepsdescribed in this section. This involves issuing commands to SQL*Plus, RMAN,and Data Pump.

(2)Using the Transport TablespacesWizard in Enterprise Manager

To run the Transport Tablespaces Wizard:

Log in toEnterprise Manager with a user that has the EXP_FULL_DATABASE role.

At the top of the Database Home page,click Data Movement to view the Data Movement page.

Under MoveDatabase Files, click Transport Tablespaces.

 

1.2 AboutTransporting Tablespaces Across Platforms

Starting withOracle Database Release 10g, you can transport tablespaces across platforms.This functionality can be used to:

--从Oracle 10g 开始,TTS 可以跨平台进行操作,该功能可以使用在如下情况:

(1)    Allow a database to be migratedfrom one platform to another

(2)    Provide an easier and moreefficient means for content providers to publish structured data and distributeit to customers running Oracle Database on different platforms

(3)    Simplify the distribution ofdata from a data warehouse environment to data marts, which are often runningon smaller platforms

(4)    Enable the sharing of read-onlytablespaces between Oracle Database installations on different operating systemsor platforms, assuming that your storage system is accessible from thoseplatforms and the platforms all have the same endianness, as described in thesections that follow.

 

Many, but notall, platforms are supported for cross-platform tablespace transport. You canquery the V$TRANSPORTABLE_PLATFORM view to see the platforms that aresupported, and to determine each platform's endian format (byte ordering). Thefollowing query displays the platforms that support cross-platform tablespacetransport:

--但是,TTS 不是支持所有的跨平台操作,可以查询v$transportable_platform 视图来确认,主要决定因素是不同平台的endian 格式(byte ordering)。

       这点和跨操作系统迁移一致:

Oracle 跨操作系统 迁移 说明

http://blog.csdn.net/tianlesoftware/article/details/7252788

 

SQL> COLUMN PLATFORM_NAME FORMAT A36

SQL> SELECT * FROMV$TRANSPORTABLE_PLATFORM ORDER BY PLATFORM_NAME;

 

PLATFORM_ID PLATFORM_NAME                        ENDIAN_FORMAT

----------------------------------------------- --------------

         6 AIX-Based Systems (64-bit)          Big

        16 Apple Mac OS                        Big

        19 HP IA Open VMS                      Little

        15 HP Open VMS                          Little

         5 HP Tru64 UNIX                       Little

         3 HP-UX (64-bit)                      Big

         4 HP-UX IA (64-bit)                   Big

        18 IBM Power Based Linux               Big

         9 IBM zSeries Based Linux             Big

        10 Linux IA (32-bit)                   Little

        11 Linux IA (64-bit)                   Little

        13 Linux x86 64-bit                    Little

         7 Microsoft Windows IA (32-bit)       Little

         8 Microsoft Windows IA (64-bit)       Little

        12 Microsoft Windows x86 64-bit        Little

        17 Solaris Operating System (x86)      Little

        20 Solaris Operating System (x86-64)   Little

         1 Solaris[tm] OE (32-bit)             Big

         2 Solaris[tm] OE (64-bit)             Big

 

19 rows selected.

 

If the sourceplatform and the destination platform are of different endianness, then anadditional step must be done on either the source or destination platform toconvert the tablespace being transported to the destination format. If they areof the same endianness, then no conversion is necessary and tablespaces can betransported as if they were on the same platform.

--如果Source Platform 和Destination 平台是不同的endianness,那么必须先转换,让两端一致,TTS仅支持在endian 格式一致的情况。

 

Before atablespace can be transported to a different platform, the datafile header mustidentify the platform to which it belongs. In an Oracle Database withcompatibility set to 10.0.0 or later, you can accomplish this by making thedatafile read/write at least once.

--跨平台的TTS还要求DB 的compatibility 参数大于10.0.0

 

1.3 Limitationson Transportable Tablespace Use

Be aware of the following limitations asyou plan to transport tablespaces:

--TTS 有如下限制:

 

1.3.1 The source and thedestination databases must use compatible database character sets. That is, oneof the following must be true:

--TTS的两端必须使用兼容的database character。

 

Oracle 字符集的查看和修改

http://blog.csdn.net/tianlesoftware/article/details/4915223

 

(1)The database character sets of thesource and the target databases are the same.

(2)The source database character setis a strict (binary) subset of the target database character set, and thefollowing three conditions are true:

1)       The source database is inversion 10.1.0.3 or higher.

2)       The tablespaces to betransported contain no table columns with character length semantics or themaximum character width is the same in both the source and target databasecharacter sets.

3)       The tablespaces to betransported contain no columns with the CLOB data type, or the sourceand the target database character sets are both single-byte or both multibyte.

 

(3)The source database character setis a strict (binary) subset of the target database character set, and thefollowing two conditions are true:

1)       The source database is in aversion lower than 10.1.0.3.

2)       The maximum character width isthe same in the source and target database character sets.

 

1.3.2 The source and the target databasesmust use compatible national character sets. Specifically, one of the followingmust be true:

--TTS的两端必须使用兼容的national character sets。

(1)    The national character sets of thesource and target databases are the same.

(2)    The source database is inversion 10.1.0.3 or higher and the tablespaces to be transported contain nocolumns with NCHAR, NVARCHAR2, or NCLOB data type.

 

1.3.3 You cannot transport a tablespace toa destination database that contains a tablespace of the same name. However,before the transport operation, you can rename either the tablespace to betransported or the destination tablespace.

       --TTS 操作的目标库上不能包含重名的表空间,如果有可以先对tablespace 进行rename。

 

1.3.4 Objects with underlying objects (suchas materialized views) or contained objects (such as partitioned tables) arenot transportable unless all of the underlying or contained objects are in thetablespace set.

       --underlying objects 和 contained objects 仅当在tablespaceset中时才可以被transportable。

 

1.3.5 Encrypted tablespaces have thefollowing the limitations:

--加密表空间有如下限制:

(1)    Before transporting anencrypted tablespace, you must copy the Oracle wallet manually to thedestination database, unless the master encryption key is stored in a HardwareSecurity Module (HSM) device instead of an Oracle wallet. When copying thewallet, the wallet password remains the same in the destination database.However, it is recommended that you change the password on the destinationdatabase so that each database has its own wallet password. See OracleDatabase Advanced Security Administrator's Guide for information aboutHSM devices, about determining the location of the Oracle wallet, and aboutchanging the wallet password with Oracle Wallet Manager.

(2)    You cannot transport anencrypted tablespace to a database that already has an Oracle wallet for transparentdata encryption. In this case, you must use Oracle Data Pump to export thetablespace's schema objects and then import them to the destination database.You can optionally take advantage of Oracle Data Pump features that enable youto maintain encryption for the data while it is being exported and imported.See OracleDatabase Utilities for more information.

(3)    You cannot transport anencrypted tablespace to a platform with different endianness.

 

1.3.6 Tablespaces that do not use blockencryption but that contain tables with encrypted columns cannot betransported. You must use Oracle Data Pump to export and import thetablespace's schema objects. You can take advantage of Oracle Data Pumpfeatures that enable you to maintain encryption for the data while it is beingexported and imported. See OracleDatabase Utilities for more information.

--表空间没有使用blockencryption,但是其中的表使用了encrypted columns,这种情况也不能使用TTS。 这种情况可以使用DataPump 来迁移。

 

1.3.7 Beginning with Oracle Database10g Release 2, you can transport tablespaces that contain XMLTypes.Beginning with Oracle Database 11g Release 1, you must use only Data Pumpto export and import the tablespace metadata for tablespaces that containXMLTypes.

--从Oracle10gR2 开始,可以TTS 包含XMLTypes的表空间,从11gR1之后,必须使用DataPump来导出导入XMLTypes 表空间的metadata。

 

The following query returns a list oftablespaces that contain XMLTypes:

--如下SQL 可以返回包含XMLTypes表空间的列表:

select distinct p.tablespace_name fromdba_tablespaces p,

 dba_xml_tables x, dba_users u, all_all_tables t where

 t.table_name=x.table_name and t.tablespace_name=p.tablespace_name

  andx.owner=u.username

 

Transporting tablespaceswith XMLTypes has the following limitations:

--TTS XMLTypes表空间的限制:

(1)    The destination database musthave XML DB installed.

(2)    Schemas referenced by XMLTypetables cannot be the XML DB standard schemas.

(3)    Schemas referenced by XMLTypetables cannot have cyclic dependencies.

(4)    XMLType tables with row levelsecurity are not supported, because they cannot be exported or imported.

(5)    If the schema for a transportedXMLType table is not present in the destination database, it is imported andregistered. If the schema already exists in the destination database, an erroris returned unless the ignore=y option is set.

(6)    If an XMLType table uses aschema that is dependent on another schema, the schema that is depended on isnot exported. The import succeeds only if that schema is already in thedestination database.

 

1.3.8 Additional limitations include thefollowing:

--TTS其他的限制:

(1)SYSTEM Tablespace Objects Youcannot transport the SYSTEM tablespace or objects owned by the user SYS. Someexamples of such objects are PL/SQL, Java classes, callouts, views, synonyms,users, privileges, dimensions, directories, and sequences.

--SYSTEM 表空间或者SYS用户包含的对象不能使用TTS。

 

(2)OpaqueTypes Types whose interpretation is application-specific and opaque to thedatabase (such as RAW, BFILE, and the AnyTypes) can be transported,but they are not converted as part of the cross-platform transport operation.Their actual structure is known only to the application, so the applicationmust address any endianness issues after these types are moved to the newplatform. Types and objects that use these opaque types, either directly orindirectly, are also subject to this limitation.

--Opaque Types(如RAW,BFILE) 对象可以使用TTS,但必须同平台。

 

(3)Floating-PointNumbers  BINARY_FLOAT and BINARY_DOUBLE types aretransportable using Data Pump.

--Floating-Point Numbers(BINARY_FLOAT和BINARY_DOUBLE)可以使用DataPump 进行TTS。


1.3.9 source 和 targetdb 的db time zone 要一致

不同的DB version 对应不同的time zone version。可以使用如下SQL 查看time zoneversion:

SQL> SELECT version FROM v$timezone_file;

 

  VERSION

----------

       14

 

Oracle 9i 的time zone 文件version是1,10g 是2,到了11gR2,time zone files 可以从1到14.

       默认情况下,11.2.0.1 的time zone 是11.

      11.2.0.2的time zone 是14

      11.2.0.3的time zone 是14.

 

如果time zone 不同,那么在import 时会报ORA-39322 的错误:

Oracle TTSORA-39322: Cannot use transportable tablespace with different timezone version 说明

http://blog.csdn.net/tianlesoftware/article/details/7298547

 


1.4 Compatibility Considerations for Transportable Tablespaces

When you create a transportable tablespace set, Oracle Databasecomputes the lowest compatibility level at which the destination database mustrun. This is referred to as the compatibility level of the transportable set.Beginning with Oracle Database 11g, a tablespace can always be transported to adatabase with the same or higher compatibility setting, whether the destinationdatabase is on the same or a different platform. The database signals an errorif the compatibility level of the transportable set is higher than thecompatibility level of the destination database.

 

The followingtable shows the minimum compatibility requirements of the source anddestination tablespace in various scenarios. The source and destination databaseneed not have the same compatibility setting.

 

Table 14-1 Minimum CompatibilityRequirements

Transport Scenario

Minimum Compatibility Setting

Source Database

Destination Database

Databases on the same platform

8.0

8.0

Tablespace with different database block size than the destination database

9.0

9.0

Databases on different platforms

10.0

10.0

 

 

二.TTS 使用示例

The followinglist of tasks summarizes the process of transporting a tablespace. Details foreach task are provided in the subsequent example.

 

1.For cross-platform transport, check theendian format of both platforms by queryingthe V$TRANSPORTABLE_PLATFORM view.

Ignore this task if you are transportingyour tablespace set to the same platform.

 

2.Pick a self-contained set of tablespaces.

 

3.At the source database, place the set oftablespaces in read-only mode and generate a transportable tablespace set.

 

A transportabletablespace set (or transportable set) consists of datafiles for theset of tablespaces being transported and an export file containing structuralinformation (metadata) for the set of tablespaces. You use Data Pump to performthe export.

--一个transportabletablespace set 包含表空间的datafiles 和 表空间的metadata。

 

If you are transporting the tablespace setto a platform with different endianness from the source platform, you mustconvert the tablespace set to the endianness of the destination platform. Youcan perform a source-side conversion at this step in the procedure, or you canperform a destination-side conversion as part of Task 4.

--如果endianness不同,必须先进行转换。

 

4.Transport the tablespace set.

Copy thedatafiles and the export file to a place that is accessible to the destinationdatabase.

If youtransported the tablespace set to a platform with different endianness from thesource platform, and you have not performed a source-side conversion to theendianness of the destination platform, perform a destination-side conversionnow.

 

5.(Optional) Restore tablespaces toread/write mode.

 

6.At the destination database, import thetablespace set.

Invoke the Data Pump utility to import themetadata for the tablespace set.

 

Example

These tasks for transporting a tablespaceare illustrated more fully in the example that follows, where it is assumed thefollowing datafiles and tablespaces exist:

Tablespace

Datafile

sales_1

/u01/app/oracle/oradata/salesdb/sales_101.dbf

sales_2

/u01/app/oracle/oradata/salesdb/sales_201.dbf

 

Task 1:Determine if Platforms are Supported and Determine Endianness

This task isonly necessary if you are transporting the tablespace set to a platformdifferent from the source platform.

If you aretransporting the tablespace set to a platform different from the sourceplatform, then determine if cross-platform tablespace transport is supportedfor both the source and destination platforms, and determine the endianness ofeach platform. If both platforms have the same endianness, no conversion isnecessary. Otherwise you must do a conversion of the tablespace set either atthe source or destination database.

If you aretransporting sales_1 and sales_2 to a different platform,you can execute the following query on each platform. If the query returns arow, the platform supports cross-platform tablespace transport.

SELECT d.PLATFORM_NAME, ENDIAN_FORMAT

    FROM V$TRANSPORTABLE_PLATFORM tp, V$DATABASE d

    WHERE tp.PLATFORM_NAME = d.PLATFORM_NAME;

 

The following is the query result from thesource platform:

PLATFORM_NAME                      ENDIAN_FORMAT

------------------------------------------------

Solaris[tm] OE (32-bit)            Big

 

The following is the result from thedestination platform:

PLATFORM_NAME                      ENDIAN_FORMAT

------------------------------------------------

Microsoft Windows IA (32-bit)      Little

 

You can see that the endian formats aredifferent and thus a conversion is necessary for transporting the tablespaceset.

 

 

 

Task 2:Pick a Self-Contained Set of Tablespaces

There may belogical or physical dependencies between objects in the transportable set andthose outside of the set. You can only transport aset of tablespaces that is self-contained. In this context"self-contained" means that there are no references from inside theset of tablespaces pointing outside of the tablespaces. Some examples of selfcontained tablespace violations are:

--TTS 仅支持对象都在要传输的表空间里,表空间里的对象不能与其他表空间有逻辑上或者物理上的依赖关系。如:

 

(1)An index inside the set oftablespaces is for a table outside of the set of tablespaces.

Note:

It is not aviolation if a corresponding index for a table is outside of the set oftablespaces.

 

(2)A partitioned table is partiallycontained in the set of tablespaces.

The tablespaceset you want to copy must contain either all partitions of a partitioned table,or none of the partitions of a partitioned table. To transport a subset of apartition table, you must exchange the partitions into tables.

See OracleDatabase VLDB and Partitioning Guide for information about exchangingpartitions.

 

(3)A  referential integrity constraint points to atable across a set boundary.

Whentransporting a set of tablespaces, you can choose to include referentialintegrity constraints. However, doing so can affect whether a set oftablespaces is self-contained. If you decide not to transport constraints, thenthe constraints are not considered as pointers.

 

(4)A table inside the set oftablespaces contains a LOB column that points to LOBs outsidethe set of tablespaces.

 

(5)An XML DB schema (*.xsd) that wasregistered by user A imports a global schema that was registered by user B, andthe following is true: the default tablespace for user A is tablespace A, thedefault tablespace for user B is tablespace B, and only tablespace A isincluded in the set of tablespaces.

 

 

To determinewhether a set of tablespaces is self-contained, you can invokethe TRANSPORT_SET_CHECK procedure in the Oracle suppliedpackage DBMS_TTS. You must have been granted the EXECUTE_CATALOG_ROLE role(initially signed to SYS) to execute this procedure.

--可以使用TRANSPORT_SET_CHECK过程来检查表空间是否自包含。调用该过程需要EXECUTE_CATALOG_ROLE角色。

 

When you invokethe DBMS_TTS package, you specify the list of tablespaces in thetransportable set to be checked for self containment. You can optionallyspecify if constraints must be included. For strict or full containment, youmust additionally set the TTS_FULL_CHECK parameter to TRUE.

 

The strict orfull containment check is for cases that require capturing not only referencesgoing outside the transportable set, but also those coming into the set.Tablespace Point-in-Time Recovery (TSPITR) is one such case where dependentobjects must be fully contained or fully outside the transportable set.

 

For example, itis a violation to perform TSPITR on a tablespace containing atable t but not its index i because the index and data willbe inconsistent after the transport. A full containment check ensures thatthere are no dependencies going outside or coming into the transportable set.See the example for TSPITR in the OracleDatabase Backup and Recovery User's Guide.

 

Note:

The default for transportable tablespacesis to check for self containment rather than full containment.

 

The following statementcan be used to determine whethertablespaces sales_1 and sales_2 are self-contained, withreferential integrity constraints taken into consideration (indicatedby TRUE).

EXECUTEDBMS_TTS.TRANSPORT_SET_CHECK('sales_1,sales_2', TRUE);

--检查表空间自包含

 

After invokingthis PL/SQL package, you can see all violations by selecting fromthe TRANSPORT_SET_VIOLATIONS view. If the set of tablespaces isself-contained, this view is empty. The following example illustrates a casewhere there are two violations: a foreign key constraint, dept_fk, acrossthe tablespace set boundary, and a partitioned table, jim.sales, that ispartially contained in the tablespace set.

--dbms_tts 检查自包含的结果可以通过TRANSPORT_SET_VIOLATIONS视图查看,如果为空,就是自包含,如果不是自包含的,会列出这些对象。

SQL> SELECT * FROMTRANSPORT_SET_VIOLATIONS;

 

VIOLATIONS

---------------------------------------------------------------------------

Constraint DEPT_FK between table JIM.EMP intablespace SALES_1 and table

JIM.DEPT in tablespace OTHER

Partitioned table JIM.SALES is partiallycontained in the transportable set

 

These violationsmust be resolved before sales_1 and sales_2 aretransportable. As noted in the next task, one choice for bypassing theintegrity constraint violation is to not export the integrity constraints.

 

Task 3:Generate a Transportable Tablespace Set

After ensuringyou have a self-contained set of tablespaces that you want to transport,generate a transportable tablespace set by completing the following steps:

--检查完自包含,就可以生成transportable tablespace set.

 

1.     Start SQL*Plus and connect tothe database as an administrator or as a user who has either the ALTER TABLESPACE or MANAGE TABLESPACE systemprivilege.

 

2.Make all tablespaces in the setread-only.

SQL> ALTER TABLESPACE sales_1 READ ONLY;

Tablespace altered.

 

SQL> ALTER TABLESPACE sales_2 READ ONLY;

Tablespace altered.

 

3.Invoke the Data Pump export utility asuser system and specify the tablespaces in the transportable set.

SQL> HOST

 

$ expdp system dumpfile=expdat.dmpdirectory=data_pump_dir

       transport_tablespaces=sales_1,sales_2 logfile=tts_export.log

 

Password: password

 

You must always specify TRANSPORT_TABLESPACES, which determines the mode of the exportoperation.

有关data pump的说明,参考:

Oracle 10gData Pump Expdp/Impdp 详解

http://blog.csdn.net/tianlesoftware/article/details/4674224

 

To perform atransport tablespace operation with a strict containment check, use the TRANSPORT_FULL_CHECK parameter,as shown in the following example:

 

expdp system dumpfile=expdat.dmpdirectory=data_pump_dir

     transport_tablespaces=sales_1,sales_2 transport_full_check=y

     logfile=tts_export.log

 

4.Check the log file for errors, and takenote of the dump file and datafiles that you must transport to the destinationdatabase. EXPDP outputs the names and paths of these files inmessages like these:

******************************************************************************

Dump file set forSYSTEM.SYS_EXPORT_TRANSPORTABLE_01 is:

 /u01/app/oracle/admin/salesdb/dpdump/expdat.dmp

******************************************************************************

Datafiles required for transportabletablespace SALES_1:

 /u01/app/oracle/oradata/salesdb/sales_101.dbf

Datafiles required for transportabletablespace SALES_2:

 /u01/app/oracle/oradata/salesdb/sales_201.dbf

 

5.When finished, exit back to SQL*Plus:

$ EXIT

 

--以下内容需要注意:

If sales_1 and sales_2 arebeing transported to a different platform, and the endianness of the platformsis different, and if you want to convert before transporting the tablespaceset, then convert the datafiles composing the sales_1 and sales_2 tablespaces:

--如果TTS 在不同的平台上,并且endianness 也不同,那么就需要先使用RMAN 进行endianness的转换,这个过程可以在Source 端处理,也可以在Target 处理,在Source 处理过程如下:

 

1.From SQL*Plus, return to the host system:

SQL> HOST

 

2.Start RMAN and connect to the sourcedatabase:

$ RMAN TARGET /

 

Recovery Manager: Release 11.2.0.0.1

 

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

connected to target database: salesdb(DBID=3295731590)

 

3.Use the RMAN CONVERT TABLESPACE commandto convert the datafiles into a temporary location on the source platform.

 

In this example,assume that the temporary location, directory /tmp, has already beencreated. The converted datafiles are assigned names by the system.

 

RMAN> CONVERTTABLESPACE sales_1,sales_2

2> TO PLATFORM'Microsoft Windows IA (32-bit)'

3> FORMAT '/tmp/%U';

 

Starting conversion at source at 30-SEP-08

using channel ORA_DISK_1

channel ORA_DISK_1: starting datafileconversion

input datafile file number=00007name=/u01/app/oracle/oradata/salesdb/sales_101.dbf

converteddatafile=/tmp/data_D-SALESDB_I-1192614013_TS-SALES_1_FNO-7_03jru08s

channel ORA_DISK_1: datafile conversioncomplete, elapsed time: 00:00:45

channel ORA_DISK_1: starting datafileconversion

input datafile file number=00008name=/u01/app/oracle/oradata/salesdb/sales_201.dbf

converteddatafile=/tmp/data_D-SALESDB_I-1192614013_TS-SALES_2_FNO-8_04jru0aa

channel ORA_DISK_1: datafile conversioncomplete, elapsed time: 00:00:25

Finished conversion at source at 30-SEP-08

 

4.Exit Recovery Manager:

RMAN> exit

Recovery Manager complete.

 

Task 4:Transport the Tablespace Set

Complete the following steps:

 

4.1.Transport boththe datafiles and the export (dump) file of the tablespaces to a placethat is accessible to the destination database. Toaccomplish this, do one of the following:

 

(1)    If no endianness conversion of the tablespace set is needed, or ifyou already converted the tablespace set:

--如果endianness 一致,操作如下:

 

1)Transport the dump file to the directorypointed to by the DATA_PUMP_DIR directory object, or to any otherdirectory of your choosing.

Run the following query to determine thelocation of DATA_PUMP_DIR:

SELECT * FROM DBA_DIRECTORIES WHEREDIRECTORY_NAME = 'DATA_PUMP_DIR';

 

OWNER     DIRECTORY_NAME   DIRECTORY_PATH

---------- ---------------------------------------------------

SYS       DATA_PUMP_DIR   C:\app\orauser\admin\orawin\dpdump\

 

2)Transport the datafiles to thelocation of the existing datafiles of the destination database.

On the UNIX and Linux platforms, thislocation is typically /u01/app/oracle/oradata/SID/ or +DISKGROUP/SID/datafile/.

 

Note:

If you convertedthe datafiles, obtain the new names and locations of the datafiles from the CONVERT TABLESPACE commandoutput, as shown in Step 3of Task3: Generate a Transportable Tablespace Set.

 

(2)    If you intend to perform endianness conversion after transporting tothe destination host:

--如果endianness 进行过转换

1)Transport the dump file to thedirectory pointed to by the DATA_PUMP_DIR directory object, or to anyother directory of your choosing.

2)Transport the datafiles to atemporary location on the destination host (for example, /tmp or C:\TEMP).During conversion, you can move the converted datafiles to the location of theexisting datafiles of the destination database.

 

Tip:

(1)If both the source and destinationare file systems, you can transport using:

1)Any facilityfor copying flat files (for example, an operating system copy utility or ftp)

2)The DBMS_FILE_TRANSFER package

3)RMAN

4)Any facilityfor publishing on CDs


(2)If either the source or destinationis an Oracle Automatic Storage Management (Oracle ASM) disk group, you can use:

1)ftp to orfrom the /sys/asm virtual folder in the XML DB repository

2)The DBMS_FILE_TRANSFER package

3)RMAN

 

Caution:

Exercise cautionwhen using the UNIX dd utility to copy raw-device files betweendatabases. The dd utility can be used to copy an entire sourceraw-device file, or it can be invoked with options that instruct it to copyonly a specific range of blocks from the source raw-device file.

It is difficultto ascertain actual datafile size for a raw-device file because of hiddencontrol information that is stored as part of the datafile. Thus, it isadvisable when using the dd utility to specify copying the entiresource raw-device file contents.

 

4.2 If you aretransporting the tablespace set to a platform with endianness that is differentfrom the source platform, and you have not yet converted the tablespace set, doso now with RMAN.

--如果传输的表空间的endianness 格式和Source 端不一样,并且在Source没有使用RMAN 进程转换,那么就必须在Target 端进行一个转换。步骤如下:

 

The followingexample places the converted datafiles into C:\app\orauser\oradata\orawin\,which is the location of the existing datafiles for the destination database:

 

C:\>RMAN TARGET /

 

Recovery Manager: Release 11.2.0.0.1

 

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

 

connected to target database: ORAWIN(DBID=3462152886)

 

RMAN> CONVERT DATAFILE

2>'C:\Temp\sales_101.dbf',

3>'C:\Temp\sales_201.dbf'

4>TOPLATFORM="Microsoft Windows IA (32-bit)"

5>FROMPLATFORM="Solaris[tm] OE (32-bit)"

6>DB_FILE_NAME_CONVERT=

7>'C:\Temp\','C:\app\orauser\oradata\orawin\'

8> PARALLELISM=4;

 

You identify thedatafiles by filename, not by tablespace name. Until the tablespace metadata isimported, the destination instance has no way of knowing the desired tablespacenames.

 

If the sourcelocation, the target location, or both do not use Oracle Automatic StorageManagement (Oracle ASM), then the source and target platforms are optional.RMAN determines the source platform by examining the datafile, and the targetplatform defaults to the platform of the host running the conversion.

 

If both thesource and target locations use Oracle ASM, then you must specify the sourceand target platforms in the DB_FILE_NAME_CONVERT clause.

 

Task 5:(Optional) Restore Tablespaces to Read/Write Mode

Make the transported tablespaces read/writeagain at the source database, as follows:

ALTER TABLESPACE sales_1 READ WRITE;

ALTER TABLESPACE sales_2 READ WRITE;

You can postpone this task to first ensurethat the import process succeeds.

 

Task 6:Import the Tablespace Set

Note:

If you aretransporting a tablespace ofa different block size than the standard block size of the database receivingthe tablespace set, then you must first have a DB_nK_CACHE_SIZE initializationparameter entry in the receiving database parameter file.

--如果传输的表空间的block size 不一样,那么在传输之前必须先在初始化参数里设置DB_nK_CACHE_SIZE.

 

从9i开始,Oracle支持创建不同块尺寸的表空间,并且可以为不同块尺寸的数据块指定不同大小的buffer cache。

9i以后,除了SYSTEM表空间和TEMPORARY表空间必须使用标准块尺寸外,所有其他表空间都可以最多指定四种不同的块尺寸。而标准块尺寸还是由上面的所说的参数db_block_size来指定。而db_cache_size则是标致块尺寸的buffer cache的大小。

非标准块尺寸的块大小可以在创建表空间(CREATE TABLESPACE)是通过BLOCKSIZE参数指定。而不同块尺寸的buffer cache的大小就由相应参数DB_nK_CACHE_SZIE来指定,其中n可以是2,4,8,16或者32。例如,你创建了一个块大小为16K的非标准块尺寸的表空间,你就可以通过设置DB_16K_CACHE_SIZE为来指定缓存这个表空间数据块的buffer cache的大小。

任何一个尺寸的Buffer Cache都是不可以缓存其他尺寸的数据块的。因此,如果你打算使用多种块尺寸用于你的数据库的存储,你必须最少设置DB_CACHE_SIZE和DB_nK_CACHE_SIZE中的一个参数(10g后,指定了SGA_TARGET就可以不需要指定Buffer Cache的大小)。并且,你需要给你要用到的非标准块尺寸的数据块指定相应的Buffer Cache大小。这些参数使你可以为系统指定多达4种不同块尺寸的Buffer Cache。

另外,注意一点,DB_nK_CACHE_SIZE参数不能设定标准块尺寸的缓冲区大小。举例来说,如果 DB_BLOCK_SIZE设定为 4K,就不能再设定 DB_4K_CACHE_SIZE参数。

 From:

Oracle 内存 架构 详解

http://blog.csdn.net/tianlesoftware/article/details/5594080

 

For example, ifyou are transporting a tablespace with an 8K block size into a database with a4K standard block size, then you must include a DB_8K_CACHE_SIZE initialization parameter entry in theparameter file. If it is not already included in the parameter file, thisparameter can be set using the ALTER SYSTEM SET statement.

 

Any privileged user canperform this task. To import a tablespace set, complete the following steps:

--通过一下2步完成import操作:

 

1.Import the tablespace metadata using theData Pump Import utility, impdp:

 

impdp system dumpfile=expdat.dmpdirectory=data_pump_dir

  transport_datafiles=

  c:\app\orauser\oradata\orawin\sales_101.dbf,

  c:\app\orauser\oradata\orawin\sales_201.dbf

  remap_schema=sales1:crm1 remap_schema=sales2:crm2

  logfile=tts_import.log

 

Password: password

 

After thisstatement executes successfully, all tablespaces in the set being copied remainin read-only mode. Check the import log file to ensure that no error hasoccurred.

 

When dealingwith a large number of datafiles, specifying the list of datafile names in thestatement line can be a laborious process. It can even exceed the statementline limit. In this situation, you can use an import parameter file. Forexample, you can invoke the Data Pump import utility as follows:

 

impdp system parfile='par.f'

where the parameter file, par.f containsthe following:

DUMPFILE=expdat.dmp

DIRECTORY=data_pump_dir

TRANSPORT_DATAFILES=

C:\app\orauser\oradata\orawin\sales_101.dbf,

C:\app\orauser\oradata\orawin\sales_201.dbf

REMAP_SCHEMA=sales1:crm1  REMAP_SCHEMA=sales2:crm2

LOGFILE=tts_import.log

 

2.If required, put the tablespaces intoread/write mode on the destination database.

 

 

三.TTS 常见问题

MOS:

Master Note for Transportable Tablespaces(TTS) -- Common Questions and Issues [ID 1166564.1]

 

3.1 Commonly Asked Questions

 

 

 

3.2 Common Issues with Transportable Tablespaces

Please note thisis not an exhaustive list of issues. Please check the "TransportableTablespaces" heading in the "List of Bugs Fixed by Problem Type"notes for the patch set or version above the one you are currently running.These notes have the most comprehensive list of bug fixes in each patch set.

 

 

相关文档:

Compatibility and New Features whenTransporting Tablespaces with Export and Import [ID 291024.1]

How to Move Tablespaces Across PlatformsUsing Transportable Tablespaces With RMAN [ID 371556.1]

 

 

小结:

(1)源和目标数据库的COMPATIBLE初始化参数必须>=8.1,且必须是企业版

(2)如果被传输的表空间的block size和目标库的标准块size不一样,那么目标库的COMPATIBLE必须>=9.0

(3)从Oracle 8i开始,TTS就可以向后跨版本(比如8i-->9i)

(4)从Oracle 10g开始,TTS可以跨平台,如果源和目标的平台字节序(endianness)相同就不需要额外的步骤,否则还需要进行字节序转换

(5)源和目标数据库必须具有相同的character set andnational character set.

(6)TTS支持RAW device file system.

(7)10g前如果目标库存在同名的表空间,则不能TTS,从10g(COMPATIBLE>=10.0.0)开始,借助tablespace rename特性可以解决这一问题

(8)TTS不能处理system表空间及system表空间里的Objects

(9)自包含检查

       SQL> EXEC sys.DBMS_TTS.TRANSPORT_SET_CHECK('data, indx',TRUE);

       SQL> SELECT * from sys.transport_set_violations;        

(10)cannot transport objects owned bythe user SYS.

       SQL> SELECT segment_type, owner||'.'||segment_name"OWNER.SEGMENT_NAME",partition_name

            FROM dba_segments

            WHERE owner = 'SYS' AND tablespace_name IN ('DATA', 'INDX')

            ORDER BY owner, segment_type, segment_name;

(11)Database entities

     在Oracle 10g版本前,TTS不支持

     – Materialized views/replication

     – Function-based indexes

     – Scoped REFs

     – 8.0-compatible advanced queues with multiple recipients

(12)source 和 target 的time zone version 要一致,否则在import时会报ORA-39322 的错误。


注:小结转载TomasBlog:

http://tomszrp.itpub.net/post/11835/525358

 

下面2篇blog 将对传输表空间在不同db和endianness 下的传输进行示例。

0 0
原创粉丝点击