Creating Transportable Tablespace Sets By RMAN

传输表空间指DataPump使用transport_tablespaces选项导入导出, tablespace sets指要传输的表空间集及相当导出元信息

transportable tablespace set contains data files for a set of tablespaces and an export file containing structural metadata for the set of tablespaces. The export file is generated by Data Pump Export.

传输表空间操作需要把相应表空间设置为READ ONLY,而使用RESTORE RMAN备份的方式创建tablespace sets对源库无影响

A key benefit of the RMAN TRANSPORT TABLESPACE command is that it does not need access to the live data files from the tablespaces to be transported. In contrast, the transportable tablespace technique requires that the tablespaces to be transported are open read-only during the transport. Thus, transporting from backups improves database availability, especially for large tablespaces, because the tablespaces to be transported can remain open for writes during the operation. Also, placing a tablespace in read-only mode can take a long time, depending on current database activity.

Basic Concepts of Transportable Tablespace Sets

实现原理是通过auxiliary instance执行DBPITR,启动数据库到OPEN状态后自动使用传输表空间进行导出

You create a transportable tablespace set by connecting RMAN to a source database as TARGET and then executing the TRANSPORT TABLESPACE command. The source database contains the tablespaces to be transported.

You must have a backup of all needed tablespaces and archived redo log files available for use by RMAN that can be recovered to the target point in time for the TRANSPORT TABLESPACE operation.

Figure 27-1 RMAN Transportable Tablespace from Backup: Architecture

The process shown in Figure 27-1 occurs in the following phases:

  1. RMAN starts an auxiliary instance.

An auxiliary instance is created by RMAN on the same host as the source database to perform the restore and recovery of the tablespaces. RMAN automatically creates an initialization parameter file for the auxiliary instance and starts it NOMOUNT.

  1. RMAN restores a backup of the source database control file to serve as the auxiliary instance control file and mounts this control file.
  2. RMAN restores auxiliary set and transportable set data files from the backups of the source database.

The auxiliary set includes data files and other files required for the tablespace transport but which are not themselves part of the transportable tablespace set. The auxiliary set typically includes the SYSTEM and SYSAUX tablespaces, temp files, and data files containing rollback or undo segments. The auxiliary instance has other files associated with it, such as its own control file, parameter file, and online logs, but they are not part of the auxiliary set.

产生文件会放入两个目录auxiliary destination与tablespace destination:

RMAN stores the auxiliary data files in the selected auxiliary destination. The auxiliary destination is a disk location where RMAN can store auxiliary set files such as the parameter file, data files (other than those in the transportable set), control files, and online logs of the auxiliary instance during the transport. If the transport succeeds, then RMAN deletes these files.

RMAN stores the transportable set files in the tablespace destination. The tablespace destination is a disk location that by default contains the data file copies and other output files when the tablespace transport command completes.

  1. RMAN performs database point-in-time recovery (DBPITR) at the auxiliary instance.

The recovery updates auxiliary and transportable set data files to their contents as of the target time specified for the TRANSPORT TABLESPACE command. If no target time is specified, then RMAN recovers with all available redo. RMAN restores archived redo logs from backup as necessary at the auxiliary destination (or other location) and deletes them after they are applied.

  1. RMAN opens the auxiliary database with the RESETLOGS option.

The data files now reflect the tablespace contents as of the target SCN for the tablespace transport operation.

  1. RMAN places the transportable set tablespaces of the auxiliary instance into read-only mode. RMAN also invokes Data Pump Export in transportable tablespace mode to create the export dump file for the transportable set.

By default, the dump file is located in the tablespace destination. To specify the dump file location, see "Specifying Locations for Data Pump Files".

RMAN also generates the sample Data Pump import script for use when plugging in the transported tablespaces at a target database. The contents of this script are written to a file named impscript.sql in the tablespace destination. The commands for the script are also included in the RMAN command output.

  1. If the preceding steps are successful, then RMAN shuts down the auxiliary instance and deletes all files created during the TRANSPORT TABLESPACE operation except for the transportable set files, the Data Pump Export file, and the sample import script.

