ICode9

精准搜索请尝试: 精确搜索
首页 > 数据库> 文章详细

【11.2拾遗】rman复制数据库 Duplicating a Database

2019-04-16 10:50:58  阅读:260  来源: 互联网

标签:database 数据库 Database Duplicating 11.2 source 复制 RMAN 备份


本章描述如何使用DUPLICATE命令创建独立运行的数据库副本。

This chapter contains the following topics:

Overview of RMAN Database Duplication

数据库复制是使用DUPLICATE命令复制源数据库中的所有或部分数据。

The duplicate database (the copied database) functions entirely independently from the source database (the database being copied).

数据库复制的目的

重复的数据库可以用于各种各样的目的,其中大多数都涉及到测试。您可以在一个复制的数据库中执行以下任务:

  • 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

例如,您可以将host1上的生产数据库复制到host2上,然后使用host2上的复制数据库,在host1上的生产数据库正常运行时,练习还原和恢复这个数据库。

如果使用操作系统实用程序而不是DUPLICATE命令复制数据库,那么复制数据库的DBID将与原始数据库保持相同。要将复制数据库注册到与原始数据库相同的恢复目录中,必须使用DBNEWID实用程序更改DBID(请参阅Oracle数据库实用程序)。相反,DUPLICATE命令自动为DUPLICATE数据库分配一个不同的DBID,以便它可以与源数据库注册在相同的恢复目录中。

DUPLICATE命令可以创建数据库或物理备用数据库的完整功能副本,这具有非常不同的用途。备用数据库是主数据库的副本,您可以使用来自主数据库的归档日志文件不断更新主数据库。如果无法访问主数据库,则可以将故障转移到备用数据库,备用数据库将成为新的主数据库。但是,不能以这种方式使用数据库副本:它不用于故障转移场景,也不支持各种备用恢复和故障转移选项。

See Also:

Oracle Data Guard Concepts and Administration to learn how to create a standby database with the DUPLICATE command

数据库复制的基本概念

源主机是承载源数据库的计算机。源数据库实例是与源数据库关联的实例。

目标主机是承载重复数据库的计算机。源主机和目标主机可以是相同的计算机,也可以是不同的计算机。与重复数据库关联的数据库实例称为辅助实例。

Note:

不支持使用相同的源数据库执行同时的数据库复制操作。

复制数据库的技术

RMAN支持两种基本类型的复制:活动数据库复制和基于备份的复制。RMAN可以执行基于备份的复制,无论是否有以下连接:

  • Target

  • Recovery catalog

活动数据库复制需要连接到这两个数据库。

Figure 24-1 shows the decision tree for the two duplication techniques.

Figure 24-1 Duplication Techniques

Description of Figure 24-1 follows
Description of "Figure 24-1 Duplication Techniques"

  • 活动数据库复制

在活动数据库复制中,RMAN作为目标连接源数据库实例,并作为辅助实例连接辅助实例。RMAN通过网络将活动源数据库复制到辅助实例,从而创建重复的数据库。不需要备份源数据库。图24-2说明了活动数据库复制。

Figure 24-2 Active Database Duplication

Description of Figure 24-2 follows
Description of "Figure 24-2 Active Database Duplication"

Backup-Based重复

在基于备份的复制中,RMAN使用预先存在的RMAN备份和副本创建复制数据库。这种复制技术使用下列相互排斥的子技术之一:

  • 在没有目标数据库连接的情况下,RMAN从恢复目录中获取关于备份的元数据。

  • 没有目标数据库连接和恢复目录的复制。RMAN从备份位置获取关于备份和副本位于何处的元数据。

  • 与目标数据库连接的复制。RMAN从目标数据库控制文件或恢复目录中获取关于备份的元数据。

Figure 24-3 说明在没有目标连接的情况下基于备份的复制。RMAN连接到恢复目录数据库实例和辅助实例。目标主机必须能够访问创建重复数据库所需的RMAN备份。

Figure 24-3 Backup-Based Duplication Without a Target Connection

Description of Figure 24-3 follows
Description of "Figure 24-3 Backup-Based Duplication Without a Target Connection"
 

