Cross-Platform Data Transport Using Image Copies

Convert Tablespace & Datafile Using Image Copies

通过IMAGE COPIES的表空间与数据文件CONVERT是DATA DUMP的传输表空间的一步,它通过在源库执行CONVERT TABLESPACE或在目标库执行CONVERT DATAFILE来对文件进行转换

Using CONVERT TABLESPACE or CONVERT DATAFILE is only one step in using cross-platform transportable tablespaces.

  1. Performing Cross-Platform Tablespace Conversion with Image Copies

To perform cross-platform tablespace conversion with image copies:

  1. Start SQL*Plus and connect to the source database prod_source with administrator privileges.
  2. Query the name for the destination platform in the V$TRANSPORTABLE_PLATFORM view.

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

  1. Check if the tablespaces to be transported are self-contained by executing the DBMS_TTS.TRANSPORT_SET_CHECK procedure.
  2. 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.
  2. Start RMAN and connect to the source database (not the destination database) as TARGET. For example, enter:

RMAN> CONNECT TARGET "sbu@prod_source AS SYSBACKUP";

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

RMAN> CONVERT TABLESPACE finance,hr

  TO PLATFORM 'Linux IA (64-bit)'

  FORMAT '/tmp/transport_linux/%U';

  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 in to the new database with the DataPump Import utility.
  4. If applicable, place the transported tablespaces into read/write mode.

  1. Performing Cross-Platform Data File Conversion with Image Copies

可以在CONVERT使用FORMAT或DB_FILE_NAME_CONVERT指定生成文件名,后者优先级高于FORMAT

If you specify a FORMAT clause, then any file not named based on the pattern provided in the DB_FILE_NAME_CONVERT clause is named based on the FORMAT pattern. 

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

To perform cross-platform data file conversion with image copies:

  1. Start SQL*Plus and connect to the source database prod_source with administrator privileges.
  2. Query the name for the source platform in V$TRANSPORTABLE_PLATFORM.

For this scenario, assume 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.

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.

  1. Make the export dump file and the data files to be transported 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, the following command connects to the target database prod_dest using the sbu user who is granted the SYSBACKUP privilege:

$ rman

RMAN> CONNECT TARGET "sbu@prod_dest AS SYSBACKUP";

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

RMAN> CONVERT DATAFILE

   '/tmp/transport_solaris/fin/fin01.dbf',

   '/tmp/transport_solaris/fin/fin02.dbf',

   '/tmp/transport_solaris/hr/hr01.dbf',

   '/tmp/transport_solaris/hr/hr02.dbf'

   DB_FILE_NAME_CONVERT

     '/tmp/transport_solaris/fin','/orahome/dbs/fin',

     '/tmp/transport_solaris/hr','/orahome/dbs/hr'

   FROM PLATFORM 'Solaris[tm] OE (64-bit)';

  1. Follow the rest of the general outline for transporting tablespaces:
  1. Plug the tablespace in to the new database with the DataPump Import utility.
  2. If applicable, place the transported tablespaces into read-only mode.

Convert DataBase Using Image Copies

You can convert the format of the data files either on the source platform or on the destination platform. 在目标库进行转化可以减少源库负载

CONVERT DATABASE的原理与DATA DUMP传输表空间或传输数据库完全不同,它不需要使用DATA DUMP导入导出元信息,而是将数据文件进行转化然后在目标端重建数据库:

  1. 转化传输包括SYSTEM表空间在内的所有数据文件
  2. 不会转化临时表空间,临时表空间如果是本地管理则传输完成后会自动在目标库创建
  3. 如果源库使用PFILE,则PFILE也会被传输;如果源库使用SPFILE将自动生成对应的PFILE再传输到目标端,最后再生它的SPFILE使用
  4. 控制文件和联机日志不会被传输,在目标端会重建控制文件并以OPEN RESETLOGS打开
  5. BFILE、外部表和directory将不会被传输。RMAN检查的时候将会把这些对象列出,用户可以手工创建这些对象。
    F. 密码文件将不会被传输,用户必须在目标数据库手工创建密码文件。

  1. Checking the Database Before Cross-Platform Database Conversion

To check the database before cross-platform conversion:

  1. On the source database, start SQL*Plus as a user with SYSDBA or SYSBACKUP privilege.
  2. Open the database in read-only mode.

SHUTDOWN IMMEDIATE

STARTUP MOUNT

ALTER DATABASE OPEN READ ONLY;

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

SET SERVEROUTPUT ON

  1. Execute the DBMS_TDB.CHECK_DB function.

This check ensures that no conditions 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 28-1.

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:

SKIP_NONE (or 0), which checks all tablespaces

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

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

The following example illustrates executing CHECK_DB on a 32-bit Linux platform for transporting a database to 32-bit Windows, skipping read-only tablespaces.

DECLARE

  db_ready BOOLEAN;

BEGIN

  db_ready :=

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

END;

/

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

  1. Examine the output to learn why the database cannot be transported, fix the problem if possible, and then return to the Step 4.
  2. 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.

The following example shows how to call the DBMS_TDB.CHECK_EXTERNAL function.

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.

  1. Converting Data Files on the Source Host When Transporting a 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:

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

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 files that require conversion.

To convert the database on the source host:

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

SHUTDOWN IMMEDIATE;

STARTUP MOUNT;

ALTER DATABASE OPEN READ ONLY;

  1. Start RMAN and connect to the source database as TARGET 
  2. Run the CONVERT DATABASE command.

RMAN> CONVERT DATABASE

   NEW DATABASE 'newdb'

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

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

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

  1. After CONVERT DATABASE completes, you can open the source database read/write again.
  2. Move the data files generated by CONVERT DATABASE to the desired locations on the destination host, and the same to transport script
  3. If necessary, edit the initialization parameter file to change any settings for the destination database. You must edit several entries at the top of the initialization parameter file when the database is moved to the destination platform:

# Please change the values of the following parameters:

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

 service_names            = "NEWDBT.example.com"

 db_recovery_file_dest    = "/tmp/convertdb/orcva"

 db_recovery_file_dest_size= 10737418240

 instance_name            = "NEWDBT"

 db_name                 = "NEWDBT"

 plsql_native_library_dir = "/tmp/convertdb/plsqlnld1"

Note: 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.

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

这个脚本是创建控制文件的语句

In the example in Step 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.

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

SQL> CONNECT / AS SYSBACKUP

If you choose not to use operating system authentication, you can create a password file and then connect with a user name and password.

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

SQL> @transportscript

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

  1. Converting Data Files on the Destination Host When Transporting a Database

3.1 Performing Preliminary Data File Conversion Steps on the Source Host

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

  1. Ensure that the database is open in read-only mode.
  2. Start RMAN and connect to the source database as TARGET
  3. Run the CONVERT DATABASE ON DESTINATION PLATFORM command.

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

如果在目标库进行转化需要使用ON DESTINATION PLATFORM选项,它会将转换语句(convert datafile commands)写在CONVERT SCRIPT目标,用于在目标库手动执行

RMAN> CONVERT DATABASE

ON DESTINATION PLATFORM

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

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

NEW DATABASE 'newdbt'

FORMAT '/tmp/convertdb/%U';

  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.

3.2 Running the Conversion Scripts on the Destination Host

  1. If necessary, edit the convert script.

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

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.

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

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

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 "sbu@prod_dest AS SYSBACKUP";

  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 includes a STARTUP NOMOUNT command.

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

In the example in Step 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.

  1. Execute the transport script in SQL*Plus.

SQL> @/tmp/convertdb/transportscript

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

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值