Alternative Names for Duplicate Database Files

When you duplicate a database to the local host, you must store the duplicate database files using a directory structure that is different from that of the source database.

When you duplicate a database to a remote host, the duplicate database files can either use the same directory structure and file names as the source database or use a different directory structure and file names.

Depending on the destination host used and your duplication scenario, the duplicate database files can either use the same names as the source database or different names. The database files include the data file, control files, online redo log files, and temp files.

(一)Using Same Names

使用相同目录结构与文件名意味着必须满足以下前提

Using the same directory structure and file names means that your environment meets the following requirements:

  1. If the source database uses ASM disk groups, then the duplicate database must use ASM disk groups with the same names.
  2. If the source database files are Oracle Managed Files, then the auxiliary instance must set DB_CREATE_FILE_DEST to the same directory location as the source database. Although the directories are the same on the source and destination hosts, Oracle Database chooses the relative names for the duplicate files.
  3. If the names of the database files in the source database contain a path, then this path name must be the same in the duplicate database.
  4. For Oracle Real Application Clusters (RAC) environments, use the same ORACLE_SID for the source and destination databases.

关于NOFILENAMECHECK选项

AUXILIARY INSTANE使用与源库相同磁盘、目录及文件名时,需要DUPLICATE命令使用NOFILENAMECHECK选项,默认会进行文件检测以确保不会覆盖源库使用的文件

Prevents RMAN from checking whether the data files and online redo logs files of the source database are in use when the source database files share the same names as the duplicate database files. You are responsible for determining that the duplicate operation does not overwrite useful data.This option is necessary when you are creating a duplicate database in a different host that has the same disk configuration, directory structure, and file names as the host of the source database.

Because RMAN is not aware of the different hosts, RMAN cannot determine automatically that it need not check the file names. In this case, specify the NOFILENAMECHECK option to avoid an error message.

Note: If duplicating a database on the same host as the source database, then ensure that NOFILENAMECHECK is not set. Otherwise, RMAN can potentially overwrite and corrupt the target database data files, temp files, or online logs. It may also signal the following error:

RMAN-10035: exception raised in RPC: ORA-19504: failed to create file "/oracle/dbs/tbs_01.f"

ORA-27086: skgfglk: unable to lock file - already in use

SVR4 Error: 11: Resource temporarily unavailable

Additional information: 8

RMAN-10031: ORA-19624 occurred during call to DBMS_BACKUP_RESTORE.RESTOREBACKUPPIECE

(二)Methods and Order of Alternative Names

以下为更改文件名或路径名方法(按顺序生效)

Use one of the following methods, listed in the order of precedence, to generate file names for the duplicate database:

  1. SET NEWNAME command

For OMF and ASM database files, you must use SET NEWNAME...TO NEW and not explicitly provide names for the database files. 

  1. CONFIGURE AUXNAME command

Specifies non-OMF and non-ASM alternative names for duplicate database files.

  1. SPFILE clause of the DUPLICATE command

使用DUPLICATE的SPFILE SET选项,SPFILE表示不使用auxiliary instance的spfile而是从源库端复制过来,SET是在复制的SPFILE基本上自定义参数

SPFILECopies the server parameter file from the source database to the duplicate database. No initialization parameters previously set in the duplicate database are used.

SET:Sets the specified initialization parameters to the specified values. This SET functionality is equivalent to pausing the duplication after restoring the server parameter file and issuing ALTER SYSTEM SET statements to change the initialization parameter file.

Note: RMAN processes SET after PARAMETER_VALUE_CONVERT. If PARAMETER_VALUE_CONVERT sets the file name specified by a parameter, and if SET sets the file name specified by the same parameter, then the SET value overrides the PARAMETER_VALUE_CONVERT setting.

PARAMETER_VALUE_CONVERT :Replaces the first string with the second string in all matching initialization parameter values.

Note: If DB_FILE_NAME_CONVERT is specified on the DUPLICATE command, then its file name settings override competing settings specified by SPFILE SET.

Example:

