Overview of RMAN Database Duplication

Database duplication is the use of the DUPLICATE command to copy all or a subset of the data in a source database

使用duplicate实质是数据库的时间点恢复

RMAN must perform database point-in-time recovery, even when no explicit point in time is provided for duplication. Point-in-time recovery is required because the online redo log files in the source database are not backed up and cannot be applied to the duplicate database. The farthest point of recovery of the duplicate database is the most recent redo log file archived by the source database.

复制库与源库有不同DBID

RMAN assigns a new DBID to the duplicate database (except when a standby database is created, in which case the source DBID is retained). You can then register the duplicate database in the same recovery catalog as the source database.

If you copy a database with operating system utilities rather than the DUPLICATE command, then the DBID of the copied database remains the same as the original database. To register the copied database in the same recovery catalog with the original, you must change the DBID with the DBNEWID utility (see Oracle Database Utilities).

You can perform the following tasks in a duplicate database:

Test backup and recovery procedures

Test an upgrade to a new release of Oracle Database

Test the effect of applications on database performance

Create a standby database

Generate reports

source host and source database 即源库

Destination host、duplicate database and auxiliary instance 即目标库

Types of Database Duplication

  1. Backup-Based Duplication

In backup-based duplication, preexisting RMAN backups of the source database are used to create the duplicate database. A combination of full and incremental backups can be used. RMAN determines which backups and archived redo log files must be used based on the UNTIL condition.

It is not required that all of the backups be from the same point in time, or that they all be backup sets, or all image copies. Data file backups can be supplied as either image copies or backup sets. Archived logs can be supplied either in their normal format or as backup sets of archived logs.

In backup-based duplication, the primary work of duplicating the database is performed by auxiliary channels. 

Use one of the following mutually-exclusive techniques to perform backup-based duplication:

  1. Backup-Based Duplication with a Target Connection

you must connect as TARGET to the source database and as AUXILIARY to the auxiliary instance.

You may connect to a recovery catalog but it is not mandatory (not in figure). RMAN uses the metadata in the control file of the source database to determine which backups or copies must be used to perform the duplication.

If RMAN is connected to the source database as TARGET, then the source database must be in the proper state for the duplication.

To ensure that the source database is in the proper state:

  1. If the source database instance is not mounted or open, then mount or open it.
  2. If you are performing active database duplication, then ensure that the following additional requirements are met:

If the source database is open, then archiving must be enabled.

If the source database is not open, then the database does not require instance recovery.

Duplicate database必须可访问到RMAN备份

The destination host must have access to the RMAN backups that are required to create the duplicate database.

  1. Backup-Based Duplication Without a Target Connection

you connect as CATALOG to the recovery catalog database and as AUXILIARY to the auxiliary instance. The destination host must have access to the RMAN backups required to create the duplicate database.

  1. Backup-Based Duplication Without a Target Database and Recovery Catalog Connection

You perform duplication by connecting to the auxiliary instance and using backups or copies of the source database that are stored in a disk location on the destination host. RMAN obtains metadata about where the backups and copies reside from the BACKUP LOCATION clause of the DUPLICATE command.

Note: This method is not supported for backups that are stored on tape devices.

  1. Active Database Duplication

Active Database Duplication是通过网络把相关文件传输到 auxiliary instance,它不需要源库备份,可以以image copy或backupset两种形式传输

一般情况下Oracle都建议使用active database duplication

Active database duplication does not require backups of the source database. It duplicates the live source database to the destination host by copying the database files over the network to the auxiliary instance. RMAN can copy the required files as image copies or backup sets.

Oracle recommends that you use active database duplication in general, unless network bandwidth between the source host and the destination host is a constraint. Active database duplication requires minimal setup and is simpler to perform.

Note: For active database duplication, the source database must use a server parameter file.

  1. Active Database Duplication Using Image Copies

In this method, RMAN connects as TARGET to the source database and as AUXILIARY to the auxiliary instance. This method is referred to as the push-based method of active database duplication and the primary work is performed by the target channels.

