Duplicate a Database Using RMAN in Oracle Database 11g Release 2
This article is an update of a previous Oracle 9i article.
Related articles.
Introduction
RMAN has the ability to duplicate, or clone, a database from a backup or from an active database. It is possible to create a duplicate database on a remote server with the same file structure, a remote server will a different file structure or the local server with a different file structure.
The article assumes the duplicate database is being created on a separate server, using the same SID (DB11G) and the same file structure as the source database. Explanations of several other scenarios are available here.
Backup-Based Duplication
Create a backup of the source database, if a suitable one doesn't already exist.
$ rman target=/ RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON; RMAN> BACKUP DATABASE PLUS ARCHIVELOG
All subsequent actions occur on the server running the duplicate database.
Create a password file for the duplicate instance.
$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwDB11G password=password entries=10
Add the appropriate entries into the "tnsnames.ora" file in the "$ORACLE_HOME/network/admin" directory to allow connections to the target database from the duplicate server.
# Added to the tnsnames.ora DB11G-SOURCE = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ol5-112-dup1)(PORT = 1521)) ) (CONNECT_DATA = (ORACLE_SID = DB11G) ) )
Create a PFILE for the duplicate database. Since we are duplicating the database onto a separate server with the same filesystem as the original, we don't need to convert the file names. In this case, the PFILE is called "initDB11G.ora" and is placed in the "$ORACLE_HOME/dbs" directory.
# Minimum Requirement. DB_NAME=DB11G # Convert file names to allow for different directory structure if necessary. #DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/DB11G/','/u01/app/oracle/oradata/NEWSID/' #LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/DB11G/','/u02/app/oracle/oradata/NEWSID/'
We don't need all the other parameters as the clone will copy the SPFILE from the primary database. If you are duplicating a database on the same machine you will probably need to create a PFFILE/SPFILE manually from the primary database SPFILE, manually change the values and avoid the SPFILE clause in the duplicate command.
Create any directories necessary for start the duplicate database.
$ mkdir -p /u01/app/oracle/oradata/DB11G $ mkdir -p /u01/app/oracle/fast_recovery_area/DB11G $ mkdir -p /u01/app/oracle/admin/DB11G/adump
Make the backup files from the source database available to the destination server. That can be done by either copying them to the matching location on the destination server, or placing them on a shared drive. If you are copying the files, you may want to use the following type of commands.
$ scp -r oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/archivelog /u01/app/oracle/fast_recovery_area/DB11G $ scp -r oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/backupset /u01/app/oracle/fast_recovery_area/DB11G $ scp -r oracle@ol5-112-dup1:/u01/app/oracle/fast_recovery_area/DB11G/autobackup /u01/app/oracle/fast_recovery_area/DB11G
Connect to the duplicate instance.
$ ORACLE_SID=DB11G; export ORACLE_SID $ sqlplus / as sysdba
Start the database in NOMOUNT
mode.
SQL> STARTUP NOMOUNT;
With the duplicate database started we can now connect to it from RMAN. For the duplication to work we must connect to the duplicate database (AUXILIARY), but depending on the type of duplication we are doing we may optionally connect to the original database (TARGET) and/or the recovery catalog (CATALOG).
$ ORACLE_SID=DB11G; export ORACLE_SID # No target or catalog. Metadata comes from backups. $ rman AUXILIARY / # Target, but no catalog. Metadata comes from target database controlfile. $ rman TARGET sys/password@DB11G-SOURCE AUXILIARY / # Catalog, but no target. Metadata comes from the RMAN catalog. $ rman CATALOG rman/password@rman-catalog AUXILIARY / # Target and catalog. Metadata can come from the target controlfile or the catalog. $ rman TARGET sys/password@DB11G-SOURCE CATALOG rman/password@rman-catalog AUXILIARY /
We can then duplicate the database using one of the following commands. Remember, remove the SPFILE clause if you have manually created a full PFILE or SPFILE.
# Backup files are in matching location to that on the source server. # Duplicate database to TARGET's current state. DUPLICATE TARGET DATABASE TO DB11G SPFILE NOFILENAMECHECK; # Duplicate database to TARGET's state 4 days ago. DUPLICATE TARGET DATABASE TO DB11G UNTIL TIME 'SYSDATE-4' SPFILE NOFILENAMECHECK; # Backup files are in a different location to that on the source server. # Duplicate database to the most recent state possible using the provided backups. # Works with just an AUXILIARY connection only. DUPLICATE DATABASE TO DB11G SPFILE BACKUP LOCATION '/source/app/oracle/fast_recovery_area/DB11G' NOFILENAMECHECK; # Do a point-in-time clone. DUPLICATE DATABASE TO DB11G SPFILE BACKUP LOCATION '/source/app/oracle/fast_recovery_area/DB11G' NOFILENAMECHECK UNTIL TIME "TO_DATE('2014-11-17 07:00:00', 'YYYY-MM-DD HH24:MI:SS')"; # Alter some SPFILE parameters during the clone. DUPLICATE DATABASE TO MYCLONE SPFILE parameter_value_convert ('DB11G','MYCLONE') set db_file_name_convert='/u01/oradata/db11g/','/u01/oradata/myclone/' set log_file_name_convert='/u01/oradata/db11g/','/u01/oradata/myclone/' set control_files='/u01/oradata/myclone/control01.ctl','/u01/oradata/myclone//control02.ctl','/u01/oradata/myclone/control03.ctl' set db_name='MYCLONE' set log_archive_dest_1='location=/u01/oradata/myclone/arch' BACKUP LOCATION '/source/app/oracle/fast_recovery_area/DB11G' NOFILENAMECHECK;
The time it takes to complete varies depending on the size of the database and the specification of the server. Once the process is finished RMAN produces a completion message and you have your duplicate instance.
Active Database Duplication
Oracle 11g introduced the ability to create duplicate databases directly without the need for a backup. This is known as active database duplication. The process is similar to the backup-based duplication, with a few exceptions.
First, and most obviously, you don't need a backup of the source system, but it does have to be in ARCHIVELOG
mode.
The passwords in the password files must match for both servers, so remember to set the correct password when creating the password file on the destination server.
Both the source and destination database servers require a "tnsnames.ora" entry for the destination database. In this case I added the following to each server. The destination server still requires the source entry shown in the previous section.
# Added to the tnsnames.ora on source and destination server. DB11G-DESTINATION = (DESCRIPTION = (ADDRESS_LIST = (ADDRESS = (PROTOCOL = TCP)(HOST = ol5-112-dup2)(PORT = 1521)) ) (CONNECT_DATA = (ORACLE_SID = DB11G) ) )
The destination server requires static listener configuration in a "listener.ora" file. In this case I used the following configuration. Remember to restart or reload the listener.
SID_LIST_LISTENER = (SID_LIST = (SID_DESC = (GLOBAL_DBNAME = DB11G.WORLD) (ORACLE_HOME = /u01/app/oracle/product/11.2.0/db_1) (SID_NAME = DB11G) ) ) LISTENER = (DESCRIPTION_LIST = (DESCRIPTION = (ADDRESS = (PROTOCOL = TCP)(HOST = ol5-112-dup2.localdomain)(PORT = 1521)) ) (DESCRIPTION = (ADDRESS = (PROTOCOL = IPC)(KEY = EXTPROC1521)) ) ) ADR_BASE_LISTENER = /u01/app/oracle
When connecting to RMAN, you must use a connect string for both the target and auxiliary connections.
$ ORACLE_SID=DB11G; export ORACLE_SID $ rman TARGET sys/password@DB11G-SOURCE AUXILIARY sys/password@DB11G-DESTINATION
Include the FROM ACTIVE DATABASE
clause in the DUPLICATE
command.
DUPLICATE DATABASE TO DB11G FROM ACTIVE DATABASE SPFILE NOFILENAMECHECK;
RMAN-06054 : Unknown Archived Log
During the duplicate operation you may encounter the following error.
RMAN-06054: media recovery requesting unknown archived log for thread 1 with sequence ???? and starting SCN of ????
Here are some things to think about when trying to resolve this.
- If this is a backup-based duplicate, it is possible you have not copied all the archived redo logs from the target to the auxiliary backup location. If you can, copy the missing logs across and try again.
- If this is a backup-based duplicate and you can't copy across the missing archived redo logs, you may need to do a point in time duplicate, described above, to leave you in a consistent state prior to the transactions contained in the first missing log.
- If this is an active duplicate, all necessary logs should be shipped automatically from the target to the auxiliary instance. This can only fail if the archived redo logs on the target system have been removed during the clone operation. This could happen if an archived redo log backup has taken place on the target server during the clone operation and deleted the backed up logs. If this is the case, either disable the backup of the target system during the clone operation, or stop using active duplicates.
For more information see:
- Duplicating a Database
- Step by Step Guide on Creating Physical Standby Using RMAN DUPLICATE...FROM ACTIVE DATABASE [ID 1075908.1]
Hope this helps. Regards Tim...
参考至:https://oracle-base.com/articles/11g/duplicate-database-using-rman-11gr2
如有错误,欢迎指正
邮箱:czmcj@163.com
相关推荐
Oracle 11gR2 使用 RMAN duplicate from active database 复制数据库 Oracle 11gR2 中使用 RMAN duplicate from active database 复制数据库是一种高效的数据库复制方法。这种方法可以直接从活动数据库复制,省去...
本文档主要介绍 Oracle Rman Active Database Duplicate 迁移方案,适用于 Oracle 11g/12c 版本。该方案旨在帮助数据库管理员快速迁移数据库,减少迁移时间和风险。 第 1 章概述 ================ 本文档将介绍 ...
在 **Oracle 11g R2** 版本中,提供了两种主要的方式来创建 Duplicate Database: 1. **Active Database Duplication**:这是一种通过网络直接将目标数据库的数据复制到辅助数据库的方式。这种方式不需要先对目标...
Oracle RMAN Database Duplication is a deep dive into RMAN's duplication feature set, showing how RMAN can make it so much easier for you as a database administrator to satisfy the many requests from ...
### ORACLE RMAN DUPLICATE 数据库复制详解 #### 概述 在Oracle环境中,通过RMAN(Recovery Manager)工具可以高效地复制整个数据库。本文将详细介绍如何利用RMAN的`DUPLICATE`命令来实现数据库的复制,并针对两种...
Oracle Database Backup and Recovery User's Guide 11g Release 2 (11.2) 是一份详细的手册,旨在为数据库管理员提供有关Oracle数据库备份和恢复的全面指导。这份指南涵盖了多个关键领域,包括使用恢复管理器(RMAN...
【使用RMAN DUPLICATE...FROM ACTIVE DATABASE 创建物理备库】 在Oracle数据库管理中,创建物理备用数据库(Physical Standby Database)是数据保护策略的重要组成部分,主要用于实现Data Guard环境中的灾难恢复和...
Oracle数据库11g是一个企业级关系型数据库管理系统,它支持高度的数据可用性和大规模数据量的管理。在本文中,我们将讨论如何将Oracle 11g RAC(Real Application Clusters)环境搭建为单实例的物理备库。这是一个...
rman target /@ortest auxname=(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=192.168.43.114)(PORT=1521)))(CONNECT_DATA=(SERVICE_NAME=ortest))) duplicate target database to standby ...
至于提供的第二个文件"MySQL主从复制、搭建、状态检查、中断排查及备库重做 实战手册.pdf",虽然与Oracle 11gR2的RMAN和Data Guard不直接相关,但它讲述了MySQL的主从复制,这是另一种数据库高可用性方案,适用于对...
用 Duplicate target database传输时前30s传输很快,当到了30s后,传输速度每10分钟1M.导致数据库文件无法Duplicate。
$ export ORACLE_SID=ora11 $ RMAN TARGET/ (nocatalog下) RMAN> SET DBID 840418022; RMAN> STARTUP NOMOUNT; RMAN> RESTORE SPFILE TO '/u01/app/oracle/admin/oradprod.ora' FROM '/dbbak/DPROD_20150920_...
总之,Oracle 11g RAC-RAC DG Duplicate的搭建是一个复杂的过程,需要细心规划和严谨的操作。通过这个文档,我们可以了解到从备份、参数设置、redo log管理到Data Guard配置等一系列关键步骤,这些都是确保数据库高...
在Linux环境下,Oracle 11g R2 Data Guard是一种高可用性和灾难恢复解决方案,它通过在不同的物理或逻辑位置维护一个或多个备用数据库,来保护关键业务数据免受硬件故障、自然灾害或其他潜在的数据丢失风险。...
RMAN> DUPLICATE TARGET DATABASE TO standby NOFILENAMECHECK DISK '/u01/app/oracle/standby/' SET NEWNAME FOR DATABASE TO 'dg'; ``` ### 15. 配置Standby Redo Log #### 配置备库重做日志文件 在备库上创建...
RMAN> DUPLICATE TARGET DATABASE TO standby FROM ACTIVE DATABASE; ``` 这个命令将从活动的主数据库复制所有的结构和数据到备用数据库。 6. **同步备用数据库**: 创建备用数据库后,需要定期使用`switch log...
Oracle 11gR2 dataguard搭建说明
Oracle数据库在windows上的复制方法。
configure 'duplicate target database for clone from active database'; backup database plus archivelog; report obsolete; delete noprompt obsolete; } ``` 五、使用Legato调度RMAN脚本 在Legato环境...