SEian.G

苦练七十二变,笑对八十一难

  • 博客访问: 42724
  • 博文数量: 70
  • 用 户 组: 普通用户
  • 注册时间: 2016-03-12 13:43
  • 认证徽章:
个人简介

冰冻三尺非一日之寒,滴水穿石非一日之功。

ITPUB论坛APP

ITPUB论坛APP



APP发帖 享双倍积分

文章分类

全部博文(70)

文章存档

2017年(69)

2016年(1)

微信关注

IT168企业级官微



微信号:IT168qiye



系统架构师大会



微信号:SACC2013

订阅
热词专题

分类: Oracle


这篇文章翻译自Oracle 11gR2官方文档。详细讨论了使用RMAN工具的CONVERT DATAFILE,CONVERT TABLESPACE和CONVERT DATABASE命令实现跨平台传输表空间和数据库。


 

27  Transporting Data Across Platforms

You can use RMAN to transport tablespaces across platforms with different endian formats. You can also use RMAN to transport an entire database to a different platform so long as the two platforms have the same endian format.

你可以使用RMAN在具有不同字节序序列的平台之间传输表空间。 你也可以使用RMAN传输整个数据库到不同的平台,只要这两个平台具有相同的字符串格式即可。

 

Overview of Cross-Platform Data Transportation

This section explains the basic concepts and tasks involved in transporting tablespaces and databases across platforms.

Purpose of Cross-Platform Data Transportation

You can transport tablespaces in a database that runs on one platform into a database that runs on a different platform. Typical uses of cross-platform transportable tablespaces include the following:

你可以将在一个平台上运行的数据库中的表空间传输到在不同平台上运行的数据库。跨平台可运输表空间的典型用途包括:

  • Publishing structured data as transportable tablespaces for distribution to customers, who can convert the tablespaces for integration into their existing databases regardless of platform
  • Moving data from a large data warehouse server to data marts on smaller computers such as Linux-based workstations or servers
  • Sharing read-only tablespaces across a heterogeneous cluster in which all hosts share the same endian format

·         将结构化数据作为可传输表空间发布给客户,无论平台如何,可将表空间转换为现有数据库进行集成

·         将数据从大型数据仓库服务器移动到较小型计算机(如基于Linux的工作站或服务器)上的数据集市

·         在异构集群中共享只读表空间,其中所有主机共享相同的端格式

You can also use RMAN to transport an entire database from one platform to another. For example, business requirements demand that you run your databases on less expensive servers that use a different platform. In this case, you can use RMAN to transport the entire database rather than re-create it and use import utilities or transportable tablespaces to repopulate the data.

你还可以使用RMAN将整个数据库从一个平台传输到另一个平台。例如,业务需求要求在使用不同平台的较便宜的服务器上运行数据库。在这种情况下,你可以使用RMAN传输整个数据库,而不是重新创建它,并使用导入实用程序或可移动表空间重新填充数据。

You can convert a database on the destination host or source host. Reasons for converting on the destination host include:

你可以在目标主机或源主机上转换数据库。 在目的主机上转换的原因包括:

  • Avoiding performance overhead on the source host due to the conversion process
  • Distributing a database from one source system to multiple recipients on several different platforms
  • Evaluating a migration path for a new platform

·         由于转换过程,避免源主机的性能开销

·         将数据库从一个源系统分发到多个不同平台上的多个收件人

·         评估新平台的迁移路径

 

Basic Concepts of Cross-Platform Data Transportation

You must use the RMAN CONVERT command in a transportable tablespace operation when the source platform is different from the destination platformand the endian formats are different. If you are converting part of the database between platforms that have the same endian format, you can use operating system methods to copy the files from the source to the destination. If you are converting an entire, same endian database, any data files with undo information must be converted. You cannot copy the data files directly from the source to the destination platform.

当源平台与目标平台不同,并且字节存储顺序不同时,必须在可移动表空间操作中使用RMAN CONVERT命令。 如果要在具有相同字节存储顺序的平台之间转换部分数据库,则可以使用操作系统方法将文件从源端复制到目标端。 如果要转换整个具有相同字节存储顺序的数据库,则必须转换具有undo信息的任何数据文件。不能将数据文件直接从源端复制到目标平台。

Tablespace and Data File Conversion

You can perform tablespace conversion with the RMAN CONVERT TABLESPACE command on the source host, but not on the destination host. The CONVERT TABLESPACE command does not perform in-place conversion of data files. Rather, the command produces output files in the correct format for use on the destination platform. The command does not alter the contents of data files in the source database.

你以在源主机上使用RMAN CONVERT TABLESPACE命令进行表空间转换,但该命令不能用在目标主机。 CONVERT TABLESPACE命令不能进行数据文件的就地转换。 相反,该命令会以正确的格式生成输出文件,以便在目标平台上使用。 该命令不会更改源数据库中的数据文件的内容。

You can use the CONVERT DATAFILE command to convert files on the destination host, but not on the source host. The Data Pump Export utility generates anexport dump file that, with data files manually copied to the destination host, can be imported into the destination database. Until the data files are transported into the destination database, the data files are not associated with a tablespace name in the database. In this case, RMAN cannot translate the tablespace name into a list of data files. Therefore, you must use CONVERT DATAFILE and identify the data files by file name.

可以在目标主机上使用CONVERT DATAFILE命令转换文件,但该命令不能用在源主机上。 “数据泵导出”生成一个转储文件,可将该dump文件手动复制到目标主机,将其导入目标数据库。 在将数据文件传输到目标数据库之前,数据文件不与数据库中的表空间名称相关联。 在这种情况下,RMAN无法将表空间名称转换为数据文件列表。 因此,必须使用CONVERT DATAFILE来根据文件名来识别数据文件。

Database Conversion

To convert a whole database to a different platform, both platforms must use the same endian format. The RMAN CONVERT DATABASE command automates the movement of an entire database from a source platform to a destination platform. The transported database contains the same data as the source database and also has, with a few exceptions, the same settings as the source database.

要将整个数据库转换为不同的平台,两个平台必须使用相同的字节存储顺序。 RMAN CONVERT DATABASE命令自动将整个数据库从源平台移动到目标平台。传输的数据库包含与源数据库相同的数据,除了少数特例,还有与源数据库相同的设置。

