Pages

Saturday, December 11, 2010

Active Database Duplication

In Oracle 11g, the live source database can be copied over the network to the duplicate database instance without the need of a backup. RMAN automates the following steps in duplicating operation.

Duplicate the password file.
Creates a default server parameter file.
Copies the latest control file.
Mounts the controlfile.
Copies the datafiles.
Performs incomplete recovery.
Opens the duplicate database with RESETLOGS option.

Run the commands on the server running the duplicate database.

$ export ORACLE_SID=<dupdb>
$ rman TARGET sys/password@<sourcedb> AUXILIARY / cmdfile=backupdb.cmd

$ cat backupdb.cmd

run {
                DUPLICATE TARGET DATABASE TO '<dupdb>'
                FROM ACTIVE DATABASE
                PASSWORD FILE
                SPFILE
                PARAMETER_VALUE_CONVERT='<sourcedb>','<dupdb>'
                SET CONTROL_FILES='<controlfile1_path>','<controlfile2_path>'
                SET DB_FILE_NAME_CONVERT='<source_dir>','<dup_dir>'
                SET LOG_FILE_NAME_CONVERT='<source_dir>','<dup_dir>'
                SET DB_UNIQUE_NAME='<dupdb>'
                SET SGA_MAX_SIZE='<size>'
                SET SGA_TARGET='<size>'
                NOFILENAMECHECK;
       }

To create standby database

run {
                ALLOCATE CHANNEL c1 TYPE DISK;
                ALLOCATE CHANNEL c2 TYPE DISK;
                ALLOCATE AUXILIARY CHANNEL s1 TYPE DISK;
                DUPLICATE TARGET DATABASE FOR STANDBY
                FROM ACTIVE DATABASE
                PASSWORD FILE
                SPFILE
                PARAMETER_VALUE_CONVERT='<sourcedb>','<dupdb>'
                SET CONTROL_FILES='<controlfile1_path>','<controlfile2_path>'
                SET DB_FILE_NAME_CONVERT='<source_dir>','<dup_dir>'
                SET LOG_FILE_NAME_CONVERT='<source_dir>','<dup_dir>'
                SET DB_UNIQUE_NAME='<dupdb>'
                SET LOG_ARCHIVE_MAX_PROCESSES=10
                SET FAL_SERVER='<sourcedb>'
                SET STANDBY_FILE_MANAGEMENT=AUTO
                SET LOG_ARCHIVE_DEST_2='SERVICE=<sourcedb> LGWR SYNC NOAFFIRM VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=<sourcedb>;
     }

             


Sunday, November 28, 2010

Agent is unable to communicate with the OMS

Sometimes the following fake alert wakes up the oncall DBA and clears itself after a couple of minutes due to the busy network.

Target Name=<host>:3872
Message=Agent is unable to communicate with the OMS. (REASON = Agent is Unreachable (REASON : Agent to OMS Communication is brokenError in request response).
Severity=Unreachable Start

Find target_guid for this target agent.
select target_guid from sysman.mgmt_targets where target_name='<host>:3872';

Increase max_inactive_time from the default value 120 sec to 240 sec.
SQL> update sysman.mgmt_emd_ping
  2  set  MAX_INACTIVE_TIME=240
  3  where target_guid='<target_guid>';

Sunday, August 15, 2010

RMAN Incrementally Updated Backup

The RMAN Incrementally Updated Backup feature was introduced in Oracle 10g. It creates image copies of the datafiles, and then subsequently updates those image copies with incremental backups. This backup strategy reduces the time needed for daily backups and saves bandwidth when backing up over network because this merges level 1 incremental backups into existing image copy.

run {
         recover copy of database with tag 'incr_update';
         backup incremental level 1 for recover of copy with tag 'incr_update'
         database;
       }

The RECOVER COPY command updates each datafile image copy with the previous level 1 incremental. If it doesn't find an image copy to update or level 1 to apply, the command generates a message but doesn't generate an error.

The BACKUP command creates level 1 incremental backup. If level 0 image copy doesn't exist, it creates one with specified tag.

The first run of the script creates level 0 image copy backup. The second run of the script creates level 1 differential incremental backup. On the 3rd run and all subsequent runs, there is a image copy updated with previous level 1 incremental and a new level 1 incremental. If the above script is scheduled to run each night, the following files will be available for a point-in-time recovery.

1. An image copy of database one day earlier.
2. An incremental backup of last night.
3. Archive logs to reach the desired SCN.

To improve incremental backup performance, enable change tracking to record changed blocks in each datafile in a file.

To enable change tracking. This will create the change tracking file in DB_CREATE_FILE_DEST.
SQL> alter database enable block change tracking;

To create the change tracking file in specific location.
SQL> alter database enable block change tracking using file '/u03/oradata/bct.dbf' reuse;

To disable change tracking.
SQL> alter database disable block change tracking;

To determine whether block change tracking is used.
SQL> select completion_time, file#, datafile_blocks, block_read, blocks, used_change_tracking from v$backup_datafile order by 1,2;