Basic Steps of Creating Transportable Tablespace Sets

The basic steps of creating transportable tablespace sets are as follows:

  1. Start the RMAN client and connect to the source database and, if used, the recovery catalog.
  2. If necessary, set additional parameters in the auxiliary instance parameter file.
  3. Execute the TRANSPORT TABLESPACE command.
  4. If the TRANSPORT TABLESPACE command fails, troubleshoot the problem and then retry the command until it succeeds.
  5. Return to the procedure for transporting tablespaces

Customizing Initialization Parameters for the Auxiliary Instance

When RMAN creates the auxiliary instance, it creates an initialization parameter file. The default values work for most TRANSPORT TABLESPACE cases. RMAN can also use an auxiliary instance parameter file that contains values for additional initialization parameters. These values override the values of parameters defined in the default initialization parameter file.

You might use an auxiliary instance parameter file for the following reasons:

  1. To increase STREAMS_POOL_SIZE and SHARED_POOL_SIZE if needed for Data Pump Export.
  2. To manage locations for auxiliary instance data files. For example, you do not want all auxiliary instance data files stored in the same location on disk, but you do not want to specify the location of every file individually.
  3. To specify names for online redo logs with LOG_FILE_NAME_CONVERT .

The auxiliary instance parameter file is not intended to be a complete initialization parameter file for the auxiliary instance. Any parameters specified are added to or override the default parameters for the auxiliary instance. It is not necessary to specify parameters in the initialization file that you do not intend to override.

  1. About Setting Initialization Parameters for the RMAN Auxiliary Instance

RMAN defines the basic initialization parameters in Table 27-1 for the automatic auxiliary instance.

Initialization Parameter

Value

DB_NAME

Same as DB_NAME of the source database.

COMPATIBLE

Same as the compatible setting of the source database.

DB_UNIQUE_NAME

Generated unique value based on DB_NAME.

DB_BLOCK_SIZE

Same as the DB_BLOCK_SIZE of the source database.

DB_FILES

Same value as DB_FILES for the source database

SGA_TARGET

280M recommended value.

DB_CREATE_FILE_DEST

Auxiliary destination (only if the AUXILIARY DESTINATION argument to TRANSPORT TABLESPACE is set). RMAN creates Oracle managed control files and online logs in this location.

  1. Setting the Location of the Auxiliary Instance Parameter File

默认RMAN会到?/rdbms/admin/params_auxint.ora找auxiliary initialization parameter file,如果未找到也并不会报错,你也可手动指定位置

To specify a different location for the auxiliary instance parameter file, you can use the RMAN SET AUXILIARY INSTANCE PARAMETER FILE command in a RUN block before the TRANSPORT TABLESPACE command. As with the default location of the auxiliary instance parameter file, the path specified when using the SET AUXILIARY INSTANCE PARAMETER FILE command is a client-side path.

Example 27-1 Specifying an Auxiliary Instance Parameter File

RUN {

  SET AUXILIARY INSTANCE PARAMETER FILE TO '/tmp/auxinstparams.ora';

  TRANSPORT TABLESPACE tbs_2

    TABLESPACE DESTINATION '/disk1/transportdest'

    AUXILIARY DESTINATION '/disk1/auxdest';

}

Creating a Transportable Tablespace Set

To create a transportable tablespace set:

  1. Start the RMAN client and connect to the source database and, if used, the recovery catalog database.
  2. Run the TRANSPORT TABLESPACE command in RMAN.

In the most basic case, you specify an AUXILIARY DESTINATION clause, which is optional but recommended. RMAN uses default values that work for most cases. If you do not specify an auxiliary location, then ensure that locations are specified for all auxiliary instance files.

TRANSPORT TABLESPACE tbs_2, tbs_3

   TABLESPACE DESTINATION '/disk1/transportdest'

   AUXILIARY DESTINATION '/disk1/auxdest';