Figure 24-4 演示了在不连接到目标或恢复目录数据库实例的情况下基于备份的复制。RMAN连接到目标主机上重复数据库的辅助实例。包含所有备份或复制副本的磁盘备份位置必须对目标主机可用。

Figure 24-4 没有目标连接或恢复目录连接的基于备份的复制

Description of Figure 24-4 follows
Description of "Figure 24-4 Backup-Based Duplication Without a Target Connection or Recovery Catalog Connection"
 

Figure 24-5 说明基于备份的与目标连接的复制。RMAN连接到源数据库实例和辅助实例。RMAN还可以选择连接到恢复目录数据库(图中没有显示)。目标主机必须能够访问创建重复数据库所需的RMAN备份。

Figure 24-5 Backup-Based Duplication with a Target Connection

Description of Figure 24-5 follows
Description of "Figure 24-5 Backup-Based Duplication with a Target Connection"

重复数据库的内容

重复的数据库可以包含与源数据库相同的内容,也可以只包含源数据库中表空间的子集。例如,可以使用表空间选项只复制指定的表空间,或者使用SKIP READONLY选项从复制数据库中排除只读表空间。

RMAN如何复制数据库

对于基于备份的复制,复制的主要工作由辅助通道执行。这些通道对应于目标主机上的辅助实例上的服务器会话。对于活动数据库复制,主要工作由目标通道执行。

即使没有为复制提供显式的时间点,RMAN也必须执行数据库时间点恢复。需要时间点恢复,因为源数据库中的联机重做日志文件没有备份,不能应用于重复数据库。复制数据库的最远恢复点是源数据库存档的最近的重做日志文件。

作为复制操作的一部分,RMAN自动执行以下步骤:

  1. 如果下列条件为真,则为辅助实例创建默认服务器参数文件:

    • 复制不涉及备用数据库。

    • 服务器参数文件没有被复制。

    • 辅助实例不是用服务器参数文件启动的。

  2. 从备份或从活动数据库中还原满足UNTIL子句要求的最新控制文件。

  3. 从活动数据库中挂载已还原或复制的备份控制文件。

    Note:

    如果源数据库中的控制文件包含禁用的线程,那么这些线程也将在重复数据库中禁用。
  4. 使用RMAN存储库选择备份,以便将数据文件还原到辅助实例。此步骤适用于基于备份的复制。

  5. 还原和复制复制的数据文件,并使用增量备份和归档重做日志文件将其恢复到非当前时间点。

  6. 以NOMOUNT模式关闭并重新启动数据库实例。

  7. 创建一个新的控制文件,然后该文件在数据文件中创建并存储新的DBID。

  8. 使用RESETLOGS选项打开重复数据库,并为新数据库创建在线重做日志。

See Also:

The DUPLICATE entry in Oracle Database Backup and Recovery Reference for a complete list of which files are copied to the duplicate database

数据库复制的基本步骤

This section describes the basic steps of database duplication. Follow the link in each step for further instructions.

To duplicate a database:

  1. Prepare for database duplication.准备数据库复制。

    See "Preparing to Duplicate a Database".

  2. Start RMAN and connect to the necessary database instances.启动RMAN并连接到必要的数据库实例

    See "Starting RMAN and Connecting to Databases".

  3. Place the source database in the proper state (if necessary).将源数据库置于适当的状态(如果需要)

    See "Placing the Source Database in the Proper State".

  4. Configure RMAN channels (if necessary).配置RMAN通道(如果需要)。

    See "Configuring RMAN Channels for Use in Duplication".

  5. Perform the duplication.执行重复。

    See "Duplicating a Database".

Preparing to Duplicate a Database

在复制数据库之前,必须决定如何执行复制,然后准备数据库环境,包括辅助数据库实例。