Using image copies for active database duplication may require additional resources on the source database. You can configure additional target channels to improve the duplication performance

  1. Active Database Duplication Using Backup Sets

Using backup sets to perform active database duplication is also known as the pull-based method of active database duplication and the principal work of duplication is performed by the auxiliary channels. 

In this method, RMAN connects as TARGET to the source database and as AUXILIARY to the auxiliary instance. The auxiliary instance then connects to the source database through Oracle Net Services and retrieves the required database files, over the network, from the source database. 


Note: Performing active database duplication using backup sets is available starting Oracle Database 12c Release 1 (12.1).

Some of the scenarios in which active database duplication using backup sets may be preferred over using image copies are:

  1. You want to use multisection backups, compression, or encryption while duplicating your database.
  2. The source database does not have sufficient network resources to transfer the required database files to the duplicate database.
  3. You want to minimize the resources used by the duplication process.
  4. Active database duplication with backup sets uses minimal resources on the source database.

How RMAN Duplicates Works

1. RMAN Duplicate的内部实现过程

RMAN automates the following steps as part of performing database duplicating operation:

  1. Creates a default server parameter file for the auxiliary instance, if the following conditions are true:

Duplication does not involve a standby database

Server parameter files are not being duplicated

The auxiliary instance was not started with a server parameter file

  1. Restores from backup or copies from the active database the latest control file that satisfies the UNTIL clause requirements.
  2. Mounts the auxiliary instance using the restored control file or the backup control file copied from the active database.
  3. Uses metadata in the RMAN repository to select the backups that will be used to restore the data files to the auxiliary instance. This step applies to backup-based duplication.
  4. Copies the duplicate database files to the destination host and restores them to a noncurrent point in time using incremental backups and archived redo log files.
  5. Shuts down and restarts the auxiliary database instance on the destination host in NOMOUNT mode.
  6. Creates a new control file, which then creates and stores the new DBID in the data files.
  7. Opens the duplicate database with the RESETLOGS option and creates the online redo log for the new database.If you do not want to open the duplicate database, use the NOOPEN clause in the DUPLICATE statement .

2. RMAN Duplicate操作过程

A. Duplicating the Whole Database

To duplicate a database:

  1. Prepare the auxiliary instance that is used when creating the duplicate database.
  2. Start RMAN and connect to required databases.
  3. Place the source database in a proper state (if necessary).
  4. (Optional) Configure RMAN channels to improve duplication performance. Channels perform the primary task of duplicating the database. .
  5. Use the DUPLICATE command to duplicate the source database.

When you perform active database duplication, you can encrypt or compress the backup sets that are used to transfer files from the source database to the duplicate database. Additionally, you can create backup sets on the source database in parallel by using multisection backups.

  1. Duplicating a Subset of the Source Database Tablespaces

To duplicate some tablespaces in a database:

  1. Prepare the auxiliary instance that is used when creating the duplicate database.
  2. Start RMAN and connect to required databases
  3. Place the source database in a proper state (if necessary).
  4. (Optional) Configure RMAN channels to improve duplication performance. Channels perform the primary task of duplicating the database.
  5. Run the DUPLICATE command.

在指定或过滤表空间可使用选项:

  1. OFFLINE NORMAL: rman不会duplicate offline normal表空间

When tablespaces are taken offline with the OFFLINE NORMAL option before duplication, RMAN does not duplicate the associated data files, and issues DROP TABLESPACE statement for these tablespaces on the duplicate database. Therefore, you do not have to specify options to exclude these tablespaces.

Note: RMAN does duplicate tablespaces that are taken offline with any other option besides NORMAL (unless they are named in a SKIP TABLESPACE option). Only OFFLINE NORMAL tablespaces are skipped automatically. As with online tablespaces, RMAN requires a valid backup for these tablespaces when you use backup-based duplication.

  1. SKIP READONLY/TABLESPACE xxx

You cannot exclude the SYSTEM and SYSAUX tablespaces, tablespaces with SYS objects, undo tablespaces, tablespaces with undo segments, tablespaces with materialized views, or tablespaces in such a way that the duplicated tablespaces are not self-contained

