Administration Workshop II 5-27. Incomplete Recovery Best Practices

1. Before starting incomplete recovery, perform a whole closed database backup, including control files and redo logs (see note below). This is helpful in the following ways:

  • It allows you to recover from error: If your recovery fails (for example, you recover past the desired point of recovery), redo logs and control files cannot be used for the next recovery unless there is a backup of these files (that is because we must issue ALTER DATABASE OPEN RESETLOGS after every incomplete recovery).
  • It saves time if the recovery fails: In this situation, you can restore the data files from the new backup, rather than from a previous backup, which needs archives applied.

Note: if a whole backup is not performed, at least archive the current redo log:

SQL> ALTER SYSTEM ARCHIVE LOG CURRENT

and back up the control file:

SQL> ALTER DATABASE BACKUP CONTROLFILE TO '/u01/data/backup.ctl'

2. Also, perform a whole closed backup after a successful recovery. This can save many hours if another recovery is rquired before completion of the next scheduled backup.

3. To prevent error because of using database of incorrect incarnation during recovery, use the %r format option of the log_archive_format database initialization parameter to:

  • Automatically incorporate the database resetlogs ID into the archived log file names
  • Ensure that unique names are constructed for the archived log files across multiple incarnations of the database

May 31, 2008. Uncategorized. Leave a comment.

Alert Log location

The location of alert.log can queried using:

SQL> SHOW PARAMETER BACKGROUND_DUMP;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
background_dump_dest                 string      C:\oracle\admin\orcl\bdump

May 31, 2008. Tags: . Uncategorized. Leave a comment.

Administration Workshop II 4-10. Dropping a redo log member

From: http://www.adp-gmbh.ch/ora/concepts/redo_log_switch.html

SQL> select sequence# from v$log where status = 'CURRENT';

 SEQUENCE#
----------
       523

SQL> alter system switch logfile;

System altered.

SQL> select sequence# from v$log where status= 'CURRENT';

 SEQUENCE#
----------
       524

SQL> alter system checkpoint;

System altered.

SQL> select sequence# from v$log where status = 'CURRENT';

 SEQUENCE#
----------
       524

May 30, 2008. Tags: . Uncategorized. Leave a comment.

Handy Backup commands

Configuration

You can enable Block Change Tracking by issuing the following command:

SQL> ALTER DATABASE ENABLE
  2> BLOCK CHANGE TRACKING
  3> USING FILE '/mydir/rman_change_track.f'
  4> REUSE;

Note: USING FILE '/mydir/rman_change_track.f' is not necessary if Oracle Managed Files is used (it will be created at the location specified by the DB_CREATE_FILE_DEST parameter).

May 25, 2008. Tags: . Uncategorized. Leave a comment.

Administration Workshop II. 3-27. Incrementally Updating Backups

To create incremental backups that can be incrementally updated:

RMAN> BACKUP INCREMENTAL LEVEL 1 ...
   2> FOR RECOVER OF COPY
   3> WITH TAG ...

To recover from the incremental copy:

RMAN> RECOVER COPY OF
   2> DATAFILE {n|'filename'}
   3> WITH TAG 'incr_upd_df1';

May 24, 2008. Tags: . Uncategorized. Leave a comment.

RMAN commands

To enable control file autobackup

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP ON;

To change the default format for autobackup file name

RMAN> CONFIGURE CONTROLFILE AUTOBACKUP
   2> FORMAT FOR DEVICE TYPE disk
   3> TO '/u1/oradata/cf_ORCL_auto_%F';

where %F is mandatory and translates into c-IIIIIIIIII-YYYYMMDD-QQ being:

  • IIIIIIII the DBID
  • YYYYMMDD timestamp of the backup
  • QQ a sequence that starts with 00 and ends with FF

Use the SHOW command to list current settings

RMAN> SHOW CONTROLFILE AUTOBACKUP FORMAT;
RMAN> SHOW EXCLUDE;
RMAN> SHOW ALL;

Use the CLEAR command to reset any persistent settings to its default value:

RMAN> CONFIGURE BACKUP OPTIMIZATION CLEAR;
RMAN> CONFIGURE MAXSETSIZE CLEAR;
RMAN> CONFIGURE DEFAULT DEVICE TYPE CLEAR;

Configure the default device type for automatic channel allocation
RMAN> CONFIGURE DEFAULT DEVICE TYPE TO sbt;

or manually allocate a channel

RMAN> RUN {
   2> ALLOCATE CHANNEL c1 DEVICE TYPE disk;
   3> BACKUP DATAFILE '/u0/oradata/user01.dbf';
   4> }

Configure parallelism

RMAN> CONFIGURE DEVICE TYPE disk PARALLELISM 3;

Specify the maximum backup piece size

RMAN> CONFIGURE CHANNEL DEVICE TYPE DISK MAXPIECESIZE 2G;

Format the name of the generated backup files