After the command completes successfully, note the following results:

The transportable set data files are left in the location /disk1/transportdest with their original names. The transportable tablespace set data files are not automatically converted to the endian format of the destination database by TRANSPORT TABLESPACE. If necessary, use the RMAN CONVERT command to convert the data files to the endian format of the destination database after creating the transportable set.

The Data Pump export dump file for the transportable set is named dmpfile.dmp, the export log is named explog.log, and the sample import script is named impscrpt.sql.

如果导出文件名在tablespace destination中已存在则TRANSPORT TABLESPACE将会报错中止The auxiliary set files are removed from /disk1/auxdest.

  1. If necessary, edit the sample import script.

The sample import script assumes that the files used to import the tablespaces into the destination database are stored in the same locations where they were created by TRANSPORT TABLESPACE. If files have been moved to new disk locations before being plugged in, then you must update the sample script with the new locations of the files before using the script to plug in the transported tablespaces.

Transportable Tablespace Set Scenarios

1. Creating a Transportable Tablespace Set at a Specified Time or SCN

Example 27-2 Specifying an End SCN

TRANSPORT TABLESPACE tbs_2

   TABLESPACE DESTINATION '/disk1/transportdest'

   AUXILIARY DESTINATION '/disk1/auxdest'

   UNTIL SCN 11379;

Example 27-3 Specifying an End Restore Point

TRANSPORT TABLESPACE tbs_2

   TABLESPACE DESTINATION '/disk1/transportdest'

   AUXILIARY DESTINATION '/disk1/auxdest'

   TO RESTORE POINT 'before_upgrade';

Example 27-4 Specifying an End Time

TRANSPORT TABLESPACE tbs_2

   TABLESPACE DESTINATION '/disk1/transportdest'

   AUXILIARY DESTINATION '/disk1/auxdest'

   UNTIL TIME 'SYSDATE-1';

2. Specifying Locations for Data Pump Files

You can place the dump file and the export log in a different directory by using the DATAPUMP DIRECTORY clause of the TRANSPORT TABLESPACE command, passing in the name of a database directory object.

DATAPUMP DIRECTORY选项同DATATUMP中DIRECTORY,表示数据库中的目录

The database directory object used by the DATAPUMP DIRECTORY clause is not the directory path of an actual file system directory. The value passed corresponds to the DIRECTORY command-line argument of Data Pump Export.

CREATE OR REPLACE DIRECTORY mypumpdir as '/datapumpdest';

You can rename these files with the DUMP FILEEXPORT LOG, and IMPORT SCRIPT clauses of TRANSPORT TABLESPACE. The file names cannot contain full file paths with directory names.

Example 27-5 Specifying Output File Locations

TRANSPORT TABLESPACE tbs_2

   TABLESPACE DESTINATION '/transportdest'

   AUXILIARY DESTINATION '/auxdest'

   DATAPUMP DIRECTORY  mypumpdir

   DUMP FILE 'mydumpfile.dmp'

   IMPORT SCRIPT 'myimportscript.sql'

   EXPORT LOG 'myexportlog.log';

  1. Specifying Auxiliary File Locations with Transportable Tablespaces

Several rules are applicable to the location of auxiliary instance files created during the transport.

The simplest technique is to use the AUXILIARY DESTINATION clause of the TRANSPORT TABLESPACE command and let RMAN manage all file locations automatically.

The following table lists the techniques available for specifying file locations when relocating some or all auxiliary instance files, in the order of precedence that RMAN uses:

Table 27-2 Options for specifying auxiliary file locations

Order of Precedence

Auxiliary File Naming Technique

1

SET NEWNAME FOR DATAFILES

SET NEWNAME FOR TABLESPACE

SET NEWNAME FOR DATABASE

2

CONFIGURE AUXNAME

3

AUXILIARY DESTINATION clause of the TRANSPORT TABLESPACE command

4

LOG_FILE_NAME_CONVERT and DB_FILE_NAME_CONVERT in the initialization parameter file