DUPLICATE TARGET DATABASE

  FOR STANDBY

  FROM ACTIVE DATABASE

  PASSWORD FILE

  SPFILE

    PARAMETER_VALUE_CONVERT '/disk1', '/disk2'

    SET DB_FILE_NAME_CONVERT '/disk1','/disk2'

    SET LOG_FILE_NAME_CONVERT '/disk1','/disk2'

    SET DB_UNIQUE_NAME 'dup1'

    SET SGA_MAX_SIZE 200M

    SET SGA_TARGET 125M;

  1. (Online redo log files only) LOGFILE clause of the DUPLICATE command

Names online redo log files in the duplicate database. You cannot use this method while creating a standby database.

自定义REDO LOG GROUP,不指定则与源库配置相同,示例:

DUPLICATE TARGET DATABASE TO dupdb

  LOGFILE    

     GROUP 1 ('/duplogs/redo01a.log','/duplogs/redo01b.log') SIZE 4M REUSE,

     GROUP 2 ('/duplogs/redo02a.log', '/duplogs/redo02b.log') SIZE 4M REUSE;

Note: When duplicating to the local host or to a remote host without the NOFILENAMECHECK clause, ensure that you do not use the name of an online redo log file that is currently in use by the source database.

  1. DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT initialization parameters

When you use DB_FILE_NAME_CONVERT for ASM file names, only disk group name changes must be performed.

You cannot use this method to specify alternative names for duplicate database files if the source database uses Oracle Managed Files.

  1. DB_CREATE_FILE_DEST and DB_CREATE_ONLINE_LOG_DEST_n parameters

Creates Oracle Managed Files at the location specified by these parameters. This is the recommended method to specify alternative names for OMF and ASM.

  1. Generating Names for Control Files in the Duplicate Database

Use one of the following techniques, listed in the order of precedence, to specify the location of the duplicate database control files:

  1. Set the CONTROL_FILES initialization parameter in the auxiliary instance's initialization parameter file.
  2. Create an OMF-based control file in a location which is determined by setting one of the following parameters:

DB_CREATE_ONLINE_LOG_DEST_n

DB_CREATE_FILE_DEST

DB_RECOVERY_FILE_DEST

If more than one of these parameters is set, then the order of precedence used is the order in which these parameters are listed.

说明:如果AUXILIARY INSTANCE使用的是一般文件系统一般使用SET NETNAME FOR或CONFIGURE AUXNAME;如果使用的是OMF/ASM则一般使用初始参数DB_CREATE_FILE_DEST以及DB_CREATE_ONLINE_LOG_DEST_n

DB_FILE_NAME_CONVERT及LOG_FILE_NAME_CONVERT不能在源库使用OMF时使用

(二)Specifying Non-OMF or Non-ASM Alternative Names

  1. Using SET NEWNAME to Name File System Data Files and Temp Files

Table 26-1 Substitution Variables for SET NEWNAME

Variable

Description

%b

Specifies the file name stripped of directory paths. For example, if a data file is named /oradata/prod/financial.dbf, then %b results in financial.dbf.

%f

Specifies the absolute file number of the data file for which the new name is generated. For example, if data file 2 is duplicated, then %f generates the value 2.

%I

Specifies the DBID.

%N

Specifies the tablespace name.

%U

Specifies the following format: data-D-%d_id-%I_TS-%N_FNO-%f

Note: For OMF and ASM database files, you must use SET NEWNAME...TO NEW and not explicitly provide names for the database files. 

RMAN supports the following commands, listed in order of precedence:

  1. SET NEWNAME FOR DATAFILE and SET NEWNAME FOR TEMPFILE
  2. SET NEWNAME FOR TABLESPACE
  3. SET NEWNAME FOR DATABASE

When using SET NEWNAME FOR DATAFILE, you can specify a full path as a literal, as in /oradata1/system01.dbf. When using SET with FOR DATABASE or FOR TABLESPACE, however, you must use at least one of these substitution variables described in Table 26-1: %b, %f, %U. (%I and %N are optional.).

Example 26-1 Duplicating with SET NEWNAME FOR DATAFILE

RUN

