11G OCM Backup and Restore REPOS in Archival Mode


I have completed all of the steps in OCM 11G Planning (1) with the backup and recovery of the repos database in archival mode.

Update 2011/12/03 – This post is NOT correct for ARCHIVAL BACKUP.

Put Database into Archival Mode

Stop All Applications

Since OEM is the only application using the repos database, I only had to stop that application:

/opt/oracle/app/OracleHomes/oms10g/bin/emctl stop oms

Changing to ArchiveLog Mode

The procedure to change the repos database to archivelog mode is similar to that in Changing the Database Archiving Mode. I used the following SQL*Plus commands (the LOG_ARCHIVE_DEST parameter was set at the same time):

shutdown immediate
startup nomount
alter system set log_archive_dest_10='LOCATION=USE_DB_RECOVERY_FILE_DEST' scope=both;
alter database mount;
alter database archivelog;
alter database open;

Check Set Up of Archival Mode

The best way to see if archiving is working correctly is to force a switch of the online redo log file using the ALTER SYSTEM command and then checking the V$ARCHIVED_LOG view.

alter system switch logfile;
select * from v$archived_log;

The output shows that an archived redo log file was created in the flashback area:

     RECID      STAMP
---------- ----------
NAME
----------------------------------------------------------------------------------------------------------------------------
   DEST_ID    THREAD#  SEQUENCE# RESETLOGS_CHANGE# RESETLOGS RESETLOGS_ID FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ----------------- --------- ------------ ------------- --------- ------------ ---------
    BLOCKS BLOCK_SIZE CREATOR REGISTR STA ARC APPLIED   DEL S COMPLETIO DIC DIC END BACKUP_COUNT ARCHIVAL_THREAD#
---------- ---------- ------- ------- --- --- --------- --- - --------- --- --- --- ------------ ----------------
ACTIVATION# IS_ COM FAL END_OF_RED BAC
----------- --- --- --- ---------- ---
         1  707778437
/opt/oracle/app/flash_recovery_area/REPOS/archivelog/2010_01_08/o1_mf_1_2_5ng0ynpr_.arc
        10          1          2           8434725 08-JAN-10    707742148       8458497 08-JAN-10      8477642 08-JAN-10
     30066        512 ARCH    ARCH    NO  YES NO        NO  A 08-JAN-10 NO  NO  NO             0                1
 1882610316 YES NO  NO             NO

Backup Database in Archive Mode

I ran the following RMAN command to backup the database in online mode:

backup database archivelog all format '/opt/oracle/backup/repos/%U.dbf';

The RMAN log is:

Starting backup at 08-JAN-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=131 device type=DISK
Datafile headers of locally managed datafiles need to be updated.
This operation might take some time.
Update of datafile headers of locally managed datafiles finished.
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
input datafile file number=00005 name=/opt/oracle/app/oradata/REPOS/mgmt.dbf
input datafile file number=00001 name=/opt/oracle/app/oradata/REPOS/system01.dbf
input datafile file number=00002 name=/opt/oracle/app/oradata/REPOS/undotbs01.dbf
input datafile file number=00003 name=/opt/oracle/app/oradata/REPOS/sysaux01.dbf
input datafile file number=00006 name=/opt/oracle/app/oradata/REPOS/mgmt_ecm_depot1.dbf
input datafile file number=00007 name=/opt/oracle/app/oradata/REPOS/rman_catalog01.dbf
input datafile file number=00004 name=/opt/oracle/app/oradata/REPOS/users01.dbf
channel ORA_DISK_1: starting piece 1 at 08-JAN-10
channel ORA_DISK_1: finished piece 1 at 08-JAN-10
piece handle=/opt/oracle/app/flash_recovery_area/REPOS/backupset/2010_01_08/o1_mf_nnndf_TAG20100108T211721_5ng1kksc_.bkp tag=TAG20100108T211721 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting archived log backup set
channel ORA_DISK_1: specifying archived log(s) in backup set
input archived log thread=1 sequence=2 RECID=1 STAMP=707778437
channel ORA_DISK_1: starting piece 1 at 08-JAN-10
channel ORA_DISK_1: finished piece 1 at 08-JAN-10
piece handle=/opt/oracle/backup/repos/0al2vmgo_1_1.dbf tag=TAG20100108T211721 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 08-JAN-10

Starting Control File and SPFILE Autobackup at 08-JAN-10
piece handle=/opt/oracle/backup/repos/c-1882277977-20100108-01 comment=NONE
Finished Control File and SPFILE Autobackup at 08-JAN-10

Interesting that the datafile backup is to the flashback recovery area instead of where I thought I had backed up the datafiles (/opt/oracle/backup/repos). The problem is that the backup command should have been:

backup
  database format '/opt/oracle/backup/repos/%U.dbf'
  archivelog all format '/opt/oracle/backup/repos/%U.dbf';

Test Backup

The simple test I used to test the backup was to delete a datafile and recover it.

Drop users01.dbf

I chose the USERS tablespace because it is not used by the OEM or RMAN applications. I just removed the only datafile (users01.dbf) in the USERS tablespace as follows:

cd /opt/oracle/app/oradata/REPOS
rm users01.dbf

Restore and Recover user01.dbf

To restore the users01.dbf file, the USERS tablespace has to be taken offline. The USERS tablespace was then restored and recovered before being brought back online. I used the following RMAN commands to achieve this:

sql "alter tablespace users offline";
restore tablespace users;
recover tablespace users;
sql "alter tablespace users online";

The log of the whole process is as follows:

RMAN> sql "alter tablespace users offline";

sql statement: alter tablespace users offline

RMAN> restore tablespace users;

Starting restore at 08-JAN-10
using channel ORA_DISK_1

channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /opt/oracle/app/oradata/REPOS/users01.dbf
channel ORA_DISK_1: reading from backup piece /opt/oracle/app/flash_recovery_area/REPOS/backupset/2010_01_08/o1_mf_nnndf_TAG20100108T211721_5ng1kksc_.bkp
channel ORA_DISK_1: piece handle=/opt/oracle/app/flash_recovery_area/REPOS/backupset/2010_01_08/o1_mf_nnndf_TAG20100108T211721_5ng1kksc_.bkp tag=TAG20100108T211721
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 08-JAN-10

RMAN> recover tablespace users;

Starting recover at 08-JAN-10
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 08-JAN-10

RMAN> sql "alter tablespace users online";

sql statement: alter tablespace users online

Conclusion

This completes steps #9 and #10 of the first phase of OCM practice as descibed in OCM 11G Planning (1).

Advertisements

One thought on “11G OCM Backup and Restore REPOS in Archival Mode

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s