使用上面任一种方法指定auxiliary file位置,如果此位置有相应的data file copy则会直接用来恢复而不再RESTORE;如果data file copy不适合恢复则会被restore覆盖

If RMAN determines that any of the auxiliary files, designated by any of the methods for specifying auxiliary file locations, contain a data file copy that is suitable to be used for the desired point in time for this transport operation, then that data file copy is used instead of restoring the data file.

Any data file copies that are present, but not suitable for this transport operation, because they are more recent than the requested point in time, or are not recognized as part of the target database, are overwritten when the data files are restored.

  1. Using SET NEWNAME for Auxiliary Data Files

You can use the following SET NEWNAME commands in a RUN block to specify file names for use in the TRANSPORT TABLESPACE command:

SET NEWNAME FOR DATAFILE

SET NEWNAME FOR DATABASE

SET NEWNAME FOR TABLESPACE

Example 27-6 Using SET NEWNAME FOR DATAFILE to Name Auxiliary Data Files

RUN

{

  SET NEWNAME FOR DATAFILE '/oracle/dbs/tbs_12.f'

    TO '/bigdrive/auxdest/tbs_12.f';

  SET NEWNAME FOR DATAFILE '/oracle/dbs/tbs_11.f'

    TO '/bigdrive/auxdest/tbs_11.f';

  TRANSPORT TABLESPACE tbs_2

    TABLESPACE DESTINATION '/disk1/transportdest'

    AUXILIARY DESTINATION '/disk1/auxdest';

}

  1. Using CONFIGURE AUXNAME for Auxiliary Data Files

You can use the CONFIGURE AUXNAME command to specify persistent locations for transportable tablespace set or auxiliary set data files.

You use the CONFIGURE AUXNAME statement to set a persistent nondefault location for the auxiliary set data file /oracle/dbs/tbs_12.f.

CONFIGURE AUXNAME FOR DATAFILE '/oracle/dbs/tbs_12.f' TO '/disk1/auxdest/tbs_12.f';

You execute the TRANSPORT TABLESPACE command with the AUXILIARY DESTINATION and TABLESPACE DESTINATION parameters.

TRANSPORT TABLESPACE tbs_11

  AUXILIARY DESTINATION '/myauxdest'

  TABLESPACE DESTINATION '/disk1/transportdest';

In the preceding scenario, RMAN restores the auxiliary set copy of data file /oracle/dbs/tbs_12.f to /disk1/auxdest/tbs_12.f instead of the location specified by AUXILIARY DESTINATION.

Note: You can view any current CONFIGURE AUXNAME settings by executing the SHOW AUXNAME 

  1. Using AUXILIARY DESTINATION to Specify a Location for Auxiliary Files

如果未使用AUXILIARY DESTINATION,则一定要指定LOG_FILE_NAME_CONVERT,因为SET NEWNAME与CONFIGURE AUXNAME均不能影响redo logs

If you do not use AUXILIARY DESTINATION, then you must use LOG_FILE_NAME_CONVERT to specify the location of the online redo log files for the auxiliary instance. Neither SET NEWNAME nor CONFIGURE AUXNAME can affect the location of the auxiliary instance online redo logs.

  1. Using Initialization Parameters to Name Auxiliary Files

You can use the LOG_FILE_NAME_CONVERT and DB_FILE_NAME_CONVERT initialization parameters in an auxiliary instance parameter file to determine the names for online redo logs and other database files at the auxiliary instance.

You cannot use LOG_FILE_NAME_CONVERT or DB_FILE_NAME_CONVERT to generate new Oracle Managed Files (OMF) names for files at the auxiliary instance when the original files are OMF files. You must use an AUXILIARY DESTINATION clause to control the location of the online redo log files. You must use the AUXILIARY DESTINATION clause, SET NEWNAME or CONFIGURE AUXNAME commands, or DB_CREATE_FILE_DEST initialization parameter to specify the location for OMF data files.

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值