【恢複,1】 redo 日誌恢複的各種情況,redo日誌

來源:互聯網
上載者:User

【恢複,1】 redo 日誌恢複的各種情況,redo日誌
Recovering After the Loss of Online Redo Log Files

If a media failure has affected the online redo logs of a database, then the appropriate recovery procedure depends on the following considerations:

  • The configuration of the online redo log: mirrored or non-mirrored

  • The type of media failure: temporary or permanent

  • The types of online redo log files affected by the media failure: current, active, unarchived, or inactive

Table 30-3 displays V$LOG status information that can be crucial in a recovery situation involving online redo logs.

Table 30-3 STATUS Column of V$LOG

Status Description

UNUSED

The online redo log has never been written to.

CURRENT

The online redo log is active, that is, needed for instance recovery, and it is the log to which the database is currently writing. The redo log can be open or closed.

ACTIVE

The online redo log is active, that is, needed for instance recovery, but is not the log to which the database is currently writing. It may be in use for block recovery, and may or may not be archived.

CLEARING

The log is being re-created as an empty log after an ALTER DATABASE CLEAR LOGFILE statement. After the log is cleared, then the status changes to UNUSED.

CLEARING_CURRENT

The current log is being cleared of a closed thread. The log can stay in this status if there is some failure in the switch such as an I/O error writing the new log header.

INACTIVE

The log is no longer needed for instance recovery. It may be in use for media recovery, and may or may not be archived.


Recovering After Losing a Member of a Multiplexed Online Redo Log Group

You can recover after losing a member of a multiplexed online redo log group. The database continues to function as usual during the following conditions:

If the online redo log of a database is multiplexed, and if at least one member of each online redo log group is not affected by the media failure, then the database continues functioning as usual, but error messages are written to the log writer trace file and the alert_SID.log of the database.

You can resolve the problem of a missing member of a multiplexed online redo log group by taking one of the following actions:

  • If the hardware problem is temporary, then correct it. The log writer process accesses the previously unavailable online redo log files as if the problem never existed.

  • If the hardware problem is permanent, then drop the damaged member and add a new member by using the following procedure.

    Note:

    The newly added member provides no redundancy until the log group is reused.
Recovering After Losing All Members of an Online Redo Log Group

丟失online redo 日誌組所有成員後恢複

If a media failure damages all members of an online redo log group, then different scenarios can occur depending on the type of online redo log group affected by the failure and the archiving mode of the database.

如果介質故障損壞所有的日誌組的成員,不同情境下發生的失敗影響依賴於日誌群組類型和資料庫的歸檔模式。

If the damaged online redo log group is current and active, then it is needed for crash recovery; otherwise, it is not. Table 30-4 outlines the various recovery scenarios.

如果損壞的當前日誌組時current和active,那麼需要做故障恢複。

Table 30-4 Recovering After the Loss of an Online Redo Log Group

If the Group Is... Then... And You Should...

Inactive

It is not needed for crash recovery

Clear the archived or unarchived group.

Active

It is needed for crash recovery

Attempt to issue a checkpoint and clear the log; if impossible, then you must either use Flashback Database or restore a backup and perform incomplete recovery up to the most recent available redo log.


試著執行checkpoint和clear日誌,如果不能,那麼你必須要麼使用閃回資料庫要麼使用轉儲備份 執行不完全恢複到最近可用的redo log。


Current

It is the redo log that the database is currently writing to

Attempt to clear the log; if impossible, then you must either use Flashback Database or restore a backup and perform incomplete recovery up to the most recent available redo log.


To determine whether the damaged group is active or inactive.

確定損壞的組是否是acitve 或inactive

  1. Locate the file name of the lost redo log in V$LOGFILE and then look for the group number corresponding to it. For example, enter:

    SELECT GROUP#, STATUS, MEMBER FROM V$LOGFILE;GROUP#    STATUS       MEMBER-------   -----------  ---------------------0001                    /oracle/dbs/log1a.f0001                    /oracle/dbs/log1b.f0002      INVALID       /oracle/dbs/log2a.f0002      INVALID       /oracle/dbs/log2b.f0003                    /oracle/dbs/log3a.f0003                    /oracle/dbs/log3b.f
  2. Determine which groups are active.

    For example, execute the following SQL query (sample output included):

    SELECT GROUP#, MEMBERS, STATUS, ARCHIVED FROM V$LOG;GROUP#  MEMBERS           STATUS     ARCHIVED------  -------           ---------  ----------- 0001   2                 INACTIVE   YES 0002   2                 ACTIVE     NO 0003   2                 CURRENT    NO
  3. Perform one of the following actions:

    • If the affected group is inactive, then follow the procedure in "Losing an Inactive Online Redo Log Group".

    • If the affected group is active (as in the preceding example), then follow the procedure in "Losing an Active Online Redo Log Group".



       
Losing an Inactive Online Redo Log Group

丟失inactive 日誌組

