关闭

关于 oracle恢复的 概论

标签: oracledatabasefilearchivecommandfilenames
305人阅读 评论(0) 收藏 举报
分类:

There are two type ways of backup:

  After completing this lesson, you should be able to do the following:
 
1: Describe media recovery.
2: Perform recovery in NOARCHIVELOG mode.
3: Perform complete recovery in ARCHIVELOG node.
4: Restore datafiles to different locations.
5: Relocate and recover a tablespace by using archived redo log files.
6: Describe read-only tablespace recovery.

Step1:
  Restoration:
  1: Restore files using operating system commands.
  2: Recovery files using the SQL*Plus recover command.
 
  Recovery in NOARCHIVELOG:
 
  You must restore the following database files:
  --All datafiles
  --Control files
 
  You can also restore the following files:
  --Redo log files  (When you shutdown the database gracefully,
                     the redo log file already write into the datafiles,
                     so this is not neccessary to backup)
  --Password file
  --parameter file
 
  This advantages:
  1: Easy to perform, with low risk of error.
  2: Recovery time the time it takes to restore all files
 
  Disadvantages:
  1: Data is lost and must be reappied manually
  2: The entire database is restored to the point of last whole closed backup.
 
--------------
  If you are required to recovery the database , the mainly steps are below:
 
  1: create pfile from spfile
  2: backup the original spfile
  3: vi pfile (update the control file path if the original disk is damaged).
  4: startup mount;
  5: select name from v$datafile;
    alter database rename file '/u01/oradata/morewood/users01.dbf' to '/u01/oradata/md/users01.dbf';
  6: select name from v$tempfile;
    alter database rename file '/u01/oradata/morewood/temp01.dbf' to '/u01/oradata/md/temp01.dbf';
  7: select member from v$logfile;
    alter database rename file '/u01/oradata/morewood/redo01.log' to '/u01/oradata/md/redo01.dbf';
  8: alter database open;
 

Step2:
  If you do not have any redo log files backup, what will you do?
 
  Below is detailed command:
 
  1: shutdown the instance.
  2: Restore the datafiles and the control files from the most recent whole database backup.
  3: Perform cancel-based recovery.
  4;Open the database with the resetlogs open.
 
  The recovery steps:
 
  1: startup mount;
  2: recover database until cancel using backup controlfiles; (cancel);
  3;alter database open resetlogs;
 
Notice:
  Please figure out when you should use the "using backup controlfile".
 

Step3:
  Study how to recovery the database in archivelog mode:
 
  Complete Recovery:
  1: Uses redo data or incremental backups
  2: Updates the database to the most current point time.
  3:Applies all redo changes.
 
  Incomplete Recovery:
  -- Uses backup and redo logs to produce a nocurrent version of the database.
 
  Details:
 
  Complete Recovery:(Archivelog Mode)
  -- make sure that datafile for restore are offline.
  -- Restore only lost or damanged datafiles.
  -- Do not restore the control files, redo log files. password files, or parameter files.
  -- Recover the datafiles.
 
  Advantages:
 
  1: Only need to restore lost files.
  2: Recovery all data to the time of failure using all redo and archive logs.
  3: Recovery time is the time it takes to restore lost files and appy all archive log files.
 
  Disadvantages:
  Must have all archived log files since the backup from which you are restoring.
 
----------

  Let us take a look at some important view about recovery:
 
  1: v$recover_file:
    This view is to determine which datafiles need recovery.
   
  2: v$archived_log:
    This is a list of all archvied redo log files for the database.
   
  3: v$recovery_log:
    This view is for a list of all archived redo log files required for recovery.
   
Notice 1:
  To determine which archived redo log files are needed, query v$archived_log and
  v$recovery_log. V$archived_log lists filenames for all archvied logs.
  v$recovery_log lists only that archived redo logs that the database needs to perform
  media recovery. It aslo incudes the probable names of the files, using LOG_ARCHIVE_FORMAT.
 
Notice 2:
  If the control file is not the current control file, the information from v$recover_file
  is not correct.
  So you can not use v$recover_file with a control file restored from backup or a
  control file that was re-created after the time of media failure.
 

Step4:
  Take a look at below recovery command:
 
  1: Recovery a mounted database:
  sql>recover database;
  sql>recover datafile '/u01/oradata/user01.dbf';
 
  2: Recover an open database:
  this time can not recover database
  sql>recover tablespace user;
  sql>recover datafile '/u01/oradata/user01.dbf';
 
-------------
  There are foure types of database recovery:
 
  1: Closed database recovery for:
   -- System datafiles
   -- Undo segment datafiles
     (above file is lost , should ensure the database in mounted mode)
    
   -- Whole database.
  
  2: Open database recovery, with database initially opened (for file lost).
 
  3: Open database recovery with database initially closed (for hardware failure).
 
  4: Data file recovery with no datafile backup.
    (using all the archived log files).
   

Step5:
  If you want to backup one tablespace when the database open, below command is needed:
 
  1: alter tablespace tablesapce_name begin backup;
  2: cd /u01/oradata/
  3: cp tbs01.dbf ./hot_bak/
  4: alter tablespace tablespace_name end backup;
 

0
0

查看评论
* 以上用户言论只代表其个人观点,不代表CSDN网站的观点或立场
    个人资料
    • 访问:919492次
    • 积分:15281
    • 等级:
    • 排名:第714名
    • 原创:598篇
    • 转载:143篇
    • 译文:26篇
    • 评论:126条
    文章存档
    最新评论