{

SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';

SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';

SET NEWNAME FOR DATAFILE 3 TO '/oradata3/undotbs01.dbf';

SET NEWNAME FOR DATAFILE 4 TO '/oradata4/users01.dbf';

SET NEWNAME FOR DATAFILE 5 TO '/oradata5/users02.dbf';

SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01.dbf';

DUPLICATE TARGET DATABASE TO dupdb

  SKIP TABLESPACE tools

  LOGFILE   

     GROUP 1 ('/duplogs/redo01a.log','/duplogs/redo01b.log') SIZE 4M REUSE,

     GROUP 2 ('/duplogs/redo02a.log', '/duplogs/redo02b.log') SIZE 4M REUSE;

}

Example 26-2 Duplicating with SET NEWNAME FOR DATAFILE and FOR TABLESPACE

{

SET NEWNAME FOR TABLESPACE users TO '/oradata%f/%b';

SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';

SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';

SET NEWNAME FOR DATAFILE 3 TO '/oradata3/undotbs01.dbf';

SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01.dbf';

DUPLICATE TARGET DATABASE TO dupdb

SKIP TABLESPACE tools

LOGFILE

   GROUP 1 ('/duplogs/redo01a.log','/duplogs/redo01b.log') SIZE 4M REUSE,

   GROUP 2 ('/duplogs/redo02a.log','/duplogs/redo02b.log') SIZE 4M REUSE;

}

Example 26-3 Duplicating with SET NEWNAME FOR DATABASE

RUN

{

SET NEWNAME FOR DATABASE TO '/oradata/%U';

DUPLICATE TARGET DATABASE TO dupdb

  SKIP TABLESPACE tools

  LOGFILE

    GROUP 1 ('/duplogs/redo01a.log','/duplogs/redo01b.log') SIZE 4M REUSE,

    GROUP 2 ('/duplogs/redo02a.log','/duplogs/redo02b.log') SIZE 4M REUSE;

}

The following table shows the results from this example.

Before SET NEWNAME DATABASE

Tablespace Name

Data File Number

After SET NEWNAME DATABASE TO '/oradata/%U';

.../system01.dbf

SYSTEM

1

/oradata/data-D-PROD_id-87650928_TS-SYSTEM_FNO-1

.../sysaux01.dbf

SYSAUX

2

/oradata/data-D-PROD_id-87650928_TS-SYSAUX_FNO-2

.../undotbs01.dbf

UNDOTS

3

/oradata/data-D-PROD_id-87650928_TS-UNDOTS_FNO-3

.../users01.dbf

USERS

4

/oradata/data-D-PROD_id-87650928_TS-USERS_FNO-4

.../users02.dbf

USERS

5

/oradata/data-D-PROD_id-87650928_TS-USERS_FNO-5

.../temp01.dbf

TEMP

1

/oradata/data-D-PROD_id-87650928_TS-TEMP_FNO-1

  1. Using CONFIGURE AUXNAME to Name File System Data Files

Specifies non-OMF and non-ASM alternative names for duplicate database files.

To use CONFIGURE AUXNAME to specify names for duplicate data files:

  1. Issue a CONFIGURE AUXNAME command for each file to name in the duplicate database.

CONFIGURE AUXNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';

CONFIGURE AUXNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';

CONFIGURE AUXNAME FOR DATAFILE 3 TO '/oradata3/undotbs01.dbf';

CONFIGURE AUXNAME FOR DATAFILE 4 TO '/oradata4/users01.dbf';

CONFIGURE AUXNAME FOR DATAFILE 5 TO '/oradata5/users02.dbf';

NOTE: CONFIGURE AUXNAME不支持TEMPFILE  

清配置命令:CONFIGURE AUXNAME FOR DATAFILE n CLEAR;

查看:SHOW AUXNAME;

  1. Issue a DUPLICATE command.

SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01.dbf';

DUPLICATE TARGET DATABASE

  TO dupdb

  SKIP TABLESPACE tools

  LOGFILE

     GROUP 1 ('/duplogs/redo01a.log','/duplogs/redo01b.log') SIZE 4M REUSE,

     GROUP 2 ('/duplogs/redo02a.log','/duplogs/redo02b.log') SIZE 4M REUSE;

