Quantcast
Channel: Cloud Training Program
Viewing all articles
Browse latest Browse all 1891

[Q/A]: Database Refresh using RMAN Active Duplicate

$
0
0

This post is covering one of the queries that we get in our Oracle Database Cloud Training. We get a lot of queries from Trainees in our training so we thought to cover the common questions that we usually get in each batch so this can be beneficial for others as well if they are having the same question in their mind. So here is the one query from Trainee.

Que: We need to do database refresh, where we need to copy data from the production database to dev database using RMAN active duplicate; hence need help to prepare an RMAN Script for the copy. Example how the script it should be and how many channels should be used?

Ans. Make sure you follow these guidelines for network-enabled database duplication. Both the source and destination databases must be known to Oracle Net.

  • The source database can be mounted or open.
  • If the source database is mounted, you must have shut it down cleanly prior to starting it up in mount mode.
  • If the source database is open, it must be running in archivelog mode.
  • You can continue to use the source database normally while the database duplication is going on, but be aware that there’s an overhead cost of CPU and network bandwidth consumption for sending the data.
  • You must use a password file during active database duplication, unlike in the case of backup-based duplication, where a password file isn’t necessary. The password file makes it possible to connect to the auxiliary instance with the same SYSDBA password as the source database. You must use the same SYSDBA password for both the source and the auxiliary database. Alternatively, you can specify the password file option within the duplicate database command.

Step1: On DEV Host, Start the auxiliary database (duplicate database) instance. You must start the new instance in the nomount mode since you don’t have a control file for this new database yet. The contents of the SPFILE for the auxiliary instance will look like this:
db_name = dev

You need only one parameter, db_name, to denote the name of your new duplicate database.

SQL> connect / as sysdba
Connected to an idle instance
SQL> startup nomount

Step 2: Startup RMAN, and connect to the target (prod) database

RMAN> connect target sys/welcome1@prod

Step 3: Connect to the duplicate database using the keyword auxiliary through an SQL*Net connection:
RMAN> connect auxiliary dev
auxiliary database Password:

Step 4: Issue the duplicate target database command to start the database duplication process. If you were to perform the active database duplication on a different host with the same directory structure, your database duplication command must include the nofilenamecheck clause

RMAN> duplicate database
to dev
from active database
nofilenamecheck;

If the source database files are spread over multiple directories, you must use the set newname parameter instead of the db_file_name_convert parameter to rename the files in the duplicate database.

RMAN> run
{
set newname for datafile 1 to ‘/u01/app/oracle/testdata/system01.dbf’;
set newname for datafile 2 to ‘/u01/app/oracle/testdata/sysaux01.dbf’;
set newname for datafile 3 to ‘/u01/app/oracle/testdata/data01.dbf’;
set newname for datafile 4 to ‘/u01/app/oracle/testdata/index01.dbf’;
set newname for datafile 5 to ‘/u01/app/oracle/testdata/undotbs01.dbf’;
duplicate target database to dev
logfile
group 1 (‘/u01/app/oracle/testdata/logs/redo01a.log’,
(‘/u01/app/oracle/testdata/logs/redo01b.log’) size 10m reuse,
group 2 (‘/u01/app/oracle/testdata/logs/redo02a.log’,
(‘/u01/app/oracle/testdata/logs/redo02b.log’) size 10m reuse;
}

The run block shown here duplicates the target database and supplies file names for both data files and online redo log files for the duplicate database

Active database duplication works as follows regarding the various types of source database files:

  • Data files are copied from the source database.
  • Control files are re-created but will be copied from the source database if you specify the for standby clause.
  • Tempfiles are re-created in the location set by the db_create_file_dest parameter.
  • Online redo log files are re-created.
  • Archived redo logs are copied from the source database, but only if needed for duplication.
  • Server parameter files are copied from the source database if you use the spfile clause only.
  • Password files are always copied for standby databases, but for a duplicate database, they’recopied only if you specify the password file option in the duplicate database command.

Like above, We cover a lot of queries from trainees in our DBA to Cloud DBA Course where we cover Cloud concepts, Services, DBCS, Creating Cloud Account, Manage DB, security, storage, REST API, DBCSCLI, EMExpress, Backup and Recovery, Migration and DBCS Performance and much more.

Related/Further Reading:

If you are just starting out in Cloud then I highly recommend you to go through these posts first

Do you want to Move Ahead in your Oracle Cloud Journey?

YES! So your next task is to get yourself registered for our FREE Webinar on Learn How To Build Your First Database On Cloud (PaaS) to start your cloud journey. Click on the image below to register for FREE.

If you liked this post then share with Your Friends over Social Media!

The post [Q/A]: Database Refresh using RMAN Active Duplicate appeared first on Oracle Trainings.


Viewing all articles
Browse latest Browse all 1891

Trending Articles