To prepare for duplication:

  1. Choose a duplication technique.

    See "Step 1: Choosing a Duplication Technique".

    在复制Oracle Real Application Clusters (Oracle RAC)数据库时,将辅助数据库上的CLUSTER_DATABASE初始化参数设置为FALSE。复制完成后,可以将此参数重置为TRUE。

  2. Choose a strategy for naming the duplicate database files.

    See "Step 2: Choosing a Strategy for Naming Duplicate Files".

  3. For a backup-based strategy, make the backups accessible to the auxiliary instance; otherwise, skip this step.

    See "Step 3: Making Backups Accessible to the Duplicate Instance".

  4. Prepare remote access to databases.

    See "Step 4: Preparing Remote Access to Databases".

  5. Prepare the auxiliary instance.

    See "Step 5: Creating an Initialization Parameter File and Starting the Auxiliary Instance".

Step 1: Choosing a Duplication Technique

业务需求和数据库环境决定哪种复制技术最适合您的情况。考虑以下问题:

  • 您熟悉每种复制技术的先决条件吗?

    Review the "Prerequisites" section of the DUPLICATE command entry in Oracle Database Backup and Recovery Reference for a complete list. 所有复制技术都有一些共同的先决条件,例如:

    • 源数据库和复制数据库必须位于同一个平台上。DUPLICATE命令将同一操作系统的32位和64位版本视为属于同一平台。

    • DUPLICATE命令需要至少一个辅助通道在辅助实例上执行复制操作。

    其他先决条件是特定的,并取决于复制技术。例如,活动复制要求源和辅助实例使用与源数据库相同的密码,而不连接到目标数据库和恢复目录的基于备份的复制只要求所有备份和数据库副本驻留在一个位置。

  • 源数据库的备份是否已经存在?

    活动数据库复制的主要优点是不需要源数据库备份。通过网络将已挂载或联机数据库文件的活动副本复制到辅助实例。该技术的一个缺点是对网络性能的负面影响。另一个缺点是源数据库正在运行将文件传输到辅助主机所需的进程,从而影响源数据库和生产工作负载。

    如果源数据库备份已经存在,并且对网络的影响是不可接受的,那么基于备份的复制可能是更好的选择。您可以将备份复制到临时存储并手动将其传输到目标主机。如果复制是通过连接到目标或恢复目录进行的,那么目标主机上的备份文件必须具有与源主机上相同的文件规范。否则,这不是必需的。

  • Is a recovery catalog available?  直接复制备份

    如果存在恢复目录,则可以执行基于备份的复制,而无需将RMAN作为目标连接到源数据库。当从辅助主机到源数据库的网络连接受到限制或容易出现间歇性中断时,这种技术很有优势。在没有目标连接的复制中,源数据库不受复制的影响。

  • How much disk space is available on the destination host?

    当使用磁盘备份执行复制时,目标主机上的磁盘空间可能是一个问题。例如,如果源数据库是1tb (TB),并且在不使用共享磁盘或网络文件系统(NFS)的情况下从磁盘备份复制数据库,那么目标主机上必须至少有2tb (TB)的可用空间。在某些环境中,手动转移备份是必要的,因为NFS性能是一个瓶颈

  • Are the source and destination hosts connected by a LAN or a WAN?

    广域网(WAN)上的活动数据库复制性能可能比局域网(LAN)慢。如果WAN上的性能下降是不可接受的,那么基于备份的复制可能是惟一可行的选择。

  • When do you plan to duplicate the database?

    如果必须在高用户活动期间复制数据库,那么由活动复制导致的网络吞吐量损失可能是一个问题,因此基于备份的复制是更好的选择。此外,在活动数据库复制中,将文件复制到辅助主机所需的RMAN通道可能会影响性能。

Step 2: Choosing a Strategy for Naming Duplicate Files

在复制数据库时,RMAN为复制的控制文件、数据文件、临时文件和在线重做日志文件生成名称。因此,您必须决定这些文件的命名策略。

Oracle推荐最简单的复制策略,即将复制数据库配置为使用与源数据库相同的名称。使用相同的名称意味着您的环境符合以下要求:

  • 如果源数据库使用ASM磁盘组,那么重复数据库必须使用名称相同的ASM磁盘组。

  • 如果源数据库文件是Oracle托管文件,那么辅助实例必须将DB_FILE_CREATE_DEST设置为与源数据库相同的目录位置。虽然源主机和目标主机上的目录是相同的,但是Oracle数据库为重复的文件选择相对名称。

  • 如果这是Oracle RAC环境,则必须对源主机和目标主机使用相同的ORACLE_SID。

  • 如果源数据库中的数据库文件的名称包含一个路径,那么这个路径名称在重复数据库中必须相同。