RMAN> RUN {
   2> ALLOCATE CHANNEL d1 DEVICE TYPE disk
   3> FORMAT '/disk1/backups/%U';
   4> BACKUP DATABASE PLUS ARCHIVELOG; }

Some backup options (more on Administration Workshop II 3-9)

RMAN> BACKUP device type disk tag '%TAG' database
   2> include current controlfile;
RMAN> BACKUP database plus archivelog;
RMAN> BACKUP datafile '/u0/oradata/user01.dbf';
RMAN> BACKUP AS BACKUPSET TABLESPACE hr_data;

(AS BACKUPSET can be omitted if RMAN is configured in mode BACKUPSET)

After a online backup, remember to archive current redo logs using:

SQL> ALTER SYSTEM ARCHIVE LOG CURRENT;

or all archive logs:

SQL> ALTER SYSTEM ARCHIVE LOG ALL;

or a specific redo group:

SQL> ALTER SYSTEM ARCHIVE LOG GROUP n;

More on backups at http://www.stanford.edu/dept/itss/docs/oracle/9i/server.920/a96519/backup.htm

See backup constraints at Administration Workshop II 3-10
See parallel backup commands at Administration Workshop II 3-11

To create a clone database or a standby database from backups of the target database

RMAN> DUPLICATE database to auxiliaryDb;

To flashback a database

RMAN> FLASHBACK DATABASE
   2> TO TIME = TO_DATE
   3> ('06/25/03 12:00:00','MM/DD/YY HH:MI:SS');

after you have performed flashback database you should remember to reset logs:

SQL> ALTER DATABASE RESETLOGS;

To restore/recover

RMAN> RESTORE/RECOVER database;
RMAN> RESTORE/RECOVER tablespace;
RMAN> RESTORE/RECOVER datafile;

Reporting command LIST (Administration Workshop II 3-28 )

RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST BACKUP OF DATAFILE
   2> '/db01/ORADATA/u03/users01.dbf'

List backup sets and copies of any data file in a specified tablespace:

RMAN> LIST COPY OF TABLESPACE "SYSTEM";

List backup sets and copies containing archive logs for a specified range:

RMAN> LIST COPY OF DATABASE ARCHIVELOG
   2> FROM TIME='SYSDATE -7';

Reporting command REPORT (Administration Workshop II 3-29)
What is the structure of the datgabase?

RMAN> REPORT SCHEMA;

Which files need to be backed up?

RMAN> REPORT NEED BACKUP ...;

Which backups can be deleted?

RMAN> REPORT OBSOLETE;

Which files are not recoverable because of unrecoverable operations?

RMAN> REPORT UNRECOVERABLE ...;

For catalog maintenance (Administration Workshop II 3-8 )

  • CROSSCHECK
  • DELETE
  • CHANGE
  • LIST

May 17, 2008. Tags: , . recovery, rman. Leave a comment.

RMAN command-line arguments

(Administration Workshop II 2-27)
First set the ORACLE_SID env

$ export ORACLE_SID=orcl

Writing RMAN output to a log file

$ rman TARGET sys/oracle LOG=$HOME/oradata/u03/rman.log APPEND

Executing a command file when RMAN is invoked

$ rman TARGET sys/oracle CMDFILE=$HOME/scripts/my_rman_script.rcv

Establishes database connections on RMAN startup (both TARGET and CATALOG DBs)

$ rman TARGET sys/oracle@orcl CATALOG rman/rman@rcat

Note: NOCATALOG is the default mode (rman will use the control file as rman repository) unless a CATALOG database is specified.

May 17, 2008. recovery, rman. Leave a comment.

Administration Workshop II. 10-3. Table types

  • Ordinary (heap organized table): Data is stored as an unordered collection (heap).
  • Partitioned table: data is divided into smaller, more manageable pieces.
  • Index-organized table (IOT): Rows (key and non-key values) are sorted and stored in a B-tree index structure.
  • Clustered table: related data from more than one table are stored together. In other words, a cluster is a group of tables that share the same data blocks because they share common columns and are often used together.

May 16, 2008. InternalWorkings. Leave a comment.

Administration Workshop II. 4-14. re-creating indexes

Use options to reduce the time it takes to create the index:

  • PARALLEL
  • NOLOGGING

SQL> CREATE INDEX rname_idx ON hr.regions (region_name) PARALLEL 4;

WARNING: if you created the index with PARALLEL option 4, then you’ll need to change it back to PARALLEL 1 after the index is created so that it doesn’t use 4 CPUs every time it access the index later!

May 15, 2008. catcha, index. Leave a comment.

Administration Workshop II. 2-16. Monitoring the Flash Recovery Area evolution with EM

Go to Enterprise Manager -> Related Links -> All metrics. Click on Recovery Area link then again on the percentage number to see the chart.

May 14, 2008. FlashRecoveryArea, recovery. Leave a comment.

Next Page »