PeopleSoft

Oracle 9i / 10g RMAN Duplicate Database Errors

October 24, 2008 · Leave a Comment

Recovering from RMAN Errors

The options for Manual Completion of an RMAN Duplication Task vary depending on which phase of the duplication failed. The following examples cover Oracle 9i and 10g. Manual completion steps out outlined per phase and most likely you’ll only two to execute a couple of the steps depending on where the failure occurred.

Restore Failure

If you receive an error during the RMAN restore of the database you need to determine what caused the problem and fix it. If very few files have been restored it may be easier to just start over and rerun the task from the beginning. If the duplication process failed after running for a long period of time and you rather not to start from the beginning (especially if it takes hours+) then you can try to recover manually and attempt to complete the process.

A likely cause if you are going from one server to another server is missing files or the rare outside possibility of a bad block in a file required for restore. You need to address whatever problem caused the file(s) to be missing from the restore location.

Remember that in order to successfully duplicate a database using RMAN’s DUPLICATE feature is that ALL files required to restore the database must be present on the remote server and in the same exact location unless you catalog the files if they are intentionally located in another directory. RMAN will not even start the restore process if it can’t find the backupsets in the expected location. A reason RMAN may be interrupted in this phase is because during the copy operating you ran out of disk space in the filesystem where you were depositing the backupsets, backup current controlfile and backup spfile and RMAN can’t locate one of the backupsets or arcivelog files.

$ export ORACLE_SID= (name of database cloning to)
$ rman target /
RMAN> run {
set until scn xxxxxxxx;
restore current controlfile from ‘restore directory’;
alter database mount;
set newname for datafile 1 to ”;
set newname for datafile 2 to ”;
….
restore datafile i,i2,….;
}

You need to identify the SCN from the output from the failed RMAN duplicate log and you must use the ‘SET NEWNAME’ for each datafile that remains to be restored as DB_FILE_NAME_CONVERT will not work with a normal restore.

For Oracle 10g+ it really is best to start over if RMAN failed during the first phase or restore step. Any files that have already been restored will be skipped and the duplicate process can be restarted without manual intervention.

Phase 2 Failure

This is the controlfile creation or switch of the datafile names after the datafiles have been restored. You need to review the log files and identify what the problem is and make sure you make a list to use for all the datafiles that have not been switched over. You can then attempt to complete this step manually by rename each datafile if the auxiliary instance uses a different file structure or the ASM Disk Group is different than that of the target’s directory structure or ASM Disk Group.

After the rename (switch) of all the datafiles that need to be renamed:

CREATE CONTROLFILE REUSE SET DATABASE RESETLOGS ARCHIVELOG

SQL> alter database backup controlfile to trace;

Phase 3 Failure

Failure during the recovery of the restored datafiles. This is the next phase where each datafile is recovered to either a point in time or SCN. Determine the cause from the log file and then to continue after fixing the problem:

$ rman target / auxiliary sys/@
RMAN> run {
set until scn xxxxxxx;
recover clone database;
alter clone database open resetlogs;
}

Get the ‘UNTIL SCN’ value from the duplicate logfile, connect to the target. Archivelogs will be automatically restored at 10g, restored into the Flash Recovery Area if this is defined. After completing recovery, change the Database Identifier (DBID) using the NID utility on Windows:

$ nid target=sys/oracle

DBNEWID …….
…..
Change database ID of database AUX? (Y/N)=>Y

The manual duplication process should be complete and you can jump down to Step 6 – Final Actions.

Phase 4 Failure

This phase is the controlfile recreation phase. Check the rman duplicate log and identify the reason the recovery didn’t complete – look for:

media recovery complete
Finished recover at

Figure out what the problem is and fix the cause then execute the following after fixing the cause:

CREATE CONTROLFILE REUSE SET DATABASE ‘AUX’ RESETLOGS ARCHIVELOG

Make sure ALL the files have been restored in the DATAFILE section of the RMAN duplicate log.

Phase 5 Failure

This failure would be in the phase that opens the database with resetlogs. Check the log file again and fix the problem. Look for Thread x closed at log sequence y

If the resetlogs was completed, determine what cause the error and fix the problem and restart the auxiliary instance. If resetlogs wasn’t completed successfully, determine what cause that problem and then open the clone database with resetlogs using RMAN (you can’t use SQL*Plus for this step) and connect to the target database first:

$ rman target / auxiliary sys/oracle@
RMAN> alter clone database open resetlogs;

If the duplication process failed only in steps 5 then you are done, no further action is required. The DBID will have already been changed. Otherwise, execute the NID command to change the DBID (Windows).

Final Steps

$ rman target / auxiliary sys/oracle@
RMAN> alter clone database open resetlogs;