Example 25-3 Excluding Read-Only Tablespaces

DUPLICATE TARGET DATABASE TO dupdb

FROM ACTIVE DATABASE

SKIP READONLY;

Example 25-4 Excluding Specified Tablespaces

DUPLICATE TARGET DATABASE TO dupdb

FROM ACTIVE DATABASE

SKIP TABLESPACE tools;

  1. TABLESPACE xxx: 只包含指定表空间

Automatically includes the SYSTEM, SYSAUX, and undo tablespaces. The included tablespaces must be self-contained and the resulting skipped tablespaces must not contain SYS objects or materialized views.

Example 25-5 Including Specified Tablespaces

DUPLICATE TARGET DATABASE TO dupdb

FROM ACTIVE DATABASE

  TABLESPACE users;

Example 25-6 Including Specified Tablespaces with Undo Segments

DUPLICATE TARGET DATABASE TO dupdb

 TABLESPACE users

 UNDO TABLESPACE undotbs;

  1. Duplicating an Oracle RAC Database

The steps to duplicate an Oracle Real Application Clusters (Oracle RAC) database contain minor variations from the ones used to duplicate databases.

  1. Prepare the auxiliary instance that is used when creating the duplicate database.

While duplicating an Oracle Real Application Clusters (Oracle RAC) database, set the CLUSTER_DATABASE initialization parameter on the auxiliary database to FALSE. This parameter can be reset to TRUE after the duplication completes.

  1. Start RMAN and connect to required databases.
  2. Place the source database in a proper state (if necessary).
  3. (Optional) Configure RMAN channels to improve duplication performance. Channels perform the primary task of duplicating the database.
  4. Use the DUPLICATE command to duplicate the source database.

三)Configuring RMAN Channels for Use in Duplication

The primary job of database duplication is performed by RMAN channels. Each channel corresponds to an Oracle Database server session that performs the duplication tasks.

Depending on the duplication technique, RMAN uses either auxiliary channels or target channels.

Use one of the following methods to configure channels:

  1. Automatically allocate channels by using the CONFIGURE command
  2. Manually allocate channels by using the ALLOCATE command

  1. Configuring Channels for Backup-based Duplication

For backup-based duplication, the principal work of the duplication is performed by the auxiliary channels.

如果不显示指定则auxiliary instance使用source database相同configuration配置的channel,即使用source database的channel未指定auxiliary选项

If you do not explicitly configure auxiliary channels, then RMAN uses the same channel configurations on the source database for duplication on the destination host. RMAN can use these configurations even if the source database channels do not specify the AUXILIARY option.

When you perform duplication without a target connection and without a recovery catalog, only disk channels can be used. If no user-allocated channels are used, then only one channel initially restores the control file. After the control file is mounted, the number of allocated channels depends on the configuration in the restored control file.

Example: Configuring Auxiliary Channels for Disk-based Backups

run

{

ALLOCATE AUXILIARY CHANNEL c1 DEVICE TYPE disk;

ALLOCATE AUXILIARY CHANNEL c2 DEVICE TYPE disk;

ALLOCATE AUXILIARY CHANNEL c3 DEVICE TYPE disk;

. . .

DUPLICATE DATABASE . . . ;

}

  1. Configuring Channels for Active Database Duplication

In active database duplication, you need not change your source database channel configuration or configure auxiliary channels. However, you may want to increase the parallelism setting of the source database disk channels so that RMAN copies files over the network in parallel.

The type of active database duplication technique used determines which channels perform the principal work of duplication.

When image copies are used to perform active database duplication, the primary work is performed by the target channels. Configure multiple target channels on the source database to improve the duplication performance.

When active database duplication is performed using backup sets, the principal work of duplication is performed by the auxiliary channels. Therefore, it is recommended that you allocate additional auxiliary channels. The number of auxiliary channels must be greater than or equal to the number of target channels.

  • Connecting to Databases
  1. 使用ACTIVE DATABASE using image copies时要用net service name连接auxiliary instance