自动传送到目标平台的文件包括:

Files automatically transported to the destination platform include:

  • Data files that belong to permanent tablespaces

Unlike transporting tablespaces across platforms, transporting entire databases requires that certain types of blocks, such as blocks in undo segments, be reformatted to ensure compatibility with the destination platform. Even though the endian formats for the source and destination platforms are the same, the data files for a transportable database must under go a conversion process. You cannot simply copy data files from one platform to another as you can when transporting tablespaces.

?属于永久表空间的数据文件

与跨平台传输表空间不同,传输整个数据库需要重新格式化某些类型的块(例如undo段中的块),以确保与目标平台的兼容性。即使源平台和目标平台的字节存储顺序相同,可传输数据库的数据文件必须经过转换。当在传输表空间时,你不能简单地将数据文件从一个平台复制到另一个平台。

  • Initialization parameter file or server parameter file

If the database uses a text-based initialization parameter file, then RMAN transports it. If the database uses a server parameter file, then RMAN generates an initialization parameter file based on the server parameter file, transports it and creates a new server parameter file at the destination based on the settings in the initialization parameter file.

Usually, some parameters in the initialization parameter file require manual updating for the new database. For example, you may change the DB_NAMEand parameters such as CONTROL_FILES that indicate the locations of files on the destination host.

?初始化参数文件或服务器参数文件

如果数据库使用文本初始化参数文件,那么RMAN会传输它。如果数据库使用服务器参数文件,首先RMAN会根据服务器参数文件生成一个初始化参数文件,并在目标端根据初始化参数文件中的设置传输并创建一个新的服务器参数文件。

通常,初始化参数文件中的一些参数需要手动更新新的数据库。例如,您可以更改DB_NAME和参数(如CONTROL_FILES),以指示目标主机上文件的位置。

You can convert the format of the data files either on the source platform or on the destination platform. The CONVERT DATABASE ON DESTINATION PLATFORM command does not convert the format of data files. Rather, it generates scripts that you can run manually to perform the conversion. The CONVERT SCRIPTparameter creates a convert script that you can manually execute at the destination host to convert data file copies in batch mode. The TRANSPORT SCRIPTparameter generates a transport script that contains SQL statements to create the new database on the destination platform.

可以在源平台或目标平台上转换数据文件的格式。 CONVERT DATABASE ON DESTINATION PLATFORM命令不转换数据文件的格式。 相反,它生成可以手动运行以执行转换的脚本。 CONVERT SCRIPT参数创建一个转换脚本,你可以在目标主机上手动执行转换脚本,以批处理模式转换数据文件副本。 TRANSPORT SCRIPT参数生成包含SQL语句的传输脚本,以在目标平台上创建新的数据库。

Performing Cross-Platform Tablespace Conversion on the Source Host(在源主机中执行跨平台表空间传输)

For purposes of illustration, assume that you must transport tablespaces finance and hr from source database prod_source, which runs on a Sun Solaris host. You plan to transport them to destination database prod_dest running on a Linux PC. You plan to store the converted data files in the temporary directory/tmp/transport_linux/ on the source host.

为了说明情况,假设你必须从在Sun Solaris主机上运行的源数据库prod_source传输表空间financehr 你计划将它们传输到运行在Linux PC上的目标数据库prod_dest。你计划将转换的数据文件存储在源主机上的/ tmp / transport_linux /临时目录中。

To perform cross-platform tablespace conversion on the source host:

在源主机上执行跨平台表空间转换:

  1. Start SQL*Plus and connect to the source database prod_source with administrator privileges.

启动SQL * Plus,并以管理员权限连接到源数据库prod_source

  1. Query the name for the destination platform in the V$TRANSPORTABLE_PLATFORM view.

The database has a list of its own internal names for each platform supporting cross-platform data transport. You may need the exact name of the source or destination platform as a parameter to the CONVERT command. Query V$TRANSPORTABLE_PLATFORM to get the platform names. The following example queries Linux platform names:

V $ TRANSPORTABLE_PLATFORM视图中查询目标平台的名称。

数据库具有支持跨平台数据传输的每个平台的自己内部名称的列表。 你可能需要源平台或目标平台的确切名称作为CONVERT命令的参数。 查询V $ TRANSPORTABLE_PLATFORM以获取平台名称。 以下示例查询Linux平台名称:

SELECT PLATFORM_ID, PLATFORM_NAME, ENDIAN_FORMAT
FROM   V$TRANSPORTABLE_PLATFORM
WHERE  UPPER(PLATFORM_NAME) LIKE '%LINUX%';

The PLATFORM_NAME for Linux on a PC is Linux IA (32-bit).

  1. Place the tablespaces to be transported in read-only mode. For example, enter:

将待传输的表空间放置在只读模式。

ALTER TABLESPACE finance READ ONLY;
ALTER TABLESPACE hr READ ONLY;

  1. Choose a method for naming the output files.

You must use the FORMAT or DB_FILE_NAME_CONVERT arguments to the CONVERT command to control the names of the output files. The rules are listed in order of precedence:

你必须使用CONVERT命令的FORMATDB_FILE_NAME_CONVERT参数来控制输出文件的名称。 规则按优先顺序列出:

    1. Files that match any patterns provided in CONVERT ... DB_FILE_NAME_CONVERT clause are named based upon this pattern.
    2. If you specify a FORMAT clause, then any file not named based on patterns provided in CONVERT ... DB_FILE_NAME_CONVERT clause is named based on the FORMAT pattern.

如果指定了FORMAT子句,则根据CONVERT ... DB_FILE_NAME_CONVERT子句中提供的模式未命名的任何文件都将基于FORMAT模式进行命名。

Note:

You cannot use CONVERT ... DB_FILE_NAME_CONVERT to generate output file names for the CONVERT command when the source and destination files have Oracle Managed File names.

当源文件和目标文件具有Oracle托管文件名时,不能使用CONVERT ... DB_FILE_NAME_CONVERTCONVERT命令生成输出文件名。

 

  1. Start RMAN and connect to the source database (not the destination database) as TARGET. For example, enter:

% rman
RMAN> CONNECT TARGET SYS@prod_source

  1. Run the CONVERT TABLESPACE command to convert the data files into the endian format of the destination host.