(三)Specifying OMF or ASM Alternative Names

本章为auxiliary instance使用OMF或ASM

  1. Initialization Parameters for OMF and ASM

1.1 Settings and Restrictions for OMF Initialization Parameters

When creating a duplicate database that uses Oracle Managed Files, you must set initialization parameters in the auxiliary instance. If you use the SPFILE clause of DUPLICATE to name the files, then you can set initialization parameters in the SPFILE clause:

1) DB_CREATE_FILE_DEST

Specifies the default location for Oracle managed data files. This location is also the default location for Oracle managed control files and online logs if no DB_CREATE_ONLINE_LOG_DEST initialization parameters are specified.

Any database files for which no other location is specified are created in DB_CREATE_FILE_DEST by DUPLICATE. You can override the default for specific files using SET NEWNAME.

2) DB_CREATE_ONLINE_LOG_DEST_n

Specifies the default location for Oracle managed control files and online redo logs. If multiple parameters are set, then one control file and one online redo log is created in each location.

Set these parameters (_1, _2, and so on) only if you want to multiplex the control files and online redo log files in multiple locations.

  1. DB_RECOVERY_FILE_DEST

Specifies the default location for the fast recovery area. The fast recovery area contains multiplexed copies of current control files and online redo log files.

Set this parameter if you want a multiplexed copy of the control file and online redo log file in the recovery area.

同时你不能配置以下参数:

1) CONTROL_FILES

Do not set this parameter if you want the duplicate database control files in an OMF format. Oracle recommends that you use a server parameter file at the duplicate database when using control files in an OMF format.

  1. DB_FILE_NAME_CONVERT

Do not set this parameter. Omitting this parameter enables the database to generate valid Oracle managed file names for the duplicate data files.

3) LOG_FILE_NAME_CONVERT

Do not set this parameter. Omitting this parameter allows the database to generate valid Oracle managed online redo log file names. To direct duplicate database online redo log files to Oracle managed storage, you can use the DB_CREATE_FILE_DEST, DB_RECOVERY_FILE_DEST, or DB_CREATE_ONLINE_LOG_DEST_n initialization parameters to identify an Oracle managed location for the online logs.

1.2 Setting Initialization Parameters for ASM

The procedure for creating a duplicate database to an ASM location is similar to the procedure described in Settings and Restrictions for OMF Initialization Parameters. The difference is that you must identify the initialization parameters that control the location where files are created and set these parameters to an ASM disk group. For example, set DB_CREATE_FILE_DESTDB_CREATE_ONLINE_DEST_n, and CONTROL_FILES to +DISK1.

  1. Duplicating Databases to ASM Using PARAMETER_VALUE_CONVERT

Example 26-4 Duplicating a Database from a File System to ASM

Assume that the source database prod is on host1 and stores its data files in a non-ASM file system. The control files for prod are located in /oracle/oradata/prod/. You want to duplicate the source database to database dupdb on remote host host2. You want to store the duplicate database files in ASM disk group +DISK1.

DUPLICATE TARGET DATABASE TO dupdb

FROM ACTIVE DATABASE

SPFILE

PARAMETER_VALUE_CONVERT '/oracle/oradata/prod/', '+DISK1'

SET DB_CREATE_FILE_DEST +DISK1;

Example 26-5 Duplicating a Database from ASM to ASM

Assume that the source database prod is on host1 and stores its data files in ASM disk group +DISK1. You want to duplicate the target to database dupdb on remote host host2. You want to store the data files for dupdb in ASM. Specifically, you want to store the data files and control files in disk group +DISK2.

The new file names in +DISK2 are generated by ASM and do not match the original file names in disk group +DISK1.

DUPLICATE TARGET DATABASE

TO dupdb

FROM ACTIVE DATABASE

SPFILE

PARAMETER_VALUE_CONVERT '+DISK1','+DISK2'

SET DB_RECOVERY_FILE_DEST_SIZE='750G';

  1. Using SET NEWNAME to Create OMF or ASM Files

