Les 08 Dupe Db

21
8 Copyright © 2007, Oracle. All rights reserved. Using RMAN to Duplicate a Database

description

oracledba-interview.blogspot.com

Transcript of Les 08 Dupe Db

Page 1: Les 08 Dupe Db

8Copyright © 2007, Oracle. All rights reserved.

Using RMAN to Duplicate a Database

Page 2: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 2

Objectives

After completing this lesson, you should be able to:

• List the purposes of creating a duplicate database

• List the methods of duplicating a database

• Duplicate a database using RMAN

• Use an RMAN backup to duplicate a database

• Duplicate a database based on a running instance

Page 3: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 3

Using RMAN to Create a Duplicate Database

Use the RMAN DUPLICATE command to create a duplicate database using target database backups.

Archivedredo log files

Data file backups

Target database

Auxiliary instance

Page 4: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 4

Using a Duplicate Database

You can use a duplicate database to:

• Test backup and recovery procedures

• Recover objects by creating an export and importing the objects into the production database

Page 5: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 5

Creating a Duplicate Database

1. Create an Oracle password file for the auxiliary instance.

2. Establish Oracle Net connectivity to the auxiliary instance.

3. Create an initialization parameter file for the auxiliary instance.

4. Start the auxiliary instance in NOMOUNT mode.

5. Mount or open the target database.

6. Ensure that backups and archived redo log files are available.

7. Allocate auxiliary channels if needed.

8. Execute the DUPLICATE command.

Page 6: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 6

Creating an Initialization Parameter File for the Auxiliary Instance

Specify parameters as follows:

• DB_NAME– If the duplicate database is in the same Oracle home as the

target database, names must be different.– Use the same value in the DUPLICATE command.

• DB_BLOCK_SIZE– Specify the same value as set for the target database.

Page 7: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 7

Specifying Parameters for Control File Naming

Specify the following parameters to control the naming of the files of your auxiliary database:

• CONTROL_FILES• DB_FILE_NAME_CONVERT• LOG_FILE_NAME_CONVERT

CONTROL_FILES='/u01/app/oracle/oradata/aux/control01.ctl', '/u01/app/oracle/oradata/aux/control02.ctl', '/u01/app/oracle/oradata/aux/control03.ctl'DB_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/aux'LOG_FILE_NAME_CONVERT='/u01/app/oracle/oradata/orcl', '/u01/app/oracle/oradata/aux'

Page 8: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 9

Starting the Instance in NOMOUNT Mode

• Start the auxiliary instance in NOMOUNT mode.

• Create a server parameter file (SPFILE) from the text initialization parameter file you used to start the instance.

SQL> startup nomount pfile='$HOME/auxinstance/initAUX.ora'ORACLE instance started.

Total System Global Area 285212672 bytesFixed Size 1218992 bytesVariable Size 92276304 bytesDatabase Buffers 188743680 bytesRedo Buffers 2973696 bytesSQL> create spfile 2 from pfile='$HOME/auxinstance/initAUX.ora';

File created.

Page 9: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 10

Ensuring That Backups and Archived Redo Log Files Are Available

• Backups of all target database data files must be accessible on the duplicate host.

• Backups can be a combination of full and incremental backups.

• Archived redo log files needed to recover the duplicate database must be accessible on the duplicate host.

• Archived redo log files can be:– Backups on a media manager– Image copies– Actual archived redo log files

Page 10: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 11

Allocating Auxiliary Channels

• Auxiliary channels specify a connection between RMAN and an auxiliary database instance.

• If automatic channels are not configured, allocate auxiliary channels:

– Start RMAN with a connection to the target database, the auxiliary instance, and recovery catalog if applicable.

– Allocate at least one auxiliary channel within the RUN block.

$ rman target sys/oracle@trgt auxiliary sys/oracle@auxRMAN> RUN {ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK; ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK; …

Page 11: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 12

Using the RMAN DUPLICATE Command

• Connect to the target database and the auxiliary instance.

• Specify the same database name that you used in the DB_NAME initialization parameter.

RMAN> RUN {ALLOCATE AUXILIARY CHANNEL aux1 DEVICE TYPE DISK; ALLOCATE AUXILIARY CHANNEL aux2 DEVICE TYPE DISK; … DUPLICATE TARGET DATABASE to auxdb; }

Page 12: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 13

Understanding the RMAN Duplication Operation

When you execute the DUPLICATE command, RMAN performs the following operations:

• Creates a control file for the duplicate database

• Restores the target data files to the duplicate database

• Performs incomplete recovery using all available incremental backups and archived redo log files

• Shuts down and restarts the auxiliary instance

• Opens the duplicate database with the RESETLOGS option

• Creates the online redo log files

• Generates a new, unique database identifier (DBID) for the duplicate database

Page 13: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 14

Specifying Options for the DUPLICATE Command

You can specify the following options with the DUPLICATE command:

Enable RESTRICTED SESSION automaticallyOPEN RESTRICTED

Exclude read-only tablespacesSKIP READONLY

Prevent checking of file namesNOFILENAMECHECK

SKIP TABLESPACE

Option

Exclude named tablespaces

Purpose

Page 14: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 15

Using EM to Clone a Database

Running instance

Existing backup

Clonedatabase

Stagingarea

Or

Or

Page 15: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 16

Cloning a Running Database

Clone a database using one of these sources:

• Open database in ARCHIVELOG mode

• Open database in NOARCHIVELOG mode

• Existing database backup

Page 16: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 17

Cloning a Running Database

Page 17: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 18

Cloning a Running Database

Page 18: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 19

Cloning a Running Database

Fromsource

database

Page 19: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 20

Cloning a Database from a Backup

Existingbackuplocation

Page 20: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 21

Summary

In this lesson, you should have learned how to:

• List the purposes of creating a duplicate database

• List the methods of duplicating a database

• Duplicate a database using RMAN

• Use an RMAN backup to duplicate a database

• Duplicate a database based on a running instance

Page 21: Les 08 Dupe Db

Copyright © 2007, Oracle. All rights reserved.8 - 22

Practice 8 Overview: Using RMAN to Duplicate a Database

This practice covers the following topic:

• Cloning a database using an RMAN backup