当您按照建议配置环境时,不需要额外的配置来命名重复的文件。

See Also:

"Specifying Alternative Names for Duplicate Database Files" for an explanation of the more complex strategy of using different names for the duplicate files

Step 3: Making Backups Accessible to the Duplicate Instance

Note:

If you are performing active database duplication, then skip this section and proceed to "Step 4: Preparing Remote Access to Databases".

当使用目标和恢复目录进行复制时,或者仅使用目标连接时,RMAN使用RMAN存储库中的元数据来定位复制所需的备份和存档重做日志文件。如果RMAN连接到恢复目录,则RMAN从目录中获取备份元数据。如果RMAN没有连接到目录(在使用目标连接执行基于备份的复制时可能就是这种情况),那么RMAN将从控制文件中获取元数据。

除非在没有连接到目标和恢复目录的情况下进行复制,否则备份的名称必须与RMAN存储库中记录的名称相同。确保目标主机上的辅助通道可以访问所有数据文件备份和存档的重做日志文件(将重复的数据库恢复到所需的时间点需要)。否则,复制将失败。存档的重做日志文件可以作为映像副本或备份集使用。

Note:

数据库备份不需要与备份数据库一起生成。您可以混合对单个数据文件的完整备份和增量备份,但是需要对每个数据文件进行完整备份。

使辅助实例可以访问SBT备份
此任务中的步骤特定于您的媒体管理器配置。

要使辅助实例可以访问SBT备份:

  1. 如果需要,在目标主机上安装媒体管理软件。

  2. 使带备份的磁带可被目标主机访问。通常情况下,您会执行以下操作之一:

    • 将磁带物理地移动到连接到远程主机的驱动器上。

    • 使用可通过网络访问的磁带服务器。

  3. 如有必要,通知远程媒体管理软件磁带的存在。

使辅助实例可以访问磁盘备份

When you make disk backups accessible to the auxiliary instance, your strategy depends on whether or not you duplicate the database while connected to the target or recovery catalog. If you do not connect to the target or recovery catalog, then you must designate a BACKUP LOCATION for the duplication.

When you use a BACKUP LOCATION, the backups and copies can reside in a shared location or can be moved to the BACKUP LOCATION on the destination host. In the latter case, you do not need to preserve the name or the original path of the backup or copy. The location specified by the BACKUP LOCATION option must contain sufficient backup sets, image copies, and archived logs to restore all of the files being duplicated, and recover them to the desired point in time.

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.

When you use backups from different points in time, the backup location must contain archived logs covering the time from the start of the oldest backup until the desired recovery point.

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.

The source database's Fast Recovery Area is particularly well suited for use as a backup location because it almost always contains all of the files needed for the duplication. To use a Fast Recovery Area as a backup location, you can either remotely access it from the destination system, or copy its contents to the destination system.

当您不使用备份位置时,您的策略取决于以下相互排斥的场景:

  • 源主机和目标主机的相同文件系统

    This scenario is the simplest and Oracle recommends it. For example, assume that the backups of the source database are stored in /dsk1/bkp. In this case, you can make disk backups accessible to the destination host in either of these ways:

    • Manually transfer backups from the source host to an identical path in the destination host. For example, if the backups are in /dsk1/bkp on the source host, then use FTP to transfer them to /dsk1/bkp on the destination host.

    • Use NFS or shared disks and ensure that the same path is accessible in the destination host. For example, assuming the source host can access /dsk1/bkp, use NFS to mount /dsk1/bkp on the destination host and use /dsk1/bkp as the mount point name.

  • 源主机和目标主机的不同文件系统

    In this case you cannot use the same directory name on the destination host as you use on the source host. You have the following options:

假设您有两个主机,srchost和dsthost,并访问NFS或共享磁盘。srchost上的数据库称为srcdb。srcdb的备份位于主机srchost上的/dsk1/bkp中。目录/dsk1/bkp已经在目标主机上使用,但是目录/dsk2/dup在这两个主机上都没有使用。