In the following example, the FORMAT argument controls the name and location of the converted data files:

RMAN> CONVERT TABLESPACE finance,hr

2>   TO PLATFORM 'Linux IA (32-bit)'

3>   FORMAT '/tmp/transport_linux/%U';

The result is a set of converted data files in the /tmp/transport_linux/ directory, with data in the correct endian format for the Linux IA (32-bit) platform.

  1. Follow the rest of the general outline for transporting tablespaces:
    1. Use the Oracle Data Pump Export utility to create the export dump file on the source host.
    2. Move the converted data files and the export dump file from the source host to the desired directories on the destination host.
    3. Plug the tablespace into the new database with the Import utility.
    4. If applicable, place the transported tablespaces into read/write mode.

使用Oracle 数据泵在源主机上创建导出转储文件。

将转换的数据文件和导出转储文件从源主机移动到目标主机上的所需目录。

使用导入程序将表空间插入新数据库。

如果适用,将传输的表空间设置为读/写模式。

 

Performing Cross-Platform Data File Conversion on the Destination Host(在目标主机中执行跨平台数据文件传输)

About Cross-Platform Data File Conversion on the Destination Host

Data file conversion necessitates that you choose a technique for naming the output files. You must use the FORMAT or DB_FILE_NAME_CONVERT arguments to theCONVERT command to control the naming of output files. The rules are listed in order of precedence:

你必须使用CONVERT命令的FORMATDB_FILE_NAME_CONVERT参数来控制命名输出文件。规则按优先顺序列出:

  1. Files that match any patterns provided in CONVERT ... DB_FILE_NAME_CONVERT clause are named based upon this pattern.
  2. If you specify a FORMAT clause, then any file not named based on patterns provided in CONVERT ... DB_FILE_NAME_CONVERT clause is named based on theFORMAT pattern.

CONVERT中提供的任何模式匹配的文件... DB_FILE_NAME_CONVERT子句根据此模式命名。

如果指定FORMAT子句,则根据CONVERT ... DB_FILE_NAME_CONVERT子句中提供的模式未命名的任何文件都将基于FORMAT模式进行命名。

Note:

You cannot use CONVERT ... DB_FILE_NAME_CONVERT to generate output file names for the CONVERT command when both the source and destination files are Oracle Managed Files.

当源文件和目标文件都是Oracle托管文件时,不能使用CONVERT ... DB_FILE_NAME_CONVERT来生成CONVERT命令的输出文件名。

If the source and destination platforms differ, then you must specify the FROM PLATFORM parameter. View platform names by querying the V$TRANSPORTABLE_PLATFORM. The FROM PLATFORM value must match the format of the data files to be converted to avoid an error. If you do not specify FROM PLATFORM, then this parameter defaults to the value of the destination platform.

如果源和目标平台不同,则必须指定FROM PLATFORM参数。通过查询V $ TRANSPORTABLE_PLATFORM查看平台名称。 FROM PLATFORM值必须与要转换的数据文件的格式相匹配,以避免错误。如果不指定FROM PLATFORM,则此参数默认为目标平台的值。

Using CONVERT DATAFILE to Convert Data File Formats

This section explains how to use the CONVERT DATAFILE command. The section assumes that you intend to transport tablespaces finance (data filesfin/fin01.dbf and fin/fin02.dbf) and hr (data files hr/hr01.dbf and hr/hr02.dbf) from a source database named prod_source. The database runs on a Sun Solaris host. You plan to transport these tablespaces into a destination database named prod_dest, which runs on a Linux PC. You plan to perform conversion on the destination host.

假设你打算从prod_source源数据库传输表空间financedata filesfin / fin01.dbffin / fin02.dbf)和hr(数据文件hr / hr01.dbfhr / hr02.dbf)。 该数据库在Sun Solaris主机上运行。 你计划将这些表空间传输到prod_dest目标数据库,该数据库在Linux PC上运行。 你计划在目标主机上执行转换。

When the data files are plugged into the destination database, you plan to store them in /orahome/dbs and preserve the current directory structure. That is, data files for the hr tablespace are stored in the /orahome/dbs/hr subdirectory, and data files for the finance tablespace are stored in the /orahome/dbs/fin directory.

当数据文件插入目标数据库时,你计划将它们存储在/ orahome / dbs中,并保留当前的目录结构。 也就是说,hr表空间的数据文件存储在/ orahome / dbs / hr子目录中,finance表空间数据文件存储在/ orahome / dbs / fin目录中。

To perform cross-platform data file conversion on the destination host:

  1. Start SQL*Plus and connect to the source database prod_source with administrator privileges.

启动SQL * Plus,并以管理员权限连接到源数据库prod_source

  1. Query the name for the source platform in V$TRANSPORTABLE_PLATFORM.

The database has a list of its own internal names for each platform supporting cross-platform data transport. You may need the exact name of the source or destination platform as a parameter to the CONVERT command. For example, you can obtain the platform name of the connected database as follows:

V $ TRANSPORTABLE_PLATFORM中查询源平台的名称。

数据库具有支持跨平台数据传输的每个平台的自己内部名称的列表。 您可能需要源或目标平台的确切名称作为CONVERT命令的参数。 例如,可以如下获取连接的数据库的平台名称:

SELECT PLATFORM_NAME
FROM   V$TRANSPORTABLE_PLATFORM
WHERE  PLATFORM_ID =
        ( SELECT PLATFORM_ID
                   FROM   V$DATABASE );

For this scenario, assume that the PLATFORM_NAME for the source host is Solaris[tm] OE (64-bit).

  1. Identify the tablespaces to be transported from the source database and place them in read-only mode.

将待传输的表空间放置在只读模式。

For example, enter the following SQL statements to place finance and hr in read-only mode:

ALTER TABLESPACE finance READ ONLY;
ALTER TABLESPACE hr READ ONLY;

  1. On the source host, use Data Pump Export to create the export dump file

In this example, the dump file is named expdat.dmp.

在源主机使用数据泵导出一个dump文件

  1. Make the export dump file and the data files to be transported available to the destination host.

将导出转储文件和要传输的数据文件提供给目标主机