Add any temp files missing to the new cloned auxiliary database. Files that were manuall restored to the auxiliary instance will be cataloged as datafile copies. Connect to the original target and execute:

RMAN> list copy of database;
RMAN> crosscheck copy of datafile ;
RMAN> delete expired copy of datafile
;

Categories: DBA · Oracle · RMAN

Duplicating a Database using Oracle 11g RMAN

October 24, 2008 · 1 Comment

RMAN Duplicate Database Feature in 11G

You can create a duplicate database using the RMAN duplicate command. The duplicate database will have a different DBID from the source database and it functions entirely independently because it is completely independent once the duplication has taken place and the duped database is open for use.

Starting with Oracle 11g there are now two ways to duplicate a database:

1. Active database duplication
2. Backup-based duplication

Active database duplication involves copying the live running database over the network to the auxiliary destination and creating the duplicate database. The backup-based duplication requires copying over using NFS to make available the backupset(s) to the destination database. The only difference between the two is you do not need pre-existing RMAN backups and copies (archivelogs). The duplication work is performed by the auxiliary channel and this channel corresponds to a server session on the auxiliary instance on the auxiliary (destination) host.

The active database duplication is slower because it is using the network to transport the data blocks instead of accessing existing RMAN backupsets. RMAN carries out the following steps as part of the duplication process:

1. Creates a control file for the duplicate database
2. Restarts the auxiliary instance and mounts the duplicate control file
3. Creates the duplicate datafiles and recovers them with incremental backups and archived redo logs
4. Opens the duplicate database with the RESETLOGS option

In the case of active database duplication, RMAN copies the target datafiles over the network to the auxiliary (destination) instance.

A RAC Target database can be duplicated as well, this feature is not restricted to non-RAC databases. The procedure is the same as what is outlined below. If the auxiliary database needs to be a RAC-database then you start the process to duplicate a single instance and convert the auxiliary to RAC after the duplicate process has succeeded.

The next section is devoted to describing the process for Active Database Duplication.

Active Database Duplication

1. Prepare the auxiliary database instance
2. Create the initialization parameter file for the Auxiliary instance

If you are using SPFILE then according to Oracle the only parameter required for the duplicate database is the DB_NAME parameter. The rest of the parameters can be set in the DUPLICATE command. If you are not using the SPFILE technique for your Oracle initialization parameter file then you will need to create an init.ora file and set the initialization parameters. Again according to Oracle the only required parameters are:

DB_NAME
CONTROL_FILES
DB_BLOCK_SIZE
DB_FILE_NAME_CONVERT
LOG_FILE_NAME_CONVERT
DB_RECOVERY_FILE_DEST

However, I have found if I use a full meaning a copy of one of my running Database’s parameter file it is easier than specifying the parameters in the DUPLICATE command itself. That is a personal preference and you should go with whatever works best for you. I use SPFILE files for all my Oracle Databases and whenever I have a need to duplicate one of them I will generate (create) an init.ora initialization parameter file for use with RMAN. I will then use my favorite editor to search and replace the database specific parameters with my new Oracle Database parameters like DB_NAME, DB_RECOVERY_FILE_DEST, etc.

3. Create the Oracle Password file for the Auxiliary Instance – this is a requirement for RMAN in order to duplicate a database you need to connect directly to the auxiliary instance using the password file with the same SYSDBA password as the target database’s password. The passwords have to match exactly in order for this to work. You can specify the PASSWORD FILE option on the DUPLICATE command in which case if you do RMAN will copy the source database password file to the destination host and overwrite any existing password file with the same name as the auxiliary instance’s name.

4. Make the necessary changes to the listener.ora and tnsnames.ora file in order to establish SQL*Net connectivity before starting the RMAN duplicate session. You have to be able to connect through Oracle Net to the target and the auxiliary instance in order to use Active Database duplication.
5. Start the Auxiliary instance from SQL*Plus – start the database and put it in nomount mode but first take care of the following steps:

I always create a link in $ORACLE_HOME/dbs to the initialization file and I just rename this link when I’m finished with RMAN to switch over to using a spfile instead of the pfile method. This way you do not have to type in a lot of characters whenever you stop, start the auxiliary instance because more than likely you will have to execute the process more than once unless you get it right the very first time! I set up the ADR – in Oracle 11G the new Automatic Diagnostic Recovery filesystem (if you aren’t using ADR set up the $ORACLE_BASE/admin/$ORACLE_SID/bdump/…._) directories prior to bringing up the auxiliary instance in nomount mode. You will need to create the supporting directories prior to starting the auxiliary instance.

Windows:

Create the parameter file (using Oracle’s example):

