April 29, 2008

OEM - Unable to access Recovery Catalog

Problem: Managing the Production database from Oracle Enterprise Manager Grid control. The recovery catalog is available, the database is registered in recovery catalog, but still OEM gives an error,

Error
Only databases with a version number equal to 10 or above, or databases that use a recovery catalog of schema version 10 or above are supported. You can click the following link to register the database in a recovery catalog.


Solution:
1. In recovery catalog database server, login rman with catalog option.

$> rman catalog sysman/******
RMAN> upgrade catalog;

recovery catalog owner is SYSMAN
enter UPGRADE CATALOG command again to confirm catalog upgrade

RMAN> upgrade catalog

recovery catalog upgraded to version 10.01.00
DBMS_RCVMAN package upgraded to version 10.01.00
DBMS_RCVCAT package upgraded to version 10.01.00

RMAN>

Now if you refresh the OEM page and go to maintenance(T) -> manage current backup URL, it'lll work.

Reference:
Note:298466.1 - Cannot Manage Current Backups with Grid Control even when Recovery Catalog is used

April 16, 2008

Rman backup restore and recover to a new host - Backup "test"

The Restore of a Database to a New Host: Scenario

This scenario assumes the following:
  1. Two networked machines, oracle1 and oracle3, are running Linux.
  2. A target database named srinfra is on oracle1 and uses a recovery catalog rcat
  3. You want to test the restore and recovery of srinfra on oracle3, while keeping database srinfra up and running on oracle1
  4. The directory structure of oracle1 is different from oracle1, so that srinfra is located in /uXX/oradata/srinfra, but you want to restore the database to /u01/oradata/srinfra
    Database srinfra uses a server parameter file (not a client-side initialization parameter file)
  5. The ORACLE_SID for the srinfra database is srinfra and will not change for the restored database
  6. You have a record of the DBID for srinfra
  7. A media manager is accessible by both machines
  8. You have recoverable backups on tape of all datafiles
  9. You have backups of the archived logs required to recover the datafiles
  10. You have control file and server parameter file autobackups on tape

Use the following steps to perform the restore process:

  1. Make backups of the target database available to oracle3. To test disaster recovery, you need to have a recoverable backup of the target database. When preparing your disaster recovery strategy, ensure that the backups of the datafiles, control files, and server parameter file are restorable on oracle3. Hence, you must configure the media management software so that oracle3is a media manager client and can read the backup sets created on oracle1. Consult the media management vendor for support on this issue.
  2. Configure the ORACLE_SID on oracle3. This scenario assumes that you want to authenticate yourself through the operating system, which is much faster than configuring Oracle Net and creating a password file. However, you must be connected to oracle3 either locally or through a SQLNet alias.
    While connected to oracle3 with administrator privileges, edit the /etc/group file so that you are included: in the DBA group:
    dba:*:614:oracle
    Set the ORACLE_SID environment variable on oracle3 to the same value used on oracle1:
    $ export ORACLE_SID srinfra
    Start RMAN and connect to the target instance without connecting to the recovery catalog.
    $ rman TARGET / CATALOG rman/xxxx@rcat
  3. Start the instance without mounting it. To start the instance, you first need to set the DBID.
    Run SET DBID to set the DBID, then run STARTUP NOMOUNT:
    RMAN> SET DBID 1340752057;
    RMAN> STARTUP NOMOUNT;

    RMAN will fail to find the server parameter file, which has not yet been restored, but will start the instance with a "dummy" file. Sample output follows:
    startup failed: ORA-01078: failure in processing system parameters
    LRM-00109: could not open parameter file '/u01/app/oralce/product/10g/dbs/initsrinfra.ora'

    trying to start the Oracle instance without parameter files ...
    Oracle instance started

    Restore and edit the server parameter file.
    Because you enabled the control file autobackup feature when making your backups, the server parameter file is included in the backup sets.
    Allocate a channel to the media manager, then restore the server parameter file (SPFILE) as a client-side pararameter file (PFILE).
    RMAN> RUN {
    ALLOCATE CHANNEL t1 DEVICE TYPE "SBT_TAPE"
    PARMS='SBT_LIBRARY=/u01/app/oracle/product/10g/lib/libobk.so,
    ENV=(NSR_CLIENT=ORACLE1.VOCOLLECT.INT,
    NSR_SERVER=LEGATO1.INTERNAL,
    NSR_DATA_VOLUME_POOL=VCDBO)';

    SET UNTIL TIME="TO_DATE('16-MAR-08 23:59:59','DD-MON-YY HH24:MI:SS')";
    RESTORE SPFILE TO PFILE '/u01/app/oralce/product/10g/dbs /initsrinfra.ora' FROM AUTOBACKUP;

    SHUTDOWN ABORT;
    }

    Next, edit the restored PFILE . Change any location-specific parameters, for example, those ending in _DEST and _PATH, to reflect the new directory structure. For example, edit the following parameters:
    - IFILE
    - *_DUMP_DEST
    - LOG_ARCHIVE_DEST*
    - CONTROL_FILES

    Then restart the instance, using the edited PFILE:
    RMAN> STARTUP FORCE NOMOUNT PFILE='/u01/app/oralce/product/10g/dbs /initsrinfra.ora';

    Restore the control file from an autobackup and then mount the database. RMAN restores the control file to whatever location you specified in the CONTROL_FILES initialization parameter. For example:
    RMAN> RUN {
    ALLOCATE CHANNEL t1 DEVICE TYPE "SBT_TAPE"
    PARMS='SBT_LIBRARY=/u01/app/oracle/product/10g/lib/libobk.so,
    ENV=(NSR_CLIENT=ORACLE1.VOCOLLECT.INT,
    NSR_SERVER=LEGATO1.INTERNAL,
    NSR_DATA_VOLUME_POOL=VCDBO)';

    SET UNTIL TIME="TO_DATE('16-MAR-08 23:59:59','DD-MON-YY HH24:MI:SS')";
    RESTORE CONTROLFILE FROM AUTOBACKUP;
    ALTER DATABASE MOUNT;
    }
    Query the database filenames recorded in the control file on the new host (oracle3). Because the control file is from the “srinfra” database, the recorded filenames use the original oracle1 filenames. You can query V$ views to obtain this information. Start a new SQL*Plus session and connect to the newly created instance on oracle3:
    $ sqlplus '/ AS SYSDBA'
    Run the following query in SQL*Plus:
    SQL> COLUMN NAME FORMAT a60
    SQL> SPOOL 'db_filenames.out'
    SQL> SELECT FILE# AS "File/Grp#", NAME FROM V$DATAFILE
    UNION
    SELECT GROUP#,MEMBER FROM V$LOGFILE;
    SQL> SPOOL OFF
    SQL EXIT

    Write the RMAN recovery script. The script must include the following steps:
    For each datafile on the destination host that is restored to a different path than it had on the source host, use a SET NEWNAME command to specify the new path on the destination host. (If the file systems on the destination system are set up to have the same paths as the source host, then do not use SET NEWNAME for those files restored to the same path as on the source host.)
    For each online redo log that is to be created at a different location than it had on the source host, use SQL ALTER DATABASE RENAME FILE commands to specify the pathname on the destination host. (If the file systems on the destination system are set up to have the same paths as the source host, then do not use ALTER DATABASE RENAME FILE for those files restored to the same path as on the source host.)
    Perform a SET UNTIL to limit media recovery to the end of the archived redo logs.
    Run SWITCH so that the control file recognizes the new path names as the official new names of the datafiles
    Restore and recover the database
    RUN{
    # allocate a channel to the tape device
    ALLOCATE CHANNEL t1 DEVICE TYPE "SBT_TAPE"
    PARMS='SBT_LIBRARY=/u01/app/oracle/product/10g/lib/libobk.so,
    ENV=(NSR_CLIENT=ORACLE1.VOCOLLECT.INT,
    NSR_SERVER=LEGATO1.INTERNAL,
    NSR_DATA_VOLUME_POOL=VCDBO)';

    ALLOCATE CHANNEL t2 DEVICE TYPE "SBT_TAPE"
    PARMS='SBT_LIBRARY=/u01/app/oracle/product/10g/lib/libobk.so,
    ENV=(NSR_CLIENT=ORACLE1.VOCOLLECT.INT,
    NSR_SERVER=LEGATO1.INTERNAL,
    NSR_DATA_VOLUME_POOL=VCDBO)';

    ALLOCATE CHANNEL t3 DEVICE TYPE "SBT_TAPE"
    PARMS='SBT_LIBRARY=/u01/app/oracle/product/10g/lib/libobk.so,
    ENV=(NSR_CLIENT=ORACLE1.VOCOLLECT.INT,
    NSR_SERVER=LEGATO1.INTERNAL,
    NSR_DATA_VOLUME_POOL=VCDBO)';

    # rename the datafiles and online redo logs
    SET NEWNAME FOR DATAFILE 00001 TO '/u01/oradata/srinfra/system01.dbf';
    SET NEWNAME FOR DATAFILE 00002 TO '/u01/oradata/srinfra/undotbs01.dbf';
    SET NEWNAME FOR DATAFILE 00003 TO '/u01/oradata/srinfra/sysaux01.dbf';
    SET NEWNAME FOR DATAFILE 00004 TO '/u01/oradata/srinfra/srdata01.dbf';
    SET NEWNAME FOR DATAFILE 00005 TO '/u01/oradata/srinfra/SRIDX01.dbf';
    SET NEWNAME FOR DATAFILE 00006 TO '/u01/oradata/srinfra/srlarge01.dbf';
    SET NEWNAME FOR DATAFILE 00007 TO '/u01/oradata/srinfra/srlarge02.dbf';
    SET NEWNAME FOR DATAFILE 00008 TO '/u01/oradata/srinfra/srlarge03.dbf';
    SET NEWNAME FOR DATAFILE 00009 TO '/u01/oradata/srinfra/srlarge04.dbf';
    SET NEWNAME FOR DATAFILE 00010 TO '/u01/oradata/srinfra/SRIDX02.dbf';
    SET NEWNAME FOR DATAFILE 00011 TO '/u01/oradata/srinfra/SRDATA02.dbf';
    SET NEWNAME FOR DATAFILE 00012 TO '/u01/oradata/srinfra/undotbs02.dbf';
    SET NEWNAME FOR DATAFILE 00013 TO '/u01/oradata/srinfra/srlarge05.sbf';
    SET NEWNAME FOR DATAFILE 00014 TO '/u01/oradata/srinfra/srdata03.dbf';
    SET NEWNAME FOR DATAFILE 00015 TO '/u01/oradata/srinfra/srdata04.dbf';
    SET NEWNAME FOR DATAFILE 00016 TO '/u01/oradata/srinfra/sridx03.dbf';
    SET NEWNAME FOR DATAFILE 00017 TO '/u01/oradata/srinfra/sridx04.dbf';
    SET NEWNAME FOR DATAFILE 00018 TO '/u01/oradata/srinfra/srdata05.dbf';
    SQL "ALTER DATABASE RENAME FILE ''/u05/oradata/srinfra/redo01-1.log'' TO ''/u01/oradata/srinfra/redo01-1.log''";
    SQL "ALTER DATABASE RENAME FILE ''/u01/oradata/srinfra/redo01-2.log'' TO ''/u01/oradata/srinfra/redo01-2.log''";
    SQL "ALTER DATABASE RENAME FILE ''/u05/oradata/srinfra/redo02-1.log'' TO ''/u01/oradata/srinfra/redo02-1.log''";
    SQL "ALTER DATABASE RENAME FILE ''/u01/oradata/srinfra/redo02-2.log'' TO ''/u01/oradata/srinfra/redo02-2.log''";
    SQL "ALTER DATABASE RENAME FILE ''/u05/oradata/srinfra/redo03-1.log'' TO ''/u01/oradata/srinfra/redo03-1.log''";
    SQL "ALTER DATABASE RENAME FILE ''/u05/oradata/srinfra/redo03-2.log'' TO ''/u01/oradata/srinfra/redo03-2.log''";

    # Do a SET UNTIL TO prevent recovery of the online logs
    SET UNTIL TIME="TO_DATE('16-MAR-08 23:59:59','DD-MON-YY HH24:MI:SS')"; # restore the database and switch the datafile names
    RESTORE DATABASE;
    SWITCH DATAFILE ALL;

    # recover the database
    RECOVER DATABASE;
    }

    RMAN> EXIT;
    RMAN will apply as many of the archived redo logs as it can and leave the database in a state in which is can be opened.
    Now perform an OPEN RESETLOGS at the restored database.
    Caution: When you re-open your database in the next step, do not connect to the recovery catalog. Otherwise, the new database incarnation created is registered automatically in the recovery catalog, and the filenames of the production database are replaced by the new filenames specified in the script.
    If this is a test restore, never connect RMAN to the test-restore database and the recovery catalog.
    From the RMAN prompt, open the database with the RESETLOGS option:
    $ rman TARGET /

    RMAN> ALTER DATABASE OPEN RESETLOGS;