You can use NFS to make the dump file and current database files (not copies) accessible. Alternatively, you can use an operating system utility to copy these files to the destination host.

In this example, you store the files in the /tmp/transport_solaris/ directory of the destination host. You preserve the subdirectory structure from the original location of the files, that is, the data files are stored as:

    • /tmp/transport_solaris/fin/fin01.dbf
    • /tmp/transport_solaris/fin/fin02.dbf
    • /tmp/transport_solaris/hr/hr01.dbf
    • /tmp/transport_solaris/hr/hr02.dbf
  1. Start RMAN and connect to the destination database (not the source database) as TARGET. For example, enter the following command:

% rman
RMAN> CONNECT TARGET SYS@prod_dest

  1. Execute the CONVERT DATAFILE command to convert the data files into the endian format of the destination host.

执行CONVERT DATAFILE命令将数据文件转换为目标主机的字节存储顺序。

In this example, you use DB_FILE_NAME_CONVERT to control the name and location of the converted data files. You also specify the FROM PLATFORM clause.

RMAN> CONVERT DATAFILE
2>   '/tmp/transport_solaris/fin/fin01.dbf',
3>   '/tmp/transport_solaris/fin/fin02.dbf',
4>   '/tmp/transport_solaris/hr/hr01.dbf',
5>   '/tmp/transport_solaris/hr/hr02.dbf'
6>   DB_FILE_NAME_CONVERT
7>     '/tmp/transport_solaris/fin','/orahome/dbs/fin',
8>     '/tmp/transport_solaris/hr','/orahome/dbs/hr'
9>   FROM PLATFORM 'Solaris[tm] OE (64-bit)

The result is a set of converted data files in the /orahome/dbs/ directory that are named as follows:

    • /orahome/dbs/fin/fin01.dbf
    • /orahome/dbs/fin/fin02.dbf
    • /orahome/dbs/hr/hr01.dbf
    • /orahome/dbs/hr/hr02.dbf
  1. Follow the rest of the general outline for transporting tablespaces:
    1. Plug the tablespace into the new database with the Import utility.
    2. If applicable, place the transported tablespaces into read-only mode.

使用导入程序将表空间插入新数据库。

将传送的表空间置于只读模式。


 

Checking the Database Before Cross-Platform Database Conversion(跨平台数据库转换之前检查数据库)

As explained in "Basic Concepts of Cross-Platform Data Transportation", you can use the RMAN CONVERT DATABASE command to automate the copying of an entire database from one platform to another.

你可以使用RMAN CONVERT DATABASE命令自动将整个数据库从一个平台复制到另一个平台。

Before converting the database, see the list of CONVERT DATABASE command prerequisites described in Oracle Database Backup and Recovery Reference.Confirm that you meet all these prerequisites before attempting the procedure in this section.

在转换数据库之前,请参阅Oracle数据库备份和恢复参考中描述的CONVERT DATABASE命令先决条件列表。确认在尝试本节中的过程之前,满足所有这些先决条件。

One prerequisite is that both the source and destination platform must share the same endian format. For example, you can transport a database from Microsoft Windows to Linux for x86 (both little-endian), or from HP-UX to AIX (both big-endian), but not from HP-UX to Linux for x86 (big-endian to little-endian).

一个先决条件是源平台和目标平台必须共享相同的字节存储顺序。例如,你可以将数据库从Microsoft Windows传输到Linux for x86(小端),或从HP-UX传输到AIX(大端),但不能从HP-UXLinux for x86(大端到小端)。

Note:

If you cannot use the CONVERT DATABASE command because the platforms do not share endian formats, then you can create a database on a destination platform manually and transport needed tablespaces from the source database with cross-platform transportable tablespaces.

如果不能使用CONVERT DATABASE命令,因为平台字节存储序列不一致,那么你可以手动创建目标平台上的数据库,并使用跨平台的可移动表空间从源数据库传输所需的表空间。

When you transport entire databases, note that certain files require RMAN conversion to ensure compatibility with the destination platform. Even though the endian formats for the source and destination platform are the same, these files cannot be simply copied from the source to the destination system. The following kinds of files require RMAN conversion:

当传输整个数据库时,请注意,某些文件需要进行RMAN转换才能确保与目标平台的兼容性。即使源平台和目标平台的字节存储顺序相同,这些文件也不能简单地从源文件复制到目标系统。以下类型的文件需要RMAN转换:

  • Any file containing undo segments
  • Any file containing automatic segment space management (ASSM) segment headers that is being transported to or from the HP Tru64 platform

·         任何包含undo段的文件

·         任何包含自动段空间管理(ASSM)段头的文件,这些段头正在传输到HP Tru64平台或从HP Tru64平台传输

The CONVERT DATABASE command, by default, processes all data files in the database using RMAN conversion. The RMAN conversion copies the files from one location to another, even when it does not make any changes to the file. If you have other preferred means to copy those files that do not require RMAN conversion, you can use the SKIP UNNECESSARY DATAFILES option of the CONVERT DATABASE command. If you select this option, then the CONVERT DATABASE command only processes the kinds of files previously mentioned. All other files must be copied by the user from the source to the destination database.

CONVERT DATABASE命令默认使用RMAN转换来处理数据库中的所有数据文件。即使文件没有进行任何更改,RMAN转换将文件从一个位置复制到另一个位置。如果有其他首选方法来复制不需要RMAN转换的文件,则可以使用CONVERT DATABASE命令的SKIP UNNECESSARY DATAFILES选项。如果选择此选项,则CONVERT DATABASE命令仅处理上述文件的种类。所有其他文件必须由用户从源复制到目标数据库。

The files should be copied while the source database is open in read-only mode. Similarly, if the conversion is performed at the destination, all data files should be copied to the destination when the source database is open in read-only mode.

在源数据库以只读模式打开时,在复制文件。类似地,如果在目的地执行转换,则当源数据库以只读模式打开时,所有数据文件都应被复制到目标。

To prepare for database conversion:

  1. Start a SQL*Plus session as SYSDBA on the source database.

SYSDBA的权限使用SQl*Plus连接到源数据库

  1. Open the database in read-only mode.

以只读模式打开数据库

ALTER DATABASE OPEN READ ONLY;

  1. Ensure that server output is on in SQL*Plus.