initNEW.ora
DB_NAME=NEW
diagnostic_dest=’E:\opt\oracle’
DB_FILE_name_CONVERT=(‘I:\oradata\OLD’,'E:\oradata\NEW’)
LOG_FILE_NAME_CONVERT=(‘I:\oradata\onlinelog\OLD’,'E:\oradata\onlinelog\NEW’)
SGA_TARGET=26214400
CONTROL_FILES=’E:\oradata\controlfile\NEW\control01.dbf’
COMPATIBLE=11.1.0.0.0

Create the Database Service (Windows Only) and password file:

% set ORACLE_SID=NEW
% set ORACLE_HOME=E:\opt\app\oracle\product\11.1.0\db_1
% oradim -NEW -SID NEW
% orapwd FILE=E:\opt\app\oracle\product\11.1.0\db_1\database\PWPDNEW.ora PASSWORD=sys

% sqlplus “/ as sysdba”
sql> startup nomount;

6. Create the necessary Oracle Net connectivity in the listener.ora and tnsnames.ora files – you need to make sure you specify SERVER = DEDICATED in the tnsnames.ora entry for your auxiliary instance and if you are using Oracle on HP-UX 11i v3 Itanium there is a bug that requires you to use the string ‘(UR=A)’ at the end of the tnsnames.ora entry (put it after the SERVICE_NAME entry). Confirm the connectivity to the target, auxiliary and you may want to confirm connectivity to your RMAN catalog even though you will not be using the catalog for this type of database duplication.

7. Start RMAN and connect to the source database by specifying the source as the target database. The duplicate database instance will be specified in the AUXILIARY connection. You can invoke the RMAN client on any host so long as that host has connectivity and you can connect to all of the required database instances. If the auxiliary instance requires a text-based initialization parameter file (pfile) then this file must exist and it must reside on the same host that runs the RMAN client application.

% rman
rman> connect target sys/sys@old;
rman> connect auxiliary sys/sys

8. Next you will be issuing the DUPLICATE database command in order to start the duplicate process and the simplest case is when you duplicate the target database to a different host and use a different directory structure. This example will assume you are using a recovery catalog, the target database is on hosta and it contains four datafiles. You duplicate the target to database AUX on a different host (hostb) and hostb has a different directory structure. The tablespace USERS is a read-only tablespace for the purpose of this example. Execute the duplciate database command from the Auxiliary site:

rman duplicate target database to ‘NEW’ from active database db_file_name_convert ‘i:\oradata\OLD’,'e:\oradata\NEW’;

A dedicated listener configuration for RMAN is required. Using instance registration requires that the database be mounted in order to register with the listener. RMAN also requires SYSDBA access to the nomount instance (Auxiliary). The control files will be create using the location and names specified in the Oracle initialization file. The use of log_file_name_convert and db_file_name_convert instructs RMAN to generate the “set newname” commands for you. You can create your own set instead of using these two commands and you can use the ‘logfile’ command to specify where the log files will be created and what size they will be created with.

Categories: Uncategorized

RMAN 11g Snapshot Standby Database

October 24, 2008 · 1 Comment

Snapshot Standby Database

Oracle 11g introduces a new type of database – the Snapshot Standby Database which allows the use of a physical standby databasee in read-write mode for a short period of time. A snapshot standby database is a fully updatable standby database that is created by converting a physical standby database into a snapshot standby database.

This database is open in the read-write mode and as thus it is possible to process transactions apart from the primary database. It maintains protection by continual feed from the production database by archiving that data for later use.

Using a single command change made while the database is in read-write mode can throw away the changes made to the standby database only and re-synchronize the standby database with the production database.

Snapshot Database has these Characteristics

1. Snapshot standby database receives and archive but does not apply the redo data.
2. Redo data received from the primary database is applied automatically once the standby database is converted back into a physical standby database.
3. Data from the primary database is always protected as the archivelogs are being received and stored in their designated location.
4. All local updates will be discarded when the snapshot database is converted back to physical standby database.
5. If the primary database moves to a new database branch (for example, because of a Flashback Database or an OPEN RESETLOGS), the snapshot standby database will continue accepting redo from the new database branch.
6. Snapshot standby database cannot be the target of a switchover or failover. A snapshot standby database must first be converted back into a physical standby database before performing a role transition to it.
7. After a switchover or failover between the primary database and one of the physical or logical standby databases in a configuration, the snapshot standby database can receive redo data from the new primary database after the role transition.
8. Snapshot standby database cannot be the only standby database in a Maximum Protection Data Guard configuration.

Once the snapshot standby is activated this database diverges from its primary database over time because redo data from the primary database is not applied. Local updates to the snapshot standby database will cause additional divergence.

Steps to Convert Physical Standby Database to the Snapshot Standby Database

The conversion from physical standby to snapshot standby database can be done through the command:

ALTER DATABASE CONVERT TO SNAPSHOT STANDBY;

1. If not already configured, configure flash recovery area as show below:

first set the size of the recovery area

alter system set db_recovery_file_dest_size=;

Next, set the location

alter system set db_recovery_file_dest=;

Bring the physical standby database to mount stage:

Stop managed recovery if it is active and convert the physical standby database to snapshot standby database

alter database convert to snapshot standby;

The database is dismounted during conversion and must be restarted after the conversion completes.

SQL> select open_mode, database_role from v$database;

The database is now ready for transactions.
An implicit restore point is created when a physical standby database is converted into a snapshot standby database and this restore point is used to flashback a snapshot standby database to its original state when it is converted back into a physical standby database from a snapshot standby database.

Steps to Convert the Snapshot Standby Database Back to the Physical Standby Database:

1. shutdown the snapshot standby database
2. bring the database to the mount state
3. issue the following command

alter database convert to physical standby;

4. shutdown the database and mount it again

SQL> select open_mode, database_role from v$database;

You are now ready to start the media recovery process.

Once a snapshot standby database has been converted back into a physical standby database and restarted – start the process of applying the redo logs and all of the redo received by the snapshot standby database will be applied to the physical standby database to roll it forward.

Flashback Database is used to convert a snapshot standby database back into a physical standby database. Any operation that cannot be reversed using the Flashback Database technology will prevent a snapshot database being converted back to a physical standby.

Categories: RMAN
Tagged: ,

RMAN Cataloging Backups / Archivelogs in RMAN 10g / 11g

October 24, 2008 · Leave a Comment

Oracle Server Version 9.2.0.8.0 to 11.1

How to catalog backups / archivelogs / datafile copies / control file copies, etc. in various versions of Oracle.

The RMAN Catalog is used to accomplish the following:

- Add backup pieces and image copies on disk to the RMAN repository
- Record a datafile copy as a level 0 incremental backup in the RMAN repository, which enables you to use it as part of an incremental backup strategy.
- Record the existence of the last user-managed datafile copies made after the final shutdown

Restrictions and Usage Notes:

1 You must be connected to the target database which must be mounted or open.
2. If RMAN is connected to a recovery catalog, then the catalog database must be opened
3. For a user-managed copy to be cataloged, it must be a datafile copy, control file copy, archived log or backup piece.
4. Accessible on disk
5. You cannot use CATALOG to catalog a file that belongs to a different database.

RMAN treats all user-managed backups as image copies. Note that during cataloging, RMAN does not check whether the file was correctly copied by the operating system utility; it just reads and checks the header.

Examples:
1. Cataloging an Archived Redo Log: This example assumes that you made an operating system copies of the archived logs or transferred them from another location, and then added them to the RMAN repository:

CATALOG ARCHIVELOG ‘?/oradata/archive1_30.dbf’,'?/oradata/archive1_31.dbf’,'?/oradata/archive1_32.dbf’;

2. Cataloging a File Copy as an Incremental Backup: The following example catalogs datafile copy users01.bak as an incremental level 0 backup:

CATALOG DATAFILECOPY ‘?/oradata/users01.bak’ LEVEL 0;

Note: That you can create datafile copies either using the RMAN BACKUP AS COPY command, or by using operating system utilities in conjunction with ALTER TABLESPACE BEGIN/END BACKUP.

3. The following example catalogs a user managed controlfile copy in the RMAN Repository:

The command to take a controfile copy is below:

SQL> alter database backup controlfile to ‘disk1/controlfile01.dbf’;

The command to catalog a controlfile copy is blow:

RMAN> catalog controlfilecopy ‘rdisk1/control01.ctl’;

4. Cataloging Multiple Copies in a Directory:
The following example catalogs a directory full of archived logs that were copied into the /tmp/arch_logs directory with an operating system utility:

CATALOG START WITH ‘/tmp/arch_logs’;

5. Cataloging Files in the Flash Directory Area:
The following example catalogs a directory enabled flash recovery area without prompting the user for each one:

CATALOG RECOVERY AREA NOPROMPT;

6. Cataloging Backup Pieces:
The following example catalogs a RMAN backup piece that was copied with an operating system utility:

CATALOG BACKUPPIECE ‘?/oradaata/01dmsbj4_1_1.log’;

7. The Command Below will catalog the Backup Pieces Help in the Location set for DB_RECOVERY_FILE_DEST Parameter:

RMAN> catalog db_recovery_file_dest;

Note: All of the above examples are valid for 10g and 11g but the examples 4,5,6 and 7 are not possible for 9i as these features are not available in 9i.

catalog backuppiece, catalog recovery area, catalog start with, catalog db_recovery_file_dest commands are not available in 9i.

Categories: Oracle · RMAN
Tagged: ,