认识duplicate命令

本文介绍了Oracle的duplicate命令,该命令用于实现数据库级别的复制和创建物理Data Guard(DG)。通过简单的命令行语法,duplicate将复杂的复制脚本封装起来,方便进行数据库复制和维护物理DG。

摘要生成于 C知道 ,由 DeepSeek-R1 满血版支持, 前往体验 >

duplicate命令调用非常简单。oracle将实现数据库级复制的大量脚本都进行了封装。

只要准备工作充分,只需要简单的执行一条语句。
除了穿件副本数据库之外,还能用来创建物理standby数据库。

 

 

可以看到duplicate的两个用途的命令:

duplicate target database for standby;
duplicate target database to new_database;


duplicate 命令虽然参数众多,但是语法简单,并且大多数参数不是必选的。而是为了提高复制数据库时的灵活性。增强其功能。
 
 
 
 
 
 

 
 

Syntax ElementDescription
FOR STANDBYSpecifies that database being duplicated is to be used as a standby database. RMAN restores the most recent files, unless SET UNTIL is specified. If DORECOVER is specified, then RMAN also recovers database. RMAN always leaves standby database in mounted state after executing DUPLICATE command.
dupsbyOptionListSpecifies options that only apply when creating a standby database.
DORECOVERSpecifies that RMAN should recover the database after creating it. If you specify anuntilClause, then RMAN recovers to the specified point and leaves the database mounted.
NOFILENAMECHECKPrevents RMAN from checking whether target datafiles sharing the same names as the duplicated files are in use. Note that the NOFILENAMECHECK option is required when the standby and primary datafiles and logs have identical filenames.

See Also: The description in dupOptionList

TO 'database_name'Specifies the name of the duplicate database. The name should match the name in the initialization parameter file of the duplicate database or the database signals an error when creating the control file.

 

 

 

 

dupOptionList

Syntax ElementDescription
dupOptionListSpecifies options that apply when creating a duplicate database not intended for use as a standby database.
DEVICE TYPE deviceSpecifierAllocates automatic channels for the specificdeviceSpecifier only (for example, DISK or sbt). This option is valid only if you have configured automatic channels and have not manually allocated channels. For example, if youCONFIGURE automatic disk and tape channels, and if you run DUPLICATE...DEVICE TYPE DISK, then RMAN allocates only disk channels.

See Also: "deviceSpecifier"

fileNameConversionSpecSpecifies one or more patterns to map original to duplicate filenames.

Note that this parameter overrides the initialization parameter DB_FILE_NAME_CONVERT (if it is set). If a file in the specification list is not affected by the conversion parameter in DUPLICATE, then you must rename it by other means, such as SET NEWNAME.

See Also: "fileNameConversionSpec"

LOGFILE logSpecSpecifies the online redo logs when creating a nonstandby duplicate database. The syntax is the same used in the LOGFILE option of the CREATE DATABASE statement.

Refer to the description of logSpec for the legal options.

NOFILENAMECHECKPrevents RMAN from checking whether target datafiles sharing the same names as the duplicated files are in use. The user is responsible for determining that the duplicate operation will 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 filenames as the host of the target database. For example, assume that you have a small database located in the /dbs directory of host1:

/oracle/dbs/system_prod1.dbf
/oracle/dbs/users_prod1.dbf
/oracle/dbs/tools_prod1.dbf
/oracle/dbs/rbs_prod1.dbf

Assume that you want to duplicate the database in machine host2, which has the same file system /oracle/dbs/*, and you want to use the same filenames in the duplicate database as in the primary. In this case, specify the NOFILENAMECHECK option to avoid an error message. Because RMAN is not aware of the different hosts, RMAN cannot determine automatically that it should not check the filenames.

OPEN RESTRICTEDEnables a restricted session in the duplicate database by issuing the following SQL statement: ALTER SYSTEM ENABLE RESTRICTED SESSION. RMAN issues this statement immediately before the duplicate database is opened.
PFILE = 'filename'Specifies a client-side initialization parameter used by the auxiliary instance. RMAN automatically shuts down and restarts the auxiliary instance during duplication. If the auxiliary does not use a server-side parameter file in the default location, you must specify the client-side parameter file that RMAN should use when starting the auxiliary instance. Otherwise, you do not need to specify PFILE.
SKIP READONLYExcludes datafiles in read-only tablespaces from the duplicate database.

Note: A record for the skipped read-only tablespace still appears in DBA_TABLESPACES. By using this feature, you can activate the read-only tablespace later. For example, you can store the read-only tablespace data on a CD-ROM, then mount the CD-ROM later and view the data.

SKIP TABLESPACE 'tablespace_name'Excludes the specified tablespace from the duplicate database. Note that you cannot exclude the SYSTEM tablespace, undo tablespaces, and tablespaces with rollback segments.
untilClauseSets the end point for incomplete recovery of the duplicate database. You can achieve the same result by runningSET UNTIL before the DUPLICATE command.

See Also: "untilClause"


 

 

 

logSpec

Syntax ElementDescription
logSpecSpecifies the online redo logs when creating a nonstandby duplicate database. If you do not specify LOGFILE, then RMAN uses LOG_FILE_NAME_CONVERT if it is set. If neither LOGFILE nor LOG_FILE_NAME_CONVERT is set, then RMAN uses the original target log filenames for the duplicate files. You must specify the NOFILENAMECHECK option in this case.

See Also: Oracle Database SQL Reference for CREATE DATABASE syntax

'filename' SIZE integerSpecifies the filename of the online redo log member and the size of the file in kilobytes (K) or megabytes (M). The default is in bytes.
REUSEAllows the database to reuse an existing file. If the file already exists, then the database verifies that its size matches the value of the SIZE parameter. If the file does not exist, then it is created.
GROUP integerSpecifies the group containing the online redo log members.

 

 例如:

RUN
  ALLOCATE AUXILIARY CHANNEL newdb1 DEVICE TYPE sbt;
  DUPLICATE TARGET DATABASE TO newdb
    DB_FILE_NAME_CONVERT=('/h1/oracle/dbs/trgt/','/h2/oracle/oradata/newdb/')
    UNTIL TIME 'SYSDATE-1'  # specifies incomplete recovery
    SKIP TABLESPACE cmwlite, drsys, example   # skip desired tablespaces
    PFILE = ?/dbs/initNEWDB.ora
    lOGFILE
      GROUP 1 ('?/oradata/newdb/redo01_1.f',  '?/oradata/newdb/redo01_2.f') SIZE 200K,
      GROUP 2 ('?/oradata/newdb/redo02_1.f',  '?/oradata/newdb/redo02_2.f') SIZE 200K,
      GROUP 3 ('?/oradata/newdb/redo03_1.f',  '?/oradata/newdb/redo03_2.f') SIZE 200K REUSE;
}

参考文档:
涂抹oracle第15章:duplicate复制数据库.
官方文档

 

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值