For example, enter the following SQL*Plus command:

SET SERVEROUTPUT ON

  1. Execute the DBMS_TDB.CHECK_DB function.

执行DBMS_TDB.CHECK_DB函数

This check ensures that no conditions would prevent the transport of the database, such as incorrect compatibility settings, in-doubt or active transactions, or incompatible endian formats between the source platform and destination platform.

此检查确保没有条件会阻止数据库的传输,例如不正确的兼容性设置,无效或活动事务,或源平台和目标平台之间不兼容的字节存储顺序。

You can call CHECK_DB without arguments to see if a condition at the source database prevents transport. You can also call this function with the arguments shown in Table 27-1.

可以调用CHECK_DB而不用参数来查看源数据库中的条件是否阻止传输。还可以使用表27-1所示的参数调用此函数。

Table 27-1 CHECK_DB Function Parameters

Parameter

Description

target_platform_name

The name of the destination platform as it appears in the V$DB_TRANSPORTABLE_PLATFORM view.

This parameter is optional, but is required when the skip_option parameter is used. If omitted, it is assumed that the destination platform is compatible with the source platform, and only the conditions not related to platform compatibility are tested.

skip_option

Specifies which, if any, parts of the database to skip when checking whether the database can be transported. Supported values (of type NUMBER) are:

o    SKIP_NONE (or 0), which checks all tablespaces

o    SKIP_OFFLINE (or 2), which skips checking data files in offline tablespaces

o    SKIP_READONLY (or 3), which skips checking data files in read-only tablespaces

 

Example 27-1 illustrates executing CHECK_DB on a 32-bit Linux platform for transporting a database to 32-bit Windows, skipping read-only tablespaces.

验证在32Linux平台上执行CHECK_DB,用于将数据库传输到32Windows,并跳过只读表空间。

Example 27-1 Executing DBMS_TDB.CHECK_DB

DECLARE

  db_ready BOOLEAN;

BEGIN

  db_ready :=

       DBMS_TDB.CHECK_DB('Microsoft Windows IA (32-bit)',DBMS_TDB.SKIP_READONLY);

END;

/

 

PL/SQL procedure successfully completed.

If no warnings appear, or if DBMS_TDB.CHECK_DB returns TRUE, then you can transport the database. Proceed to Step 6.

如果没有出现警告,或DBMS_TDB.CHECK_DB返回TRUE,则可以传输数据库。 继续步骤6

If warnings appear, or if DBMS_TDB.CHECK_DB returns FALSE, then you cannot currently transport the database. Proceed to Step 5.

如果出现警告,或DBMS_TDB.CHECK_DB返回FALSE,则无法传输数据库。 继续步骤5

  1. Examine the output to learn why the database cannot be transported, fix the problem if possible, and then return to the Step 4. See the DBMS_TDBdocumentation for the conditions present.

检查输出以了解为什么无法传输数据库,如果可能的话可以解决问题,然后返回到步骤4.有关条件的信息,请参阅DBMS_TDB文档。

  1. Execute the DBMS_TDB.CHECK_EXTERNAL function to identify any external tables, directories, or BFILEs. RMAN cannot automate the transport of these files, so you must copy the files manually and re-create the database directories.

执行DBMS_TDB.CHECK_EXTERNAL函数来识别任何外部表,目录或BFILE RMAN无法自动传输这些文件,因此你必须手动复制文件并重新创建数据库目录。

 

Example 27-2 shows how to call the DBMS_TDB.CHECK_EXTERNAL function.

如何调用DBMS_TDB.CHECK_EXTERNAL函数

Example 27-2 Executing DBMS_TDB.CHECK_EXTERNAL

DECLARE

     external BOOLEAN;

BEGIN

    /* value of external is ignored, but with SERVEROUTPUT set to ON

     * dbms_tdb.check_external displays report of external objects

     * on console */

    external := DBMS_TDB.CHECK_EXTERNAL;

END;

/

If no external objects exist, then the procedure completes with no output. If external objects exist, however, then the output is similar to the following:

如果没有外部对象存在,那么该过程完成,没有输出。 但是,如果存在外部对象,则输出类似于以下内容:

The following external tables exist in the database:
SH.SALES_TRANSACTIONS_EXT
The following directories exist in the database:
SYS.DATA_PUMP_DIR, SYS.MEDIA_DIR, SYS.DATA_FILE_DIR, SYS.LOG_FILE_DIR
The following BFILEs exist in the database:
PM.PRINT_MEDIA

 
PL/SQL procedure successfully completed.




Converting Data Files on the Source Host When Transporting a Database
(在传输数据库时转换源主机上的数据文件)

When you transport entire databases, certain types of blocks, such as blocks in undo segments, must be reformatted to ensure compatibility with the destination platform. Even though the endian formats for the source and destination platform are the same, the data files for a transportable database must undergo a conversion process. You cannot simply copy data files from one platform to another as you can when transporting tablespaces.

当在传输整个数据库时,必须重新格式化某些类型的块(例如undo段中的块),以确保与目标平台的兼容性。尽管源平台和目标平台的字节存储顺序相同,但可传输数据库的数据文件必须经过转换过程。你不可以在传输表空间时简单地将数据文件从一个平台复制到另一个平台。

Data files with undo information and those from the HP Tru64 platform must be converted. By default, all data files are converted when the CONVERT DATABASEcommand is executed. If, however, SKIP UNNECESSARY DATAFILES is used in the CONVERT DATABASE command, then the data files with undo segments and those from the HP Tru64 platform are converted. The data files without undo segments can be copied to the new database using FTP, an operating system copy command, or some other mechanism.

必须转换具有undo信息和HP Tru64平台的数据文件。默认情况下,执行CONVERT DATABASE命令时,将转换所有数据文件。但是,如果在CONVERT DATABASE命令中使用SKIP UNNESSESSARY DATAFILES参数,则会转换具有undo段和HP Tru64平台的数据文件。没有undo段的数据文件可以使用FTP,操作系统复制命令或其他机制复制到新数据库。

This section assumes that you have already met all of the CONVERT DATABASE prerequisites and followed the steps in "Checking the Database Before Cross-Platform Database Conversion". The goal of this procedure is to convert the format of data files on the source host as part of a cross-platform database transport.

