Sarah said:
This maybe basic stuff to some of you out there but I'm still learning
Frankly, Sarah, we're all still learning...And if anyone claims that they know everthing about how Oracle works, then they would lie about other stuff, too.
![[wink] [wink] [wink]](/data/assets/smilies/wink.gif)
Additionally, Oracle's behaviours during Hot Backups are perhaps some of the most esoteric, least understood aspects of Oracle...you are not alone.
Here is a (Readers Digest) explanation of what is going on once you issue the command, "ALTER TABLESPACE <name> BEGIN BACKUP;":
First, as you probably are aware, if one simply copies Oracle's database data files without the benefit of a shutdown database or the "...BEGIN BACKUP..." feature, the copies (backups) are virtually useless due to "fractured blocks" (i.e., data blocks that are "in-flight" with changes at the time the file-copy occurs). That is why one must either cleanly shutdown the database or have the database in ARCHIVELOG mode and perform a "HOT BACKUP" (as you are wishing to do).
The clever methodology that Oracle uses for its "HOT BACKUP" to avoid "fractured blocks" during hot backups is to:
a) advise the Oracle instance that you are backing up the files of a particular tablespace, and
b) (as a result of the "...begin backup..." signaling) Oracle invokes "
block protect" mode during your backup activities.
Block protect mode during backup represents the
magic of hot backups:
Normally, (when you are not doing "hot backups") your Oracle server process does the following:
1) Writes a pre-change image of your data to the UNDO (Rollback) segment (in the database buffer cache),
2) Writes a post-change image directly to your database data block (in the database buffer cache)
3) Writes just the row-level changes that result from INSERTs, UPDATEs, or DELETEs to the on-line redo log buffer.
This "business-as-usual" behaviour properly preserves your data integrity in the event of the following scenarios:
1) You decide to COMMIT your changes (the changed data is already in place in your database block(s)).
2) You decide to ROLLBACK your changes (the pre-change image is in the UNDO/Rollback segment and Oracle replaces the changed data in your data blocks with the contents of the UNDO/Rollback segment.
3) A power failure or "shutdown abort" occurs either
a) before you COMMIT (and thus needs to rollback your changes) or
b) after you COMMIT, but before the DBWR (DataBase WRiter) process can write your committed change to disk,
...then upon database restart, the on-line redo log files contain both the COMMITted changes and the pointers to the applicable UNDO/Rollback segments to put the database back to its pre-change committed state prior to the abnormal end to the instance.
(This "business-as-usual" scenario, above, was to give you the background that you need to understand the
magic that occurs during a
hot backup.)
Since Oracle can, at any time, write either COMMITTED or UNCOMMITTED data
physically to your database datafiles (which, in the case of an abnormal end to the instance, is reconciled by entries in the redo log files), we normally "don't care" whether the physical image of your database data files is COMMITTED or UNCOMMITTED data.
The problem arises, however, if we are doing a "hot backup" (i.e., doing an o/s copy of database data files) while UNCOMMITTED changes are occurring. Without Oracle's "protective magic" during hot backups, we could unwittingly be backing up "fractured blocks" (i.e., spurious images) of data.
Therefore, we now reach the explanation of the
protective magic that Oracle implements during a "hot backup":
When you issue the above "...begin backup..." command for a tablespace, this slightly changes Oracle's redo logging behaviour during the time that a tablespace is in this mode. Instead of recording to the redo log buffer just the
data changes that it normally does,
Oracle writes the entire pre-changed image of a soon-to-change database block to the redo log buffer! This methodology absolutely prevents "fractured blocks" by preserving to the redo log buffer, every pristine, unchanged, "un-fractured" block that DML
will change momentarily.
Using this technique,
we don't care when our backup copy of a database data file contains a spurious, fractured block that was changing during the backup process since a pristine, untouched copy of the block resides in physically in either an on-line redo log file or in an archived redo log file, guaranteed.
So, this protective process, although it consumes more redo log space, is a small price to pay for the insurance that our hot backups preserve COMMITTED data integrity.
Once you are done copying the data files for a tablespace, we no longer want the more-expensive block-preservation process to continue, so we issue the command:
Code:
ALTER TABLESPACE <name> END BACKUP;
Does this help to explain how Oracle's clever "hot backup" strategy works?
![[santa] [santa] [santa]](/data/assets/smilies/santa.gif)
Mufasa
(aka Dave of Sandy, Utah, USA)
[
Providing low-cost remote Database Admin services]
Click here to join
Utah Oracle Users Group on Tek-Tips if you use
Oracle in
Utah USA.