If all members of an online redo log group with INACTIVE status are damaged, then the procedure depends on whether you can fix the media problem that damaged the inactive redo log group. If the failure is temporary, then fix the problem. The log writer can reuse the redo log group when required. If the failure is permanent, then the damaged inactive online redo log group eventually halts normal database operation. Reinitialize the damaged group manually by issuing the ALTER DATABASE CLEAR LOGFILE statement as described in this section.

inactive狀態的日誌組所有成員損壞。那麼程式依賴於你能否定位inactive日誌組的介質問題(記錄檔是否損壞),如果介質故障是臨時的,log writer 能重新使用 日誌組。如果介質故障是永久的,那麼損壞的inactive日誌組最終會停止正常的資料庫操作。通過執行alter database CLEAR LOGFILE語句手動的重新初始化損壞的日誌組。

Clearing Inactive, Archived Redo

清除inactive 已歸檔的日誌

You can clear an inactive redo log group when the database is open or closed. The procedure depends on whether the damaged group has been archived.

資料庫開啟或關閉都能 clear inactive 日誌組。依賴於損壞的日誌組是否歸檔。

To clear an inactive, online redo log group that has been archived:

Clearing Inactive, Unarchived Redo

清除 inactive 未歸檔的日誌

Clearing a not-yet-archived redo log allows it to be reused without archiving it. This action makes backups unusable if they were started before the last change in the log, unless the file was taken offline before the first change in the log. Hence, if you need the cleared log file for recovery of a backup, then you cannot recover that backup. Clearing a not-yet-archived-redo-log, prevents complete recovery from backups due to the missing log.

清除的沒有歸檔的日誌允許被被重用。如果日誌的最後一次改變之前開始, 這個操作會導致備份不可用,除非記錄檔在第一次改變之前被置為offline。此後,如果你需要被清除的日誌去做備份恢複,是不能備份恢複的。

To clear an inactive, online redo log group that has not been archived:

清除一個inactive ,日誌沒有歸檔:

Failure of CLEAR LOGFILE Operation 失敗的清除記錄檔操作

The ALTER DATABASE CLEAR LOGFILE statement can fail with an I/O error due to media failure when it is not possible to:

alter database clear logfile 語句如果不能做下面的操作 會失敗由於介質故障導致的io錯誤,

  • Relocate the redo log file onto alternative media by re-creating it under the currently configured redo log file name

     通過當前配置的記錄檔的名稱重新建立記錄檔 遷移日誌日誌到另外的介質上

  • Reuse the currently configured log file name to re-create the redo log file because the name itself is invalid or unusable (for example, due to media failure)

    重新使用當前的配置記錄檔的名稱去重新建立記錄檔因為他自己的名字是無效的或者不可用。

In these cases, the ALTER DATABASE CLEAR LOGFILE statement (before receiving the I/O error) would have successfully informed the control file that the log was being cleared and did not require archiving. The I/O error occurred at the step in which the CLEAR LOGFILE statement attempted to create the new redo log file and write zeros to it. This fact is reflected in V$LOG.CLEARING_CURRENT.

在這些情況下,alter database clear logfile 語句

Losing an Active Online Redo Log Group

If the database is still running and the lost active redo log is not the current log, then issue the ALTER SYSTEM CHECKPOINT statement. If the operation is successful, then the active redo log becomes inactive, and you can follow the procedure in "Losing an Inactive Online Redo Log Group". If the operation is unsuccessful, or if your database has halted, then perform one of procedures in this section, depending on the archiving mode.

The current log is the one LGWR is currently writing to. If a LGWR I/O operation fails, then LGWR terminates and the instance fails. In this case, you must restore a backup, perform incomplete recovery, and open the database with the RESETLOGS option.

Recovering from the Loss of Active Logs in NOARCHIVELOG Mode

In this scenario, the database archiving mode is NOARCHIVELOG.

To recover from the loss of an active online log group in NOARCHIVELOG mode:

If the media failure is temporary, then correct the problem so that the database can reuse the group when required. If the media failure is not temporary, then use the following procedure.

Recovering from Loss of Active Logs in ARCHIVELOG Mode

In this scenario, the database archiving mode is ARCHIVELOG.

To recover from loss of an active online redo log group in ARCHIVELOG mode:

Loss of Multiple Redo Log Groups

If you have lost multiple groups of the online redo log, then use the recovery method for the most difficult log to recover. The order of difficulty, from most difficult to least difficult, is as follows:






oracle中如果redo記錄檔損壞,應該怎恢複呀?

很簡單 進入rman
redolog file檔案的丟失:
shutdown immediate;
starup mount;
alter database resetlogs;(這一步可能會出現問題 則在這之前加上一句
recover database until cancel;
並且所有步驟重新再在sqlplus中來一遍)

不過這個方法使用了resetlogs,有可能造成資料損失
 
一個快閃記憶體資料庫的代碼,下面我把詳細問題說下,跪一個日誌恢複代碼

百度搜吧,不行的話你多換搜尋引擎吧,或者多換關鍵詞搜尋,google學術裡面應該有的,你自己去找吧
 

相關文章

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.