将备份从源主机转移到目标主机

  1. 在源主机或目标主机中创建备份存储目录。

    For this example, create backup directory /dsk2/dup on the destination host.

  2. 将上一步中创建的目录挂载到另一台主机上,确保目录和挂载点名称相同。
    例如,如果您在目标主机上创建/dsk2/dup,那么使用NFS将该目录挂载为源主机上的/dsk2/dup。

  3. 使备份在目标主机的新位置可用。你可以使用以下任何一种技巧:

    • Connect RMAN to the source database as TARGET and use the BACKUP command to back up the backups, as explained in "Backing Up RMAN Backups". For example, use the BACKUP COPY OF DATABASE command to copy the backups in /dsk1/bkp on the source host to /dsk2/dup on the source host. In this case, RMAN automatically catalogs the backups in the new location.

    • Use an operating system utility to transfer the backups to the new location. For example, use FTP to transfer the backups from /dsk1/bkp on the source host to /dsk2/dup on the destination host, or use the cp command to copy the backups from /dsk1/bkp on the source host to /dsk2/dup on the source host. Afterward, connect RMAN to the source database as TARGET and use the CATALOG command to update the RMAN repository with the location of the manually transferred backups.

Step 4: Preparing Remote Access to Databases

当必须从其他主机访问数据库时,必须设置密码文件和Oracle网络连接。注意此类设置的潜在安全后果。

Establishing Connectivity in Required Cases

To create a password file manually:

Follow the instructions in Oracle Database Administrator's Guide to create a password file.

The types of file names allowed for password files and the location of the password file are both platform specific and operating system-specific.

See Also:

To establish Oracle Net connectivity and set up a static listener:

Follow the instructions in Oracle Database Net Services Administrator's Guide to configure a client for connection to a database and add static service information for the listener.

Creating a Password File for the Auxiliary Instance

You have the following options for creating a password file for the auxiliary instance on the destination host:

  • Create the password file manually.

    There are additional requirements for the case of DUPLICATE ... FROM ACTIVE DATABASE. You must use the SYS user ID, and the password must match the password of the source database. You may want to create the password file with a single password so that you can start the auxiliary instance and enable the source database to connect to it.

  • Specify the PASSWORD FILE option on the DUPLICATE... FROM ACTIVE DATABASE command.

    In this case, RMAN copies the source database password file to the destination host and overwrites any existing password file for the auxiliary instance. This technique is useful if the source database password file has multiple passwords that you want to make available on the duplicate database.

See Also:

Oracle Database Administrator's Guide

Note:

如果使用FROM ACTIVE database选项创建备用数据库,那么RMAN总是将密码文件复制到备用主机。

Step 5: Creating an Initialization Parameter File and Starting the Auxiliary Instance

The location and content of the initialization parameter file depend on your choice in "Step 2: Choosing a Strategy for Naming Duplicate Files". 本节作出以下假设:

  • You choose the recommended technique of using the same naming strategy for the source and destination hosts. Thus for Oracle RAC environments, you use the same ORACLE_SID for source and destination hosts.

  • You create a text-based initialization parameter file for the auxiliary instance. See Table 25-5, "Auxiliary Instance Initialization Parameters".

  • The initialization parameter file is located in the operating system-specific default location of the host on which SQL*Plus runs.

    For example, on Linux and UNIX the default initialization parameter file name is ORACLE_HOME/dbs/initORACLE_SID.oraand on Windows the file name is ORACLE_HOME\database\initORACLE_SID.ora.

  • You plan to specify the SPFILE clause on the DUPLICATE command.

    The DUPLICATE ... SPFILE technique is easiest because during duplication RMAN automatically copies the server parameter file from the source database to the auxiliary instance or restores it from backup. If a server parameter file exists on the auxiliary instance, then RMAN overwrites it.

If you cannot meet the preceding requirements, then see "Duplicating a Database When No Server Parameter File Exists".

