How to recover online log files after corruption

Source: Internet
Author: User
Tags copy log oracle documentation thread oracle database backup
Recovery
Yesterday encountered an Oracle database problem, the environment is: windows2000+oracle9i.
After using Windows shutdown reboot, Oracle cannot connect, and when startup with startup always reports a ORA-00333 error, check the Oracle documentation for a description of this issue as follows:
ORA-00333 Redo Log Read error block string count string
Cause:an I/O error occurred while reading the log described in the
Accompanying error.
Action:restore accessibility to file, or get another copy of the file.

The judgment is that the online log is corrupted, and here is an article found to solve the problem.

As we all know, the online log is divided into current online and non current online logs, and the corruption of non-current online logs is relatively simple, and the problem can be solved by the clear command generally.
1, start the database, encountered ORA-00312 or ORA-00313 error, such as
Ora-00313:open failed for members of log Group 1 of thread 1
Ora-00312:online Log 1 Thread 1: ' D:\ORACLE\ORADATA\TEST\REDO01. LOG '
From here we know that log Group 1 data files are corrupted.
More detailed information can be seen from the alert file
2. View V$log View
Sql> select Group#,sequence#,archived,status from V$log;

group# sequence# Archived STATUS
---------- ---------- -------- ----------------
1 1 YES INACTIVE
2 2 YES INACTIVE
3 3 NO Current
As you can see, the group is out of the current state and has been archived.
3. Rebuild the log file with clear command
Sql>alter Database Clear LogFile Group 1;
If the log group is not yet archived, you need to use the
Sql>alter Database Clear unarchived logfile Group 1;
4, open the database, back up the database
Sql>alter database open;
Description
1, if the damage is not the current online log file, generally only need clear to rebuild the log text
, but if the database is in an archived state but the log is not archived, you need to force clear.
2, recommend clear, especially after forced clear to make a full backup of the database.
3. This method is suitable for archiving and non-archive databases

Corrupt current online log
There are two cases of corruption of the current log in archive mode.
First, the database is closed normally, the log file does not have outstanding transactions need instance recovery, the current log group
Damage can be rebuilt directly with ALTER DATABASE clear unarchived logfile Group N.
Two, is the log group has the active transaction, the database needs the media recovery, the log group needs to use for the synchronization, has two
Kind of remedial measures
A. The best approach is to ensure consistency in the database through incomplete recovery, but this approach requires
In the archive mode, and there are available backups
B. Through mandatory recovery, but may cause database inconsistencies.
The following are used to illustrate the two methods of recovery
Restore by Backup
1, open the database, you will encounter a similar error
Ora-00313:open failed for members of log Group 1 of thread 1
Ora-00312:online Log 1 Thread 1: ' D:\ORACLE\ORADATA\TEST\REDO01. LOG '
Ora-27041:unable to open File
Osd-04002:unable to open File
O/s-error: (OS 2) The system could not find the specified file

2, view V$log, found is the current log
Sql> select Group#,sequence#,archived,status from V$log;

group# sequence# Archived STATUS
---------- ---------- -------- ----------------
1 1 NO Current
2 2 YES INACTIVE
3 3 YES INACTIVE

3. Found clear not successful
Sql> ALTER DATABASE Clear unarchived logfile Group 1;
ALTER DATABASE Clear unarchived logfile Group 1
*
ERROR at line 1:
Ora-01624:log 1 needed for crash recovery of thread 1
Ora-00312:online Log 1 Thread 1: ' D:\ORACLE\ORADATA\TEST\REDO01. LOG '

4, copy valid database full backup, not fully restore the database
Can be recovered using the until SCN with a method of obtaining the nearest SCN or until Cnacel
Recover database until Cancel
Select Auto, try to restore the available archive logs, and then
Recover database until Cancel
This time the input cancel, completes does not complete restores, namely restores two times.
Such as:
sql> recover database until cancel;
Auto
......
sql> recover database until cancel;
Cancel;
5. Open the database using ALTER DATABASE open Resetlogs
Description
1, this approach to restore the database is consistent incomplete recovery, will lose the current online log in the transaction data
2, this method is suitable for archiving the database and has available database full backups.
3, after the restoration of success, remember to do a full backup of the database.
4. It is recommended that the online log files must realize the mirror phase on different disks to avoid this situation, because
Any loss of data is not permissible for production.

If there is no backup, make mandatory recovery
1, open the database, you will encounter a similar error
Ora-00313:open failed for members of log Group 1 of thread 1
Ora-00312:online Log 1 Thread 1: ' D:\ORACLE\ORADATA\TEST\REDO01. LOG '
Ora-27041:unable to open File
Osd-04002:unable to open File
O/s-error: (OS 2) The system could not find the specified file

2, view V$log, found is the current log
Sql> select Group#,sequence#,archived,status from V$log;

group# sequence# Archived STATUS
---------- ---------- -------- ----------------
1 1 NO Current
2 2 YES INACTIVE
3 3 YES INACTIVE

3. Found clear not successful
Sql> ALTER DATABASE Clear unarchived logfile Group 1;
ALTER DATABASE Clear unarchived logfile Group 1
*
ERROR at line 1:
Ora-01624:log 1 needed for crash recovery of thread 1
Ora-00312:online Log 1 Thread 1: ' D:\ORACLE\ORADATA\TEST\REDO01. LOG '

4, the database down
Sql>shutdown Immediate

5, add the following parameters in the Init<sid>.ora
_allow_resetlogs_corruption=true

6, restart the database, using until cancel recovery
Sql>recover database until cancel;
Cancel
If you make a mistake, stop ignoring it and send out
Sql>alter database open resetlogs;

7. After the database is opened, execute a full export immediately.

8, Shutdown database, remove _all_resetlogs_corrupt parameters

9. Rebuild the Library

10. Import and complete recovery

11, the proposal executes analyze TABLE ... VALIDATE STRUCTURE CASCADE;
Description
1, the recovery method is no way after the recovery method, generally recommended not to use, because the method
May cause inconsistencies in the database
2, this method also loses the data, but the lost data does not have the previous method the data to be many, mainly is writes the number
Submitted or uncommitted data according to the document.
3, the recommendation of the successful implementation of the above 7 to 11 steps to complete the database inspection and analysis
4, all completed after the full backup of the database
5. It is recommended that the online log files must realize the mirror phase on different disks to avoid this situation, because
Any loss of data is not permissible for production.



Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

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.