假设你已经满足了所有的CONVERT DATABASE先决条件,并按照“"Checking the Database Before Cross-Platform Database Conversion”中的步骤。该过程的目标是在源主机上转换数据文件的格式,作为跨平台数据库传输的一部分。

Assume that you want to convert a database running on Solaris to a database that runs on Windows.

假设要将在Solaris上运行的数据库转换为在Windows上运行的数据库。

To convert the database on the source platform:

  1. Open the source database in read-only mode.

ALTER DATABASE OPEN READ ONLY;

  1. Start RMAN and connect to the source database as TARGET. For example, enter the following commands:

% rman
RMAN> CONNECT TARGET SYS@source_db

  1. Run the CONVERT DATABASE command.

Example 27-3 shows a CONVERT DATABASE command (sample output included). The TRANSPORT SCRIPT parameter specifies the location of the generated SQL script that you can use to create the new database. The TO PLATFORM parameter indicates the platform of the destination database. TheDB_FILE_NAME_CONVERT parameter specifies the naming scheme for the generated data files.

27-3显示CONVERT DATABASE命令(包括样本输出)。 TRANSPORT SCRIPT参数指定可用于创建新数据库的生成的SQL脚本的位置。 TO PLATFORM参数指示目标数据库的平台。 DB_FILE_NAME_CONVERT参数指定生成的数据文件的命名方案。

Example 27-3 Converting a Database on the Source Host

RMAN> CONVERT DATABASE

2>   NEW DATABASE 'newdb'

3>   TRANSPORT SCRIPT '/tmp/convertdb/transportscript.sql'

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

5>   DB_FILE_NAME_CONVERT '/disk1/oracle/dbs' '/tmp/convertdb';

 

Starting convert at 25-NOV-06

using channel ORA_DISK_1

 

External table SH.SALES_TRANSACTIONS_EXT found in the database

 

Directory SYS.DATA_PUMP_DIR found in the database

Directory SYS.MEDIA_DIR found in the database

Directory SYS.DATA_FILE_DIR found in the database

Directory SYS.LOG_FILE_DIR found in the database

 

BFILE PM.PRINT_MEDIA found in the database

 

User SYS with SYSDBA and SYSOPER privilege found in password file

User OPER with SYSDBA privilege found in password file

channel ORA_DISK_1: starting datafile conversion

input datafile fno=00001 name=/disk1/oracle/dbs/tbs_01.f

converted datafile=/tmp/convertdb/tbs_01.f

channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:15

channel ORA_DISK_1: starting datafile conversion

input datafile fno=00002 name=/disk1/oracle/dbs/tbs_ax1.f

converted datafile=/tmp/convertdb/tbs_ax1.f

channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:03

.

.

.

channel ORA_DISK_1: starting datafile conversion

input datafile fno=00016 name=/disk1/oracle/dbs/tbs_52.f

converted datafile=/tmp/convertdb/tbs_52.f

channel ORA_DISK_1: datafile conversion complete, elapsed time: 00:00:01

Run SQL script /tmp/convertdb/transportscript.sql on the destination platform

  to create database

Edit init.ora file init_00gb3vfv_1_0.ora. This PFILE will be used to

  create the database on the destination platform

To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on

  the destination platform

To change the internal database identifier, use DBNEWID Utility

Finished backup at 25-NOV-06

  1. After CONVERT DATABASE completes, you can open the source database read/write again.

CONVERT DATABASE完成后,可以以读写的方式打开源数据库。

  1. Move the data files generated by CONVERT DATABASE to the desired locations on the destination host.

CONVERT DATABASE生成的数据文件移动到目标主机上所需的位置。

In Example 27-3, the command creates the files in the /tmp/convertdb/ directory on the source host. Move these files to the directory on the destination host that will contain the destination database files.

在例27-3中,该命令将在源主机上的/ tmp / convertdb /目录中创建文件。 将这些文件移动到将包含目标数据库文件的目标主机上的目录。

  1. If the path to the data files is different on the destination host, then edit the transport script to refer to the new data file locations.

如果数据文件的路径在目标主机上不同,则编辑传输脚本以引用新的数据文件位置。

  1. If necessary, edit the initialization parameter file to change any settings for the destination database.

如有必要,请编辑初始化参数文件以更改目标数据库的任何设置。

You should edit several entries at the top of the initialization parameter file when the database is moved to the destination platform. For example, the initialization parameter file may look as follows:

当数据库移动到目标平台时,你应该编辑初始化参数文件顶部的多个条目。 例如,初始化参数文件可能如下所示:

# Please change the values of the following parameters:
control_files            = "/tmp/convertdb/cf_D-NEWDBT_id-1778429277_00gb9u2s"
db_recovery_file_dest    = "/tmp/convertdb/orcva"
db_recovery_file_dest_size= 10737418240
instance_name            = "NEWDBT"
service_names            = "NEWDBT.example.com"
plsql_native_library_dir = "/tmp/convertdb/plsqlnld1"
db_name                  = "NEWDBT"

  1. If necessary, edit the transport script to use the new names for the converted data files.

如有必要,请编辑传输脚本以使用转换后的数据文件的新名称。

In Example 27-3, the transport script is named /tmp/convertdb/transportscript.sql. You run this script on the destination host to create the database. Thus, you must edit this script with the correct names for the data files.

在例27-3中,传输脚本命名为/tmp/convertdb/transportscript.sql 您可以在目标主机上运行此脚本来创建数据库。 因此,您必须使用数据文件的正确名称编辑此脚本

  1. On the destination host, start SQL*Plus and connect to the destination database instance as SYSDBA using operating system authentication.

在目标主机上,启动SQL * Plus,并使用操作系统身份验证以SYSDBA连接到目标数据库实例。

For example, connect as follows:

SQL> CONNECT / AS SYSDBA

If you choose not to use operating system authentication, then you must first configure Oracle Net files, create a password file, and start the listener. You can then connect to the instance with a net service name.

如果你选择不使用操作系统身份验证,则必须首先配置Oracle Net文件,创建密码文件,然后启动侦听器。 然后,您可以使用网络服务名称连接到实例。

  1. Execute the transport script in SQL*Plus to create the new database on the destination host.