To name Oracle managed data files, you can use the same SET NEWNAME commands, but with TO NEW instead of TO 'filename'. RMAN creates the specified data files or temp files with Oracle Managed File names in the location specified by DB_CREATE_FILE_DEST.

Example 26-6 Duplicating with SET NEWNAME FOR DATAFILE and FOR TABLESPACE

This example illustrates a script that specifies literal names for data files 1-5. The only Oracle Managed Files in the source database are the data files in the users tablespace. Therefore, TO NEW is specified in the SET NEWNAME command for these files.

RUN

{

SET NEWNAME FOR TABLESPACE users TO NEW;

SET NEWNAME FOR DATAFILE 3 TO NEW;

SET NEWNAME FOR DATAFILE 1 TO '/oradata1/system01.dbf';

SET NEWNAME FOR DATAFILE 2 TO '/oradata2/sysaux01.dbf';

SET NEWNAME FOR TEMPFILE 1 TO '/oradatat/temp01';

DUPLICATE TARGET DATABASE TO dupdb

  SKIP TABLESPACE tools

  LOGFILE

    GROUP 1 ('/duplogs/redo01a.log','/duplogs/redo01b.log') SIZE 4M REUSE,

    GROUP 2 ('/duplogs/redo02a.log','/duplogs/redo02b.log') SIZE 4M REUSE;

}

Example 26-7 Using SET NEWNAME to Create Files in an ASM Disk Group

This example uses SET NEWNAME to direct individual data files, temp files, or tablespaces to a specified ASM disk group.

RUN

{

SET NEWNAME FOR DATAFILE 1 TO "+DGROUP1";

SET NEWNAME FOR DATAFILE 2 TO "+DGROUP2";

.

.

.

DUPLICATE TARGET DATABASE

TO dupdb

FROM ACTIVE DATABASE

SPFILE SET DB_CREATE_FILE_DEST +DGROUP3;

}

  1. Using DB_FILE_NAME_CONVERT

DB_FILE_NAME_CONVERT allows you to specify multiple conversion file name pairs. 

DB_FILE_NAME_CONVERT can also be used to produce names for data files and temp files.

You can specify DB_FILE_NAME_CONVERT in the DUPLICATE command or you can set it in the initialization parameter of the auxiliary instance.

Restrictions of DB_FILE_NAME_CONVERT:

You cannot use the DB_FILE_NAME_CONVERT clause of the DUPLICATE command to control generation of new names for files at the duplicate instance that are in the Oracle Managed Files (OMF) format at the source database instance. See Oracle Database Backup and Recovery Reference for details on this restriction.

EXAMPLE:

Db_file_name_convert与log_file_name_convert为字符串替代,它不会判断字符串代表意义

target db path: /u01/database/sybo3, auxiliary db path: /u01/database/sybo5 :

db_file_name_convert =('sybo3','sybo5')  

log_file_name_convert =('sybo3','sybo5')  

  1. Using LOG_FILE_NAME_CONVERT

If the LOG_FILE clause has been omitted and no Oracle Managed Files initialization parameters DB_CREATE_FILE_DEST, DB_CREATE_ONLINE_DEST_n, or DB_RECOVERY_FILE_DEST are specified, then LOG_FILE_NAME_CONVERT can transforms target file names.

This works in much the same way as the DB_FILE_NAME_CONVERT and can transform target file names from log_* to duplog_*. You can specify multiple conversion file name pairs with this parameter.

When you specify LOG_FILE_NAME_CONVERT, RMAN uses the REUSE parameter when creating the online redo logs. If an online redo log file exists at the named location and is of the correct size, then it is reused for the duplicate.

Restrictions of LOG_FILE_NAME_CONVERT:

Do not specify LOG_FILE_NAME_CONVERT if you set Oracle Managed Files initialization parameters.

LOG_FILE_NAME_CONVERT cannot be specified as a DUPLICATE clause, it can only be specified in the initialization parameter of the auxiliary instance.

You cannot use the LOG_FILE_NAME_CONVERT initialization parameter to control generation of new names for files at the duplicate instance that are in the Oracle Managed Files (OMF) format at the source database instance.

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值