For active database duplication using image copies, you must connect to the source database as TARGET and to the auxiliary instance as AUXILIARY. You must supply the net service name to connect to the AUXILIARY instance.

A recovery catalog connection is optional. A recovery catalog connection is optional.

On both instances, the password for the user performing the duplication must be the same. Any user with a SYSDBA or SYSBACKUP privilege can perform duplication.

  1. 使用ACTIVE DATABASE using backup sets时要用net service name连接source database

For active database duplication using backup sets, you must connect to the source database as TARGET using a net service name. The auxiliary instance uses this net service name to connect to the source database and retrieve the backup sets required for the duplication. Connect to the auxiliary instance as AUXILIARY. If you are connecting to the auxiliary instance remotely or intend to use the PASSWORD FILE option of the DUPLICATE command, then connect to the auxiliary instance with a net service name.

On both instances, the password for the user performing the duplication must be the same. Any user with a SYSDBA or SYSBACKUP privilege can perform duplication. A recovery catalog connection is optional.

  1. For backup-based duplication without a target connection, you must connect to the auxiliary instance as AUXILIARY and the recovery catalog as CATALOG.
  2. For backup-based duplication with a target connection, you must connect to the source database as TARGET and the auxiliary instance as AUXILIARY. A recovery catalog is optional.
  3. For backup-based duplication without target and recovery catalog connections, you must connect to the auxiliary instance as AUXILIARY.

Encrypting Backup Sets During Active Database Duplication

RMAN can use backup sets to transfer the source database files that need to be duplicated. The backup sets are transferred over the network to the auxiliary database. Backup sets can be encrypted for additional security. Use the SET ENCRYPTION ALGORITHM command before the DUPLICATE command to specify the encryption algorithm.

Before you perform active database duplication, use one of the following techniques to ensure that the encryption is successful:

If the source database uses transparent encryption, then you must share the Oracle software keystore containing the encryption key between the source database and the auxiliary instance as described in Making the Oracle Keystore Available to the Destination Host.

If the source database uses password encryption, then you must specify the password used to encrypt backups.

The following command sets the encryption password (where password is a placeholder for the actual password that you enter):

SET ENCRYPTION ON IDENTIFIED BY password;

Compressing Backup Sets During Active Database Duplication

When backup sets are used to perform active database duplication, RMAN can use backup compression to minimize the size of the backup sets used to transfer files from the source database to the destination host. Thus, compression can enhance the performance of the duplication process.

Compressing backup sets used for active database duplication is supported starting with Oracle Database 12c Release 1 (12.1).

Use the USING COMPRESSED BACKUPSET clause of the DUPLICATE command to compress the backup sets containing data required to perform active database duplication. The following command performs active database duplication using compressed backup sets. Assume that the connection to the target database and auxiliary instance has been made using net service names.

DUPLICATE TARGET DATABASE TO dup_db

FROM ACTIVE DATABASE

PASSWORD FILE

USING COMPRESSED BACKUPSET;

Duplicating Command

Depending on your requirement, use one of the following syntaxes of the DUPLICATE command:

  1. Use these for duplicating non-CDBs and CDBs.

DUPLICATE DATABASE or DUPLICATE … ACTIVE DATABASE

  1. Use this to create a standby database by duplicating the source database.

Use the DUPLICATE DATABASE ... FOR FARSYNC command to create an Oracle Data Guard far sync instance using duplication.

DUPLICATE DATABASE …. FOR STANDBY

  1. Use this to duplicate one or more PDBs while connected to the root.

DUPLICATE PLUGGABLE DATABASE

If the backup location contains backup files from multiple databases, then the DATABASE clause must specify the name of the database that is to be duplicated. If the backup location contains backup files from multiple databases having the same name, then the DATABASE clause must specify both the name and DBID of the database that is to be duplicated.

By default, the DUPLICATE command creates the duplicate database by using the most recent backups of the target database and then performs recovery to the most recent consistent point contained in the incremental backups and archived redo logs. However, you can recover the duplicate database to a past point in time by using one of the following methods:

DUPLICATE … UNTIL command

SET UNTIL command before the DUPLICATE command

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

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

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

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值