SQL * Plus中执行传输脚本,以在目标主机上创建新的数据库

SQL> @transportscript

When the transport script finishes, the creation of the new database is complete.

传输脚本完成后,新数据库的创建就完成了

 

Converting Data Files on the Destination Host When Transporting a Database(在传输数据库时转换目标主机上的数据文件)

This section assumes that you have already met all of the CONVERT DATABASE command prerequisites and followed the steps in "Checking the Database Before Cross-Platform Database Conversion". The goal of this procedure is to convert the format of data files on the destination host as part of a cross-platform database transport.

假设你已经满足了所有CONVERT DATABASE命令的先决条件,并按照“"Checking the Database Before Cross-Platform Database Conversion”中的步骤进行操作。 此过程的目标是在目标主机上转换数据文件的格式,作为跨平台数据库传输的一部分。

Perform the data file conversion in the following phases:

  1. Performing Preliminary Data File Conversion Steps on the Source Host
  2. Converting Data Files on the Destination Host

在以下阶段执行数据文件转换:

在源主机上执行初步的数据文件转换步骤

转换目标主机上的数据文件

Performing Preliminary Data File Conversion Steps on the Source Host

In this procedure, you execute the CONVERT DATABASE command on the source host. This command generates an initialization parameter file and scripts that you can edit for use on the destination host. You also copy the unconverted data files from the source host to the destination host.

在此过程中,你可以在源主机上执行CONVERT DATABASE命令。 此命令生成一个初始化参数文件和脚本,你可以编辑该脚本以在目标主机上使用。你还将未转换的数据文件从源主机复制到目标主机。

To perform preliminary data file conversion steps on the source host:

  1. Ensure that the database is open in read-only mode.

确保数据库是以只读方式打开

  1. Start RMAN and connect to the source database as TARGET.

For example, enter the following commands:

% rman
RMAN> CONNECT TARGET SYS@source_db

  1. Run the CONVERT DATABASE ON DESTINATION PLATFORM command.

Example 27-4 shows a sample CONVERT DATABASE command (sample output included). The ON DESTINATION PLATFORM parameter specifies that any CONVERTcommands required for data files should be performed on the destination platform rather than the source platform. The FORMAT parameter specifies the naming scheme for the generated files.

示例27-4显示了一个示例CONVERT DATABASE命令(包括样本输出)。 ON DESTINATION PLATFORM参数指定在目标平台而不是源平台上执行数据文件所需的任何CONVERT命令。 FORMAT参数指定生成的文件的命名方案。

Example 27-4 Executing CONVERT DATABASE ON DESTINATION PLATFORM

RMAN> CONVERT DATABASE

2>   ON DESTINATION PLATFORM

3>   CONVERT SCRIPT '/tmp/convertdb/convertscript-target'

4>   TRANSPORT SCRIPT '/tmp/convertdb/transportscript-target'

5>   NEW DATABASE 'newdbt'

6>   FORMAT '/tmp/convertdb/%U';

 

Starting convert at 28-JAN-05

using target database control file instead of recovery catalog

allocated channel: ORA_DISK_1

channel ORA_DISK_1: sid=39 devtype=DISK

 

External table SH.SALES_TRANSACTIONS_EXT found in the database

 

Directory SYS.DATA_PUMP_DIR found in the database

Directory SYS.MEDIA_DIR found in the database

Directory SYS.DATA_FILE_DIR found in the database

Directory SYS.LOG_FILE_DIR found in the database

 

BFILE PM.PRINT_MEDIA found in the database

 

User SYS with SYSDBA and SYSOPER privilege found in password file

User OPER with SYSDBA privilege found in password file

channel ORA_DISK_1: starting to check datafiles

input datafile fno=00001 name=/disk1/oracle/dbs/tbs_01.f

channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00

channel ORA_DISK_1: starting to check datafiles

input datafile fno=00002 name=/disk1/oracle/dbs/tbs_ax1.f

channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00

channel ORA_DISK_1: starting to check datafiles

input datafile fno=00017 name=/disk1/oracle/dbs/tbs_03.f

channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00

.

.

.

channel ORA_DISK_1: starting to check datafiles

input datafile fno=00015 name=/disk1/oracle/dbs/tbs_51.f

channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00

channel ORA_DISK_1: starting to check datafiles

input datafile fno=00016 name=/disk1/oracle/dbs/tbs_52.f

channel ORA_DISK_1: datafile checking complete, elapsed time: 00:00:00

Run SQL script /tmp/convertdb/transportscript-target on the destination platform to create database

Edit init.ora file /tmp/convertdb/init_00gb9u2s_1_0.ora. This PFILE will be used to create the database on the destination platform

Run RMAN script /tmp/convertdb/convertscript-target on destination platform to convert datafiles

To recompile all PL/SQL modules, run utlirp.sql and utlrp.sql on the destination platform

To change the internal database identifier, use DBNEWID Utility

Finished backup at 28-JAN-05

The command in Example 27-4 creates a transport script, an initialization parameter file for the new database, and a convert script containing RMANCONVERT DATAFILE commands for each data file being converted.

示例27-4中的命令创建一个传输脚本,一个用于新数据库的初始化参数文件,以及一个转换脚本,其中包含要转换的每个数据文件的RMANCONVERT DATAFILE命令。

Note:

CONVERT DATABASE ON DESTINATION PLATFORM does not produce converted data file copies. The command only creates scripts.

CONVERT DATABASE ON DESTINATION PLATFORM不会生成转换的数据文件副本。 该命令仅创建脚本。

  1. Use an operating system utility to copy the following files to a temporary location on the destination host:

使用操作系统实用程序将以下文件复制到目标主机上的临时位置:

    • The data files to be converted(要转换的数据文件)
    • The convert script(转换脚本)
    • The transport script(传输脚本)
    • The initialization file for the destination database(目标数据库的初始化文件)
  1. Make the source database read/write.

使源数据库读/写。

Converting Data Files on the Destination Host

This section explains how to use the script created in the previous section to convert the data files on the destination host.

本节介绍如何使用上一节中创建的脚本来转换目标主机上的数据文件

