nocoug 2005 - oracle 10g backup and recovery

Upload: amitava-roy

Post on 07-Apr-2018

228 views

Category:

Documents


0 download

TRANSCRIPT

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    1/88

    NoCOUG 2005 Winter Conference

    Oracle 10g Backup and Recovery

    New Features

    Daniel T. Liu

    Senior Technical Consultant

    First American Real Estate Solutions

    Date: Tuesday, February 8, 2005 @ 2:15 PM - 3:15 PM

    Venue: Room 103, Oracle Conference Center, Redwood Shores, CA

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    2/88

    NoCOUG 2005, Daniel T. Liu 2

    Agenda

    Introduction

    Oracle Database 10g

    Challenges forBackup and Recovery

    Types of Database

    Errors

    Backup and RecoverySolutions

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    3/88

    NoCOUG 2005, Daniel T. Liu 3

    Agenda

    Extended Flashback

    Features

    Enhanced RMANFeatures

    Summary

    Q & A

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    4/88

    NoCOUG 2005, Daniel T. Liu 4

    Introduction to Oracle 10g

    Grid Computing Concept Utilizing computing resource as utility

    Software level

    Hardware level

    Grid Computing Challenges

    Standardization

    Security

    Reliability

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    5/88

    NoCOUG 2005, Daniel T. Liu 5

    Introduction to Oracle 10g

    Oracle Database 10g New Features Real Application Clusters

    Oracle Streams

    Cross-platform transportable tablespaces Automatic Storage Management (ASM)

    Self-Managing Database

    New Backup and Recovery Features

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    6/88

    NoCOUG 2005, Daniel T. Liu 6

    Challenges for Backup and Recovery

    Database size is getting bigger and bigger Database Backup Time

    A DLT tape writes 6 MB/Second, or 21

    GB/hour A 2 TB database with one tape driver will

    take 97 hours to backup

    Database Recovery Time Is the backup good?

    Trouble shooting time

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    7/88

    NoCOUG 2005, Daniel T. Liu 7

    Types of Database Errors

    Corruptions Logical corruptions

    Physical corruptions

    Human Errors

    Accidentally drop, or truncate a table Accidentally delete, update rows in a table

    Accidentally delete a data file or drop a tablespace

    Disasters War, terrorism Earthquake, flood, fire or hurricane

    No power for a long period of time

    Server crash, malfunction of hardware

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    8/88

    NoCOUG 2005, Daniel T. Liu 8

    Backup and Recovery Solutions

    Logical Methods Export and Import

    Data Pump

    Flashback Functions

    Physical Methods O/S Backup and Restore

    RMAN Backup and Restore

    High Availability Methods Data Guard RAC

    Oracle Streams

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    9/88

    NoCOUG 2005, Daniel T. Liu 9

    Extended Flashback Functions

    Flashback Database Flashback Drop

    Flashback Table

    Flashback Versions Query

    Flashback Transaction Query

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    10/88

    NoCOUG 2005, Daniel T. Liu 10

    Flashback Database

    Traditional recovery method uses backupsand redo log files; Flashback Database isimplemented using a new type of log filecalled Flashback Database logs.

    The Oracle database server periodicallylogs before images of data blocks in theFlashback Database logs.

    The data block images are used to quicklyback out changes to the database duringFlashback Database.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    11/88

    NoCOUG 2005, Daniel T. Liu 11

    Flashback Database

    Flashback Database reduces the timerequired to recover the database to a point

    in time.

    The time to restore a database isproportional to the number of changes that

    need to be backed out, not the size of the

    database. Flashback Database is faster than

    traditional point-in-time recovery.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    12/88

    NoCOUG 2005, Daniel T. Liu 12

    Flashback Database

    DATABASE

    LGWR

    FlashbackDatabase

    Logs

    Redo

    LogFiles

    RVWR

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    13/88

    NoCOUG 2005, Daniel T. Liu 13

    Flashback Database

    $ ps -ef | grep grid

    oracle 25124 1 0 16:32:05 ? 0:00 ora_s000_grid

    oracle 25116 1 0 16:32:04 ? 0:00 ora_reco_grid

    oracle 25169 1 0 16:32:22 ? 0:00 ora_rvwr_gridoracle 25112 1 0 16:32:04 ? 0:00 ora_ckpt_grid

    oracle 25110 1 0 16:32:04 ? 0:00 ora_lgwr_grid

    oracle 25108 1 0 16:32:04 ? 0:00 ora_dbw0_grid

    oracle 25114 1 0 16:32:04 ? 0:00 ora_smon_grid

    oracle 25118 1 0 16:32:04 ? 0:00 ora_cjq0_grid

    oracle 25120 1 0 16:32:04 ? 0:00 ora_rbal_grid

    oracle 25122 1 0 16:32:04 ? 0:00 ora_d000_grid

    oracle 25106 1 0 16:32:04 ? 0:00 ora_pmon_grid

    The list below shows all the backgroundprocesses for grid instance.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    14/88

    NoCOUG 2005, Daniel T. Liu 14

    Enabling Flashback Database

    Make sure the database is in archive mode. Configure the recovery area by setting the two

    parameters:

    DB_RECOVERY_FILE_DEST

    DB_RECOVERY_FILE_DEST_SIZE Open the database in MOUNT EXCLUSIVE

    mode and turn on the flashback feature:

    SQL> STARTUP MOUNT EXCLUSIVE;

    SQL> ALTER DATABASE FLASHBACK ON;

    Set the Flashback Database retention target:

    DB_FLASHBACK_RETENTION_TARGET

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    15/88

    NoCOUG 2005, Daniel T. Liu 15

    Disabling Flashback Database

    Disabling Flashback DatabaseSQL> ALTER DATABASE FLASHBACK OFF;

    Determine if Flashback Database is enabledSQL> select flashback_on

    2 from v$database;FLASHBACK_ON------------YES

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    16/88

    NoCOUG 2005, Daniel T. Liu 16

    Monitoring Flashback Database

    Monitoring Flashback DatabaseSQL> select begin_time, flashback_data,2 db_data, redo_data, ESTIMATED_FLASHBACK_SIZE

    3 from v$flashback_database_stat;

    BEGIN_TIME FLASHBACK_DATA DB_DATA REDO_DATA ESTIMATED_FLASHBACK_SIZE

    -------------------- -------------- ---------- ---------- ------------------------

    Feb 22 2004 01:05:14 147456 2719744 92160 0

    Feb 22 2004 00:05:09 3891200 5857280 2537984 252788736

    Feb 21 2004 23:05:04 7979008 13615104 3385344 254877696

    Feb 21 2004 22:05:00 14893056 19857408 17463296 255737856

    Feb 21 2004 21:04:55 4210688 6422528 2598912 254361600

    Feb 21 2004 20:04:51 4333568 8962048 2775552 256475136

    Feb 21 2004 19:04:46 4431872 7028736 2804736 258588672

    Feb 21 2004 18:04:41 4202496 8511488 2635264 260726784

    Feb 21 2004 17:04:37 4030464 6938624 2546688 263012352

    Feb 21 2004 16:04:32 4005888 7479296 2512384 265420800Feb 21 2004 15:04:27 3874816 6864896 2471936 267927552Feb 21 2004 14:04:23 4153344 7028736 2578944 270532608Feb 21 2004 13:04:18 3825664 7675904 2497536 27311308813 rows selected.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    17/88

    NoCOUG 2005, Daniel T. Liu 17

    Flashback Database Retention

    Monitor the Flashback Database retentiontargetSQL> select *

    2 from v$flashback_database_log;

    OLDEST_FLASHBACK_SCN OLDEST_FLASHBACK_TIMERETENTION_TARGET FLASHBACK_SIZE ESTIMATED_FLASHBACK_SIZE

    -------------------- --------------------- ---------------- -------------- ------------------------

    2.2029E+12 Oct 06 2003 09:44:42 144048316416

    The default value for flashback retention

    time is 1440 minutes.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    18/88

    NoCOUG 2005, Daniel T. Liu 18

    Flashback Database

    Example 1: Flashback a Database using RMANRMAN> FLASHBACK DATABASE

    2> TO TIME = TO_DATE

    3> (06/25/03 12:00:00,MM/DD/YY

    HH:MI:SS);

    Example 2: Flashback a database using SQLcommandSQL> FLASHBACK DATABASE TO TIMESTAMP(SYSDATE 5/24);

    SQL> FLASHBACK DATABASE TO SCN 76239;SQL> ALTER DATABASE RESETLOGS;

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    19/88

    NoCOUG 2005, Daniel T. Liu 19

    Flashback Drop

    Prior to Oracle 10g, a DROP commandpermanently removed objects from thedatabase.

    SQL> DROP TABLE CUSTOMERS;

    In Oracle 10g, a DROP command places theobject in the recycle bin.

    The extents allocated to the segment are not

    reallocated until you purge the object. You can restore the object from the recycle

    bin at any time.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    20/88

    NoCOUG 2005, Daniel T. Liu 20

    Recycle Bin

    A recycle bin contains all the droppeddatabase objects until,

    You permanently drop them with the PURGE

    command.

    Recover the dropped objects with theFLASHBACK TABLE command.

    There is no room in the tablespace for new rows

    or updates to existing rows.

    The tablespace needs to be extended.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    21/88

    NoCOUG 2005, Daniel T. Liu 21

    Recycle Bin

    You can view the dropped objects in therecycle bin from two dictionary views:

    USER_RECYCLEBIN: list all dropped user

    objects

    DBA_RECYCLEBIN: list all dropped system-

    wide objects

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    22/88

    NoCOUG 2005, Daniel T. Liu 22

    Example 1: Dropping an ObjectSQL> create table test (col_a varchar(4));Table created.

    SQL> select object_name, original_name,

    2 type, createtime, droptime3 from user_recyclebin;

    no rows selected

    SQL> drop table test;

    Table dropped.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    23/88

    NoCOUG 2005, Daniel T. Liu 23

    Example 1: Dropping an ObjectSQL> select object_name, original_name,2 type, createtime, droptime

    3 from user_recyclebin;

    OBJECT_NAME ORIGINAL_NAMETYPE CREATETIME DROPTIME

    ------------------------------ ---------------- ------ ------------------- -------------------

    BIN$0+ktoVCgEmXgNAAADiUEHQ==$0 TEST

    TABLE 2004-02-21:19:04:03 2004-02-21:19:04:41

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    24/88

    NoCOUG 2005, Daniel T. Liu 24

    Example 1: Dropping an ObjectSQL> create table test (col_b varchar(4));

    Table created.

    SQL> select object_name, original_name,

    2 type, createtime, droptime

    3 from user_recyclebin;

    OBJECT_NAME ORIGINAL_NAMETYPE CREATETIME DROPTIME

    ------------------------------ ---------------- ------ ------------------- -------------------

    BIN$0+ktoVCgEmXgNAAADiUEHQ==$0 TESTTABLE 2004-02-21:19:04:03 2004-02-21:19:04:41

    SQL> drop table test;

    Table dropped.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    25/88

    NoCOUG 2005, Daniel T. Liu 25

    Example 1: Dropping an ObjectSQL> select object_name, original_name,2 type, createtime, droptime

    3 from user_recyclebin;

    OBJECT_NAME ORIGINAL_NAMETYPE CREATETIME DROPTIME

    ------------------------------ ---------------- ------ ------------------- -------------------

    BIN$0+ktoVChEmXgNAAADiUEHQ==$0 TEST

    TABLE 2004-02-21:19:07:33 2004-02-21:19:08:17

    BIN$0+ktoVCgEmXgNAAADiUEHQ==$0 TESTTABLE 2004-02-21:19:04:03 2004-02-21:19:04:41

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    26/88

    NoCOUG 2005, Daniel T. Liu 26

    Example 1: Dropping an ObjectSQL> show recyclebinORIGINAL NAME RECYCLEBIN NAMEOBJECT TYPE DROP TIME

    ---------------- ---------------------------

    --- ------------ -------------------TESTBIN$0+ktoVChEmXgNAAADiUEHQ==$0 TABLE2004-02-21:19:08:17

    TESTBIN$0+ktoVCgEmXgNAAADiUEHQ==$0 TABLE2004-02-21:19:04:41

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    27/88

    NoCOUG 2005, Daniel T. Liu 27

    Example 2: Restoring a Dropped Object

    This example will restore a dropped tabletest.

    SQL> flashback table

    BIN$0+ktoVChEmXgNAAADiUEHQ==$0 to before drop;

    Flashback complete.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    28/88

    NoCOUG 2005, Daniel T. Liu 28

    Example 3: Dropping a Table Permanently

    This statement removes the tablepermanently:SQL> drop table test purge;

    Table dropped.

    This statement removes the table in the

    recycle bin:

    SQL> purge table "BIN$0+ktoVChEmXgNAAADiUEHQ==$0";

    Table purged.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    29/88

    NoCOUG 2005, Daniel T. Liu 29

    Example 4: Dropping a Tablespace

    You can only issue this command when thetablespace users is empty. Object in the recycle bin

    of tablespace users will be purged:

    SQL> drop tablespace users;

    When you issue this command, objects in the

    tablespace users are dropped. They are not placed

    in the recycle bin. Any objects in the recycle bin

    belonging to the tablespace users are purged.SQL> drop tablespace users including

    contents;

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    30/88

    NoCOUG 2005, Daniel T. Liu 30

    Example 5: Purging the Recycle Bin

    This statement purges the user recycle bin:SQL> purge recyclebin;

    Recyclebin purged.

    This statement removes all objects from the

    recycle bin:SQL> purge dba_recyclebin;

    DBA Recyclebin purged.

    This statement purges all objects from tablespaceusers in the recycle bin:SQL> purge tablespace users;

    Tablespace purged.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    31/88

    NoCOUG 2005, Daniel T. Liu 31

    Flashback Table

    Flashback Table allows you to recover atable or tables to a specific point in time

    without restoring a backup.

    When you use the Flashback Table featureto restore a table to a specific point in time,

    all associated objects, such as, indexes,

    constraints, and triggers will be restored.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    32/88

    NoCOUG 2005, Daniel T. Liu 32

    Flashback Table

    Flashback Table operations are not validfor the following object types:

    Tables that are part of a cluster

    Materialized views Advanced Queuing tables

    Static data dictionary tables

    System tables

    Partitions of a table

    Remote tables (via database link)

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    33/88

    NoCOUG 2005, Daniel T. Liu 33

    UNDO_RETENTION Parameter

    Data used to recover a table is stored in theundo tablespace. You can use the

    parameter UNDO_RETENTION to set the

    amount of time you want undo informationretained in the database.

    The default value for UNDO_RETENTIONis 900 seconds (15 minutes).

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    34/88

    NoCOUG 2005, Daniel T. Liu 34

    Guaranteed Retention

    When an active transaction uses all the undotablespace, the system will start reusing undo

    space that would have been retained unless you

    have specified RETENTION GUARANTEE for

    the tablespace. To create an undo tablespace with the

    RETENTION GUARANTEE option, issue the

    following command:SQL> CREATE UNDO TABLEAPCE undo_tbs

    DATAFIEL /u02/oradata/grid/undo_tbs01.dbf SIZE 1 G

    RETENTION GUARANTEE;

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    35/88

    NoCOUG 2005, Daniel T. Liu 35

    Flashback Table Privileges

    You must have the FLASHBACK TABLEor FLASHBACK ANY TABLE system

    privilege to use the Flashback Table feature.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    36/88

    NoCOUG 2005, Daniel T. Liu 36

    Example 1: Flashback Table using SCN

    Table row movement must be enabled toflashback a table:

    SQL> ALTER TABLE billing ENABLE

    ROW MOVEMENT; This statement brings a table billing back

    to a certain SCN number;

    SQL> FLASHBACK TABLE billing TOSCN 76230;

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    37/88

    NoCOUG 2005, Daniel T. Liu 37

    Example 2: Flashback Table using TIMESTAMP

    This statement brings a table billing backto a certain timestamp:SQL> FLASHBACK TABLE billing

    TO TIMESTAMPTO_TIMESTAMP(06/25/03

    12:00:00,MM/DD/YY HH:MI:SS);

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    38/88

    NoCOUG 2005, Daniel T. Liu 38

    Flashback Versions Query

    Flashback Query was first introduced inOracle9i, to provide a way for you to view

    historical data.

    In Oracle 10g, this feature has beenextended.

    You can now retrieve all versions of the

    rows that exist or ever existed between thetime the query was issued and a point back

    in time.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    39/88

    NoCOUG 2005, Daniel T. Liu 39

    Flashback Versions Query

    You can use the VERSIONS BETWEENclauses to retrieve all historical data related

    to a row.

    The Flashback Versions Query featureretrieves all committed occurrences of the

    row.

    The row history data is stored in the undotablespace.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    40/88

    NoCOUG 2005, Daniel T. Liu 40

    Flashback Versions Query

    The undo_retention initialization parameterspecifies how long the database will keep theamount of committed undo information.

    If a new transaction needs to use undo space

    and there is not enough free space left, anyundo information older than the specifiedundo retention period will be overwritten.

    You can set the undo tablespace option toRETENTION GUARANTEE to retain allrow histories.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    41/88

    NoCOUG 2005, Daniel T. Liu 41

    Example 1

    To verify the retention value for thetablespace, you can issue the followingstatement:

    SQL> select tablespace_name, retention

    2 From dba_tablespaces;

    TABLESPACE_NAME RETENTION

    ------------------------------ -----------

    SYSTEM NOT APPLY

    UNDOTBS1 NOGUARANTEE

    SYSAUX NOT APPLY

    TEMP NOT APPLY

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    42/88

    NoCOUG 2005, Daniel T. Liu 42

    Example 2

    SQL> create table emp (name varchar2(10),salary number(8,2));

    Table created.

    SQL> insert into empvalues ('DANIEL',2000);

    1 row created.

    SQL> commit;

    Commit complete.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    43/88

    NoCOUG 2005, Daniel T. Liu 43

    Example 2

    SQL> update emp set salary = 3000where name = 'DANIEL';

    1 row updated.

    SQL> commit;

    Commit complete.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    44/88

    NoCOUG 2005, Daniel T. Liu 44

    Example 2

    SQL> select * from emp;NAME SALARY

    ---------- ----------

    DANIEL 3000

    SQL> select * from emp

    versions between scn minvalue and maxvalue;

    NAME SALARY

    ---------- ----------

    DANIEL 3000

    DANIEL 2000

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    45/88

    NoCOUG 2005, Daniel T. Liu 45

    Flashback Transaction Query

    It provides a way for you to view changesmade to the database at the transactionlevel.

    It allows you to diagnose problems in

    your database and perform analysis andaudit transactions.

    You can use this feature in conjunction

    with the Flash Versions Query feature toroll back the changes made by atransaction.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    46/88

    NoCOUG 2005, Daniel T. Liu 46

    Flashback Transaction Query

    You can retrieve the transaction history fromflashback_transaction_query view:Name Null? Type

    ------------------------------------ -------- --------------

    XID RAW(8)

    START_SCN NUMBERSTART_TIMESTAMP DATE

    COMMIT_SCN NUMBER

    COMMIT_TIMESTAMP DATE

    LOGON_USER VARCHAR2(30)

    UNDO_CHANGE# NUMBER

    OPERATION VARCHAR2(32)

    TABLE_NAME VARCHAR2(256)

    TABLE_OWNER VARCHAR2(32)

    ROW_ID VARCHAR2(19)

    UNDO_SQL VARCHAR2(4000)

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    47/88

    NoCOUG 2005, Daniel T. Liu 47

    Example

    SQL> select versions_xid, name, salary

    2 from emp

    3 versions between scn minvalue and maxvalue;

    VERSIONS_XID NAME SALARY

    ---------------- ---------- ----------0003000E00000FE2 DANIEL 3000

    DANIEL 2000

    SQL> select *2 from flashback_transaction_query

    3 where xid = '0003000E00000FE2';

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    48/88

    NoCOUG 2005, Daniel T. Liu 48

    Example

    SQL> select xid, start_scn, start_timestamp,

    2 table_name, undo_sql

    3 from flashback_transaction_query

    4 where xid = '0009001F000000B2;

    XID START_SCN START_TIMESTAMPTABLE_NAME

    UNDO_SQL

    ---------------- ---------- -------------------- ----------

    -------------------------------------------------------------------------------

    0009001F000000B2 714980 Feb 21 2004 23:30:31 EMP

    update "ORACLE"."EMP" set "SALARY" = 2000' where ROWID ='AAAMWJAAEAAAAFsAAA';

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    49/88

    NoCOUG 2005, Daniel T. Liu 49

    Summary - Flashback

    Flashback Database Flashback Drop

    Flashback Table

    Flashback Versions Query Flashback Transaction Query

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    50/88

    NoCOUG 2005, Daniel T. Liu 50

    Enhanced RMAN Features

    Automated File Creation DuringRecovery

    Simplified Recovery Through Resetlogs Change-Aware Incremental Backups

    Automated Disk-Based Backup and

    Recovery RMAN Database Dropping and

    Deregistration

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    51/88

    NoCOUG 2005, Daniel T. Liu 51

    Automated File Creation During Recovery

    This feature enhances RMAN recoveryby automatically creating and recoveringdatafiles that have never been backed up.

    In order to recover a data file that has

    never been backed up, you need thearchive log files from the time of the datafile creation until the time at which you

    want to stop the recovery process and acopy of the control file with theinformation regarding the data file.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    52/88

    NoCOUG 2005, Daniel T. Liu 52

    Automated File Creation During Recovery

    data file

    #1

    data file

    #2

    Missing

    data file

    #3

    Control fle

    RMAN

    Archive log files

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    53/88

    NoCOUG 2005, Daniel T. Liu 53

    Simplified Recovery Through Resetlogs

    After performing an incomplete (Point-in-time) recovery, you need to open the

    database with RESETLOGS option:

    SQL> alter database open resetlogs;

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    54/88

    NoCOUG 2005, Daniel T. Liu 54

    Simplified Recovery Through Resetlogs

    This RESETLOGS operation creates a newincarnation of the database and resets the logs.

    Prior to Oracle 10g, the newly generated redolog files could not be used with the backups

    taken in the past. Therefore, it was importantto take an immediate backup since all previousbackups became invalid.

    In addition, if you used RMAN catalog for

    future backups, you needed to issue thefollowing command to make the RMAN catalogaware of the new incarnation of the database.

    RMAN> reset database;

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    55/88

    NoCOUG 2005, Daniel T. Liu 55

    Simplified Recovery Through Resetlogs

    In Oracle 10g, you no longer have to backup your database following an incompleterecovery and OPEN RESETLOGSoperations.

    This new feature is also applicable to thefollowing two scenarios: When you perform a recovery using a

    backup control file and open the databasewith the RESETLOGS operation.

    When you need to reinstantiate the oldprimary database following a failover.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    56/88

    NoCOUG 2005, Daniel T. Liu 56

    Simplified Recovery Through Resetlogs

    Benefits of Simplified Recovery ThroughResetlogs

    There is no need to perform a full backup

    after an incomplete recovery.

    There is no need to recreate a new standby

    database after a failover operation.

    There is no need to change any backup

    scripts as there are no changes to therecovery commands to take advantage of

    this functionality.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    57/88

    NoCOUG 2005, Daniel T. Liu 57

    Simplified Recovery Through Resetlogs

    Benefits of Simplified Recovery ThroughResetlogs

    You can take incremental backups based on

    full backups of a previous incarnation when

    you use RMAN.

    Block media recovery can restore backups

    from parent incarnation backups and

    recover the corrupted blocks through aRESETLOGS operation.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    58/88

    NoCOUG 2005, Daniel T. Liu 58

    Simplified Recovery Through Resetlogs

    How does it work? Oracle 10g introduces a new format

    specification for archived log files.

    This new format avoids overwriting archived

    redo log files with the same sequencenumber across incarnations.

    SQL> show parameter log_archive_format

    NAME TYPE VALUE

    ---------------------------- ----------- ------------log_archive_format string %t_%s_%r.dbf

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    59/88

    NoCOUG 2005, Daniel T. Liu 59

    Simplified Recovery Through Resetlogs

    The format specification is %r andrepresents the resetlogs id. It is included

    in the default format for the

    LOG_ARCHIVE_FORMATinitialization parameter.

    It will ensure that a unique name is

    constructed for the archived redo log file

    during RMAN restore and SQL*plusauto recovery mode.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    60/88

    NoCOUG 2005, Daniel T. Liu 60

    Simplified Recovery Through Resetlogs

    During the RESETLOGS operation, theinformation in V$LOG_HISTORY and

    V$OFFLINE_RANGE records are no

    longer cleared.

    In addition, two new columns have been

    added to indicate the incarnation the

    records belong to:

    RESETLOGS_CHANGE#

    RESETLOGS_TIME.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    61/88

    NoCOUG 2005, Daniel T. Liu 61

    Simplified Recovery Through Resetlogs

    SQL> select recid, thread#, sequence#, resetlogs_change#,resetlogs_time

    2 from v$log_history3 where rownum < 20;

    RECID THREAD# SEQUENCE# RESETLOGS_CHANGE# RESETLOGS_TIME

    ---------- ---------- ---------- ----------------- --------------------

    1 1 1 1 Aug 12 2003 18:48:54

    2 1 2 1 Aug 12 2003 18:48:54

    3 1 3 1 Aug 12 2003 18:48:544 1 4 1 Aug 12 2003 18:48:54

    5 1 5 1 Aug 12 2003 18:48:54

    6 1 6 1 Aug 12 2003 18:48:54

    7 1 7 1 Aug 12 2003 18:48:54

    8 1 8 1 Aug 12 2003 18:48:54

    9 1 9 1 Aug 12 2003 18:48:54

    10 1 10 1 Aug 12 2003 18:48:5411 1 11 1 Aug 12 2003 18:48:54

    12 1 12 1 Aug 12 2003 18:48:54

    13 1 13 1 Aug 12 2003 18:48:54

    14 1 14 1 Aug 12 2003 18:48:54

    15 1 15 1 Aug 12 2003 18:48:54

    Ch A I l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    62/88

    NoCOUG 2005, Daniel T. Liu 62

    Change-Aware Incremental Backups

    In previous releases of the Oracle database,when you perform an incremental backup,

    RMAN has to examine every block in the data

    file to determine which blocks have been

    changed. The time to perform an incremental backup is

    proportional to the size of the data files.

    Therefore, to perform an incremental backup

    on a very large database can take some timeeven if you have just changed a few blocks.

    Ch A I l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    63/88

    NoCOUG 2005, Daniel T. Liu 63

    Change-Aware Incremental Backups

    In Oracle 10g, you can create ablock changetracking file that records the blocks modified

    since the last backup.

    RMAN uses the tracking file to determine

    which blocks to include in the incrementalbackup.

    RMAN no longer needs to examine the entire

    data file. The time to perform an incremental

    backup is now proportional to the amount of

    content modified since the last backup.

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    64/88

    NoCOUG 2005, Daniel T. Liu 64

    Change-Aware Incremental Backups

    Here are the steps RMAN will perform todo an incremental backup:

    Read the Block Change Tracking File to

    determine which blocks in the data file need

    to be read.

    Only scan the changed blocks in the data file

    and then back them up.

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    65/88

    NoCOUG 2005, Daniel T. Liu 65

    Change-Aware Incremental Backups

    Block Change Tracking File

    Data File

    RMAN Step 1

    Step 2

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    66/88

    NoCOUG 2005, Daniel T. Liu 66

    Change-Aware Incremental Backups

    How big is the Block Change Tracking File? The database size in bytes: theblock change tracking

    file contains data representing every data file block

    in the database. The data is approximately 1/250000

    of the total size of the database.

    The number of enabled threads: In a Real

    Application Cluster (RAC) environment, the

    instances update different areas of the tracking file

    without any locking or inter-node block swapping.

    You enable block change tracking for the entiredatabase and not for individual instances.

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    67/88

    NoCOUG 2005, Daniel T. Liu 67

    Change-Aware Incremental Backups

    How big is the Block Change TrackingFile?

    The number of old backups: The block

    change tracking file keeps a record of all

    changes between previous backups, inaddition to the modification since the last

    backup. It retains the change history for a

    maximum of eight backups.

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    68/88

    NoCOUG 2005, Daniel T. Liu 68

    Change-Aware Incremental Backups

    The size of the file is calculated by thefollowing formula:

    Size of the Block Change

    Tracking File =( ( (Threads*2) + number of oldbackups ) * database size inbytes ) / 250,000

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    69/88

    NoCOUG 2005, Daniel T. Liu 69

    Change-Aware Incremental Backups

    The minimum size for the block changetracking file is 10 MB.

    By using this formula, a 2 TB database

    with only one thread, and having fivebackups in the RMAN repository will

    require a block change tracking file of 59

    MB.

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    70/88

    NoCOUG 2005, Daniel T. Liu 70

    Change-Aware Incremental Backups

    Enabling Block Change Tracking By default, Oracle will not record block

    change information.

    To enable this feature, you need to issue the

    following command:

    SQL> alter database enable blockchange tracking;

    Ch A I t l B k

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    71/88

    NoCOUG 2005, Daniel T. Liu 71

    Change-Aware Incremental Backups

    Disabling Block Change TrackingSQL> alter database disable blockchange tracking;

    Monitoring the status of Block Change

    Tracking:SQL> select file, status, bytes

    2 from v$block_change_tracking;

    STATUS FILE BYTES----------- ---------------------------- ---------------

    ENABLED /dba/backup/01_mf_yzmrr7.chg 10,000,000

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    72/88

    NoCOUG 2005, Daniel T. Liu 72

    p

    Recovery

    Prior to Oracle 10g, disk files that were createdby RMAN utility or ARCH process had noknowledge of one another.

    Furthermore, they were not aware of the sizesof the file system on which they created files.Database administrators need to routinelyclean up the old archive logs or old RMANfiles.

    It is nice to have a unified disk storage locationwhere you can manage all recovery relatedfiles. Now you can achieve this in Oracle 10gby specifying aRecovery Area

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    73/88

    NoCOUG 2005, Daniel T. Liu 73

    p

    Recovery

    Therecovery area is a unified disk storagelocation for all recovery related files and

    activities in an Oracle Database. Those files

    include:

    Control file

    Online redo log files

    Archived log files

    Flashback logs

    Control file autobackups

    Data file copies RMAN files

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    74/88

    NoCOUG 2005, Daniel T. Liu 74

    p

    Recovery

    The recovery area is defined by settingtwo initialization parameters. These two

    parameters can be dynamically altered or

    disabled.

    Thedb_recovery_file_dest_size sets the disk

    limit, expressed in bytes

    Thedb_recovery_file_dest sets the location

    for the recovery area

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    75/88

    NoCOUG 2005, Daniel T. Liu 75

    p

    Recovery

    Set the disk limit for recovery area to 100GB:SQL> ALTER SYSTEM SET

    DB_RECOVERY_FILE_DEST_SIZE = 100G;

    Set the recovery area destination:

    SQL> ALTER SYSTEM SET

    DB_RECOVERY_FILE_DEST = /dba/backup/;

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    76/88

    NoCOUG 2005, Daniel T. Liu 76

    Recovery

    Alter a Recovery AreaSQL> ALTER SYSTEM SETDB_RECOVERY_FILE_DEST_SIZE = 200G;

    Disabling a Recovery AreaSQL> ALTER SYSTEM SETDB_RECOVERY_FILE_DEST = ;

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    77/88

    NoCOUG 2005, Daniel T. Liu 77

    Recovery

    Recovery Area Space Management When the recovery area is less than 90% full, Oracle

    does not delete eligible files immediately, to

    minimize the need to restore recent files from tape

    during recovery. The recovery area can thus serve

    as a kind of cache for tape.

    Once the recovery area is 90% full, Oracle will issue

    a warning to users.

    The Oracle database server and RMAN will

    continue to create files in the recovery area until

    100% of the disk limit is reached.

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    78/88

    NoCOUG 2005, Daniel T. Liu 78

    Recovery

    Recovery Area Space Management

    Once the recovery area is 100% full, the RMAN

    retention policy is used to indicate what files will be

    deleted in order to make space for newer files.

    The db_flashback_retention_target parameterspecifies how long Oracle will keep the flashback

    logs in the flashback recovery area. However,

    flashback logs won't be deleted even if it exceeds the

    duration specified by the flashback retention period

    unless more space is needed in the recovery area forother files.

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    79/88

    NoCOUG 2005, Daniel T. Liu 79

    Recovery

    New RMAN command for RecoveryArea

    RMAN> BACKUP RECOVERY AREA;

    RMAN> BACKUP RECOVERY FILES;

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    80/88

    NoCOUG 2005, Daniel T. Liu 80

    Recovery

    Oracle 10g has a new dynamic performance

    view for monitoring the recovery area:

    SQL> desc v$recovery_file_dest

    Name Null? Type

    ------------------------------- -------- -----------

    NAME VARCHAR2(513)

    SPACE_LIMIT NUMBER

    SPACE_USED NUMBER

    SPACE_RECLAIMABLE NUMBERNUMBER_OF_FILES NUMBER

    Automated Disk-Based Backup and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    81/88

    NoCOUG 2005, Daniel T. Liu 81

    Recovery

    Example:SQL> select * from v$recovery_file_dest;

    NAME SPACE_LIMIT SPACE_USED

    SPACE_RECLAIMABLE NUMBER_OF_FILES------------ ------------- ----------------------------- ----------------

    /dba/backup 2147483648 458219520

    0 49

    RMAN Database Dropping and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    82/88

    NoCOUG 2005, Daniel T. Liu 82

    Deregistration

    In Oracle 10g, you can drop a database and

    remove its entry from the RMAN catalog.

    The following statement drops the entiredatabase and removes the database files:RMAN> drop database;

    The following statement drops the entire

    database, removes the database files, and deletes

    all backup copies of the database and the archivelog files:RMAN> drop database including backups;

    RMAN Database Dropping and

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    83/88

    NoCOUG 2005, Daniel T. Liu 83

    Deregistration

    The above two statements drop thedatabase and delete the database files.

    However, they do not unregister the

    database from the RMAN catalog. The

    following statement will remove the

    database information from the RMAN

    catalog:

    RMAN> unregister database grid;

    S RMAN F t

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    84/88

    NoCOUG 2005, Daniel T. Liu 84

    Summary - RMAN Features

    Automated File Creation DuringRecovery

    Simplified Recovery Through Resetlogs Change-Aware Incremental Backups

    Automated Disk-Based Backup andRecovery

    RMAN Database Dropping andDeregistration

    Summary

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    85/88

    NoCOUG 2005, Daniel T. Liu 85

    Summary

    Oracle Database 10g Grid Computing

    Challenges For Backup and Recovery

    Different Types of Database Errors Solutions for Backup and Recovery

    Oracle 10g Extended Flashback Features

    Oracle 10g Enhanced RMAN Features

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    86/88

    NoCOUG 2005, Daniel T. Liu 86

    Questions

    &

    Answers

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    87/88

    NoCOUG 2005, Daniel T. Liu 87

    References

    Oracle Database 10g New Features, Ault, Liu and Tumma;

    Rampant Techpress;

    Recovery Manager Reference, 10g Release;

    Backup and Recovery Advanced Users Guide, 10g Release;

    I would also like to acknowledge the assistance of Larry

    Bailey of FARES, Tammy Bednar, Larry Carpenter, Roger

    Peterson, Schwinn Ulrike of Oracle Corporation.

  • 8/3/2019 NoCOUG 2005 - Oracle 10g Backup and Recovery

    88/88

    Thanks For Coming !!

    Daniel Liu Contact Information

    Phone: (714) 701-3346

    Email: [email protected]

    Email: [email protected]

    Company Web Site:

    http://www.firstam.com