要创建初始化参数文件并启动辅助实例:

  1. Using a text editor, create an empty file for use as a text-based initialization parameter file.

  2. Copy the initialization parameter file to the operating system-specific default location on the host where SQL*Plus runs.

  3. In the parameter file, set DB_NAME to an arbitrary value.

    DB_NAME is the only required initialization parameter. The following example shows a sample DB_NAME setting:

    DB_NAME=somevalue
    
  4. If necessary, set other initialization parameters like those needed for Oracle RAC, and for connecting by using a user ID that has SYSDBA privileges through Oracle Net.

  5. Start SQL*Plus and connect to the auxiliary instance with SYSDBA privileges. Start the auxiliary instance in NOMOUNTmode (no PFILE parameter on the STARTUP command is necessary if the file is in the default location):

    SQL> STARTUP NOMOUNT
    

Note:

Ensure that the auxiliary instance is started with a text-based initialization parameter file and not a server parameter file. Do not create a control file or try to mount or open the auxiliary instance.

Placing the Source Database in the Proper State

Note:

If you are performing backup-based duplication without a target connection, then skip to "Configuring RMAN Channels for Use in Duplication".

如果RMAN作为目标连接到源数据库,则源数据库必须处于复制的适当状态。

确保源数据库处于正确的状态:

  1. 如果源数据库实例没有挂载或打开,则挂载或打开它。
    如果你正在进行活动的数据库复制,请确保符合下列额外要求:
    如果源数据库是开放的,则必须启用归档。
    如果源数据库未打开,则数据库不需要实例恢复。

Starting RMAN and Connecting to Databases

In this task, you must start the RMAN client and connect to the database instances required by the duplication technique chosen in "Step 1: Choosing a Duplication Technique". The RMAN client can be located on any host so long as it can connect to the necessary databases over the network.

启动RMAN并连接到目标实例和辅助实例:

  1. Start the RMAN client on any host that can connect to the necessary database instances.

  2. At the RMAN prompt, run CONNECT commands for the database instances required for your duplication technique:

    • For active database duplication, you must connect to the source database as TARGET and to the auxiliary instance as AUXILIARY. You must use the same SYSDBA password for both instances and must supply the net service name to connect to the AUXILIARY instance. A recovery catalog connection is optional.

    • For backup-based duplication without a target connection, you must connect to the auxiliary instance as AUXILIARY and the recovery catalog as CATALOG.

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

    • For backup-based duplication without target and recovery catalog connections, you must connect to the auxiliary instance as AUXILIARY.

    在下面的活动数据库复制示例中,建立到三个数据库实例的连接,所有实例都使用net服务名称:

    RMAN> CONNECT TARGET SYS/sysdba@prod;    # source database
    connected to target database: PROD (DBID=39525561)
    
    RMAN> CONNECT AUXILIARY SYS/sysdba@dupdb; # duplicate database instance
    connected to auxiliary database: DUPDB (not mounted)
    
    RMAN> CONNECT CATALOG rman/rman@catdb;    # recovery catalog database
    connected to recovery catalog database
    

Configuring RMAN Channels for Use in Duplication

The channel on the auxiliary instance, not the source database instance, restores RMAN backups in backup-based duplication. The channel configuration depends on your duplication technique.

Configuring Channels for Active Database Duplication

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

See Also:

Oracle Database Backup and Recovery Reference for information about the CONFIGURE command

Configuring Channels for Backup-Based Duplication

RMAN can use 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.

Note the following additional considerations:

  • The channel type (DISK or sbt) of the auxiliary channel must match the backup media. In general, the more channels you allocate for disk backups, the faster the duplication. You cannot increase the speed of duplication after the disks reach their maximum read/write rate. For tape backups, limit the number of channels to the number of devices available.

  • If the auxiliary channels need special parameters (for example, to point to a different media manager), then you can configure an automatic channel with the AUXILIARY option of the CONFIGURE command.

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

Duplicating a Database

本节描述复制数据库的最基本过程。本节作出以下假设:

  • You are duplicating the database to a remote host. The duplicate database files use the same names as the source database files.

    Note:

    When running the DUPLICATE command in this configuration, you must specify the NOFILENAMECHECK option on the DUPLICATE command. If you duplicate a database on the same host as the source database, then verify that NOFILENAMECHECK is not specified.
  • You are duplicating the entire database. For other scenarios, see "Duplicating a Subset of the Source Database Tablespaces".

To duplicate a database to a remote host with the same directory structure:

  1. Ensure that you have completed Steps 1 through 4 in "Basic Steps of Database Duplication".

  2. Run the DUPLICATE command.

Example 24-1 说明如何在指定SPFILE子句时执行活动复制。DUPLICATE需要NOFILENAMECHECK选项,因为源数据库文件具有与DUPLICATE数据库文件相同的名称。

密码文件选项指定RMAN应该将密码文件复制到目标主机。RMAN自动将服务器参数文件复制到目标主机,使用服务器参数文件启动辅助实例,通过网络将所有必要的数据库文件和存档的重做日志复制到目标主机,并恢复数据库。最后,RMAN使用RESETLOGS选项打开数据库,创建在线重做日志。

Example 24-1 Duplicating to a Host with the Same Directory Structure (Active)

DUPLICATE TARGET DATABASE TO dupdb
  FROM ACTIVE DATABASE
  PASSWORD FILE
  SPFILE
  NOFILENAMECHECK;

Backup-Based Duplication Without a Target Connection: Example

In this variation of Example 24-1, RMAN does not use a TARGET connection to the source database. Example 24-2 creates a duplicate of the source database prod as it appeared in 2007 in a previous database incarnation. RMAN is not connected to the source database but must be connected to a recovery catalog because no BACKUP LOCATION is provided.

Example 24-2 将数据库复制到过去某个时间点 (Backup-Based)

DUPLICATE DATABASE prod DBID 8675309 TO dupdb
  UNTIL TIME "TO_DATE('11/01/2007', 'MM/DD/YYYY')"
  SPFILE
  NOFILENAMECHECK;

Note the following characteristics of Example 24-2:

  • 未指定FROM ACTIVE DATABASE子句。通过不指定此子句,您指示RMAN执行基于备份的复制。
    指定DBID是因为源数据库名称prod在恢复目录中不是惟一的。
    之所以指定NOFILENAMECHECK检查,是因为当重复的数据库文件使用与源数据库文件相同的名称时,这是必要的。

假设您希望恢复存档备份的变体,从包括恢复和恢复数据库所需的每个文件的意义上说,备份是全面的。恢复用于测试的存档备份的推荐技术是创建一个临时实例并使用DUPLICATE命令。这样,您就避免了对源数据库的干扰。

In the DUPLICATE command you must specify the restore point that was created with the archival backup. You can only specify TO RESTORE POINT if RMAN is connected to a catalog, or to the source database when the restore point exists in the control file. Example 24-3 specifies restore point TESTDB103107.

Example 24-3 使用存档备份进行基于备份的复制

DUPLICATE DATABASE prod DBID 8675309 TO dupdb
  TO RESTORE POINT TESTDB103107
  SPFILE
  NOFILENAMECHECK;

Backup-Based Duplication with a Target Connection: Example

Assume a backup-based variation of Example 24-1 in which RMAN is connected as TARGET to the source database. Example 24-4recovers the duplicate database to 1 week ago to view the data in the source database as it appeared then.

Example 24-4 Duplicating a Database to a Past Point in Time (Backup-Based)

DUPLICATE TARGET DATABASE TO dupdb
  SPFILE
  NOFILENAMECHECK
  UNTIL TIME 'SYSDATE-7';

Note the following characteristics of Example 24-4:

  • 未指定FROM ACTIVE DATABASE子句。通过不指定此子句,您指示RMAN执行基于备份的复制。
    之所以指定NOFILENAMECHECK选项,是因为当重复的数据库文件使用与源数据库文件相同的名称时,这是必需的。

Backup-Based Duplication Without a Target and a Recovery Catalog Connection: Example

In the variation of Example 24-1, shown in Example 24-5, RMAN does not use a TARGET connection to the source database or a CATALOG connection to a recovery catalog. All backup and copies necessary for duplication until November 11 of 2007 at 2:00 PM, including a control file backup or copy, have been placed under /prod_backups.

Example 24-5 Duplicating a Database Without a Target and Recovery Catalog Connection (Backup-Based)

DUPLICATE DATABASE TO dupdb
  UNTIL TIME "TO_DATE('11/01/2007 14:00:00', 'MM/DD/YYYY HH24:MI:SS')"
  SPFILE
  BACKUP LOCATION '/prod_backups'
  NOFILENAMECHECK;

Note the following characteristics of Example 24-5:

  • 没有指定数据库名称。通过不使用database关键字指定数据库名称,DUPLICATE可以从备份中获得数据库名称和DBID。如果在备份位置发现多个数据库的备份,则会显示错误。
    使用BACKUP LOCATION子句可以将复制类型标识为基于备份的,既没有目标连接也没有恢复目录。

  • 指定了UNTIL TIME选项。它是唯一允许使用BACKUP LOCATION子句的UNTIL子句。
    之所以指定NOFILENAMECHECK选项检查,是因为当重复的数据库文件使用与源数据库文件相同的名称时,这是必要的。

Example 24-6 Duplicating a Database to a Past Point in Time (Backup-Based)

DUPLICATE TARGET DATABASE TO dupdb
  SPFILE
  NOFILENAMECHECK
  UNTIL TIME 'SYSDATE-7';

Note the following characteristics of Example 24-6:

  • 未指定FROM ACTIVE DATABASE子句。省略此子句指示RMAN执行基于备份的复制。
    之所以指定NOFILENAMECHECK选项检查,是因为当重复的数据库文件使用与源数据库文件相同的名称时,这是必要的。

Restarting DUPLICATE After a Failure

RMAN自动优化重复命令,重复先前失败的重复命令。repeat DUPLICATE命令注意哪些数据文件在前面已经成功复制,并且不会再次复制它们。这适用于所有形式的复制,无论它们是基于备份的(有或没有目标连接)还是活动数据库复制。当在复制非常大的数据库期间发生故障时,重复命令的自动优化特别有用。

To restart a DUPLICATE operation:

  1. Exit RMAN.

  2. Start SQL*Plus and connect to the auxiliary instance with SYSDBA or SYSBACKUP privilege. Start the auxiliary instance in NOMOUNT mode with the same SPFILE or PFILE specification that you used initially. If you omitted this specification initially, then omit it again here.

    This example starts the auxiliary instance using the parameters in /home/my_pfile.ora:

    STARTUP FORCE PFILE=/home/my_pfile.ora
    
  3. Exit SQL*Plus and start RMAN.

  4. Connect to the same databases as initially.

  5. Repeat the DUPLICATE command.

The second DUPLICATE operation:

  • Locates the data files that were successfully duplicated by the initial DUPLICATE command.

  • Displays a message similar to the following for each data file that it does not need to duplicate again:

    RMAN-05560: Using previous duplicated file /oradata/new/data01.f for datafile 1 with checkpoint SCN of 1654665
    
  • Restores only the missing or incomplete data files, thereby avoiding recopying and restoring all the data files.

如果不希望RMAN自动从失败的重复操作中恢复,请指定关键字NORESUME禁用该功能。在第一次调用DUPLICATE时使用关键字NORESUME可以防止新数据库的后续DUPLICATE命令使用此自动优化。

标签:database,数据库,Database,Duplicating,11.2,source,复制,RMAN,备份
来源: https://blog.csdn.net/viviliving/article/details/89326602

本站声明: 1. iCode9 技术分享网(下文简称本站)提供的所有内容,仅供技术学习、探讨和分享;
2. 关于本站的所有留言、评论、转载及引用,纯属内容发起人的个人观点,与本站观点和立场无关;
3. 关于本站的所有言论和文字,纯属内容发起人的个人观点,与本站观点和立场无关;
4. 本站文章均是网友提供,不完全保证技术分享内容的完整性、准确性、时效性、风险性和版权归属;如您发现该文章侵犯了您的权益,可联系我们第一时间进行删除;
5. 本站为非盈利性的个人网站,所有内容不会用来进行牟利,也不会利用任何形式的广告来间接获益,纯粹是为了广大技术爱好者提供技术内容和技术思想的分享性交流网站。

专注分享技术,共同学习,共同进步。侵权联系[81616952@qq.com]

Copyright (C)ICode9.com, All Rights Reserved.

ICode9版权所有