The convert script created in the previous phase uses the original data file names of the source database files. The FORMAT parameter specifies the name that was generated with the FORMAT or DB_FILE_NAME_CONVERT parameter of the CONVERT DATABASE command.

在前一阶段创建的转换脚本使用源数据库文件的原始数据文件名。 FORMAT参数指定使用CONVERT DATABASE命令的FORMATDB_FILE_NAME_CONVERT参数生成的名称。

If the data files of the source database are accessible from the destination host with the same path names, then so long as the source database is read-only you can run the convert script on the destination host without any changes. For example, if the source and destination hosts both use NFS to mount a disk containing the source data files, and if the mount point for both hosts is /fs1/dbs/, then no editing is needed.

如果源数据库的数据文件可以从具有相同路径名称的目标主机访问,那么只要源数据库是只读的,你可以在目标主机上运行转换脚本,而不进行任何更改。 例如,如果源和目标主机都使用NFS装载包含源数据文件的磁盘,并且如果两个主机的安装点为/ fs1 / dbs /,则不需要编辑。

To convert the data files on the destination host:

If necessary, edit the convert script.(如有必要,编辑转换脚本)

In the script, one CONVERT DATAFILE command exists for each data file to be converted. The convert script should indicate the current temporary file names of the unconverted data files and the output file names of the converted data files. A typical convert script looks as follows:

在脚本中,每个要转换的数据文件都有一个CONVERT DATAFILE命令。 转换脚本应该指示未转换的数据文件的当前临时文件名和转换的数据文件的输出文件名。 一个典型的转换脚本如下所示:

RUN

{

 CONVERT

 FROM PLATFORM 'Linux IA (32-bit)'

 PARALLELISM 10

  DATAFILE '/disk1/oracle/dbs/tbs_01.f'

  FORMAT

 '/tmp/convertdb/data_D-TV_I-1778429277_TS-SYSTEM_FNO-1_7qgb9u2s';

 

 DATAFILE '/disk1/oracle/dbs/tbs_ax1.f'

 FORMAT

 '/tmp/convertdb/data_D-TV_I-1778429277_TS-SYSAUX_FNO-2_7rgb9u2s';

 

 DATAFILE '/disk1/oracle/dbs/tbs_03.f'

 FORMAT

 '/tmp/convertdb/data_D-TV_I-1778429277_TS-SYSTEM_FNO-17_7sgb9u2s';

 

 DATAFILE '/disk1/oracle/dbs/tbs_51.f'

 FORMAT

 '/tmp/convertdb/data_D-TV_I-1778429277_TS-TBS_5_FNO-15_8egb9u2u';

 

 DATAFILE '/disk1/oracle/dbs/tbs_52.f'

  FORMAT

 '/tmp/convertdb/data_D-TV_I-1778429277_TS-TBS_5_FNO-16_8fgb9u2u';

}

Edit each DATAFILE command in the convert script to specify the temporary location of each data file as input. Also, edit the FORMAT parameter of each command to specify the desired final location of the data files of the transported database.

convert脚本中编辑每个DATAFILE命令,以指定每个数据文件的临时位置作为输入。 此外,编辑每个命令的FORMAT参数以指定传输数据库的数据文件的所需最终位置。

  1. If necessary, edit the initialization parameter file on the destination host to change settings for the destination database.

如有必要,编辑目标主机上的初始化参数文件以更改目标数据库的设置。

You should edit several entries at the top of the initialization parameter file before moving the database to the destination platform. For example, the initialization parameter file may look as follows:

在将数据库移动到目标平台之前,应编辑初始化参数文件顶部的多个条目。 例如,初始化参数文件可能如下所示:

# Please change the values of the following parameters:

control_files            = "/tmp/convertdb/cf_D-NEWDBT_id-1778429277_00gb9u2s"

db_recovery_file_dest    = "/tmp/convertdb/orcva"

db_recovery_file_dest_size= 10737418240

instance_name            = "NEWDBT"

service_names            = "NEWDBT.example.com"

plsql_native_library_dir = "/tmp/convertdb/plsqlnld1"

db_name                  = "NEWDBT"

  1. On the destination host, use SQL*Plus to start the database instance in NOMOUNT mode.

在目标主机上,使用SQL * PlusNOMOUNT模式启动数据库实例。

Specify the initialization parameter file that you copied in the preceding step. For example, enter the following command:

指定在上一步中复制的初始化参数文件。 例如,输入以下命令

SQL> STARTUP NOMOUNT PFILE='/tmp/init_convertdb_00i2gj63_1_0.ora'

  1. Start RMAN and connect to the destination database (not the source database) as TARGET. For example, enter the following command:

% rman
RMAN> CONNECT TARGET SYS@prod_dest

  1. Run the convert script at the RMAN prompt. For example, enter the following command:

RMAN> @/tmp/convertdb/convertscript-target

  1. Shut down the database instance.

关闭数据库实例。

This step is necessary because the transport script that must execute already includes a STARTUP NOMOUNT command.

此步骤是必需的,因为必须执行的传输脚本已经包含STARTUP NOMOUNT命令。

  1. If necessary, edit the transport script to use the new names for the converted data files.

如有必要,编辑传输脚本以使用转换后的数据文件的新名称。

In Example 27-3, the transport script is /tmp/convertdb/transportscript.sql. You run this script on the destination host to create the database. Thus, you must edit this script with the correct names for the data files.

在例27-3中,传输脚本为/tmp/convertdb/transportscript.sql 您可以在目标主机上运行此脚本来创建数据库。 因此,您必须使用数据文件的正确名称编辑此脚本。

  1. Execute the transport script in SQL*Plus.

SQL * Plus中执行传输脚本。

For example, create the new database on the destination host as follows:

SQL> @/tmp/convertdb/transportscript

When the transport script completes, the destination database is created.

传输脚本完成后,将创建目标数据库

 

参考链接:

http://blog.itpub.net/23135684/viewspace-776048/

http://blog.sina.com.cn/s/blog_69e7b8d7010164xh.html

https://www.2cto.com/database/201311/260446.html

 


作者:SEian.G(苦练七十二变,笑对八十一难)



阅读(1154) | 评论(1) | 转发(0) |
给主人留下些什么吧!~~

qq1239761222017-10-31 09:56:31

万火留

评论热议
请登录后评论。

登录 注册