Oracle redo log
Oracle Redo Log recordFor all database changes, when you perform DML or DDL operations, oracle records the database changes to the redo log. The primary purpose of Redo Log is to use the Redo Log to recover an instance or media failure.
(Official documentation: Redo log, which consists of two or more preallocated files that store all changes made to the database as they occur. every instance of an Oracle Database has an associated redo log to protect the database in case of an instance failure .) before Oracle executes any DML or DDL operations to change data, it will restore the required information, first write the redo log buffer, and then write it into the database high-speed buffer. The name redo log indicates its purpose: When the database crashes, the RDBMS can redo (re-process) all changes on datafiles which will take the database data back to the state it was when the last redo record was written. two types of major database faults of the Redo Log application: 1. system faults: if the server where the database is located is powered off or the operating system is incorrect, the instance fails. Database data inconsistency: uncommitted transactions have committed data modifications to the data file + committed transactions have not committed data modifications to the data file
Because the database writes the log file first and then writes the update mechanism of the data file, and the two are asynchronous (improving performance ).
1) For "uncommitted transactions have submitted data modifications to the data file"
When the database is restarted, log files are scanned reversely from the end to the end, and undo uncommitted transactions. Undo
2) For "The data modification of committed transactions has not been submitted to the data file"
When the database is restarted, log files are scanned forward from start to end to redo committed transactions. Redo
Fault recovery: Oracle automatically completes the fault based on the log file content. No user intervention is required, and all data is not lost. In this case, the database is opened for a longer time than normal shutdown.
2. Media failure: if a permanent fault occurs on the disk drive that contains data files, Oracle uses archive redo logs and online redo logs to restore the backup of the disk drive to an appropriate time point. Cause: Hard Disk data is lost, which is extremely destructive. Fault recovery: 1. reinstall the database system 2. mount the latest database backup 3. all log file backups after the latest Database Backup need to be manually completed. If there is no log file backup, some data will be lost. Redo Log FilesSELECT * FROM v $ log; SELECT * FROM v $ logfile;
Archive Log is a non-active backup of redo logs. archive logs can be used to keep all redo history records. When the database is in ARCHIVELOG mode and the log is switched, the background process ARCH will save the redo log content to the archive log. when a media failure occurs in the database, you can use data file backup, archive logs and redo logs to completely restore the database. The production environment must use the archive mode. Thomas Kyte said that if the system does not run in ARCHIVELOG mode, it cannot be considered a production system. <Oracle Database 9i10g11g programming Art: go deep into the Database architecture> The following is a clear example of a media fault:Suppose you make a backup on Saturday every week. It's Friday afternoon, and hundreds of redo logs have been generated this week. Suddenly your disk has a problem. If you are not running in ARCHIVELOG mode, the options are as follows:
- Delete the tablespace related to the failed disk. As long as a tablespace has files on the disk, the tablespace (including the contents of the tablespace) needs to be deleted ). This method cannot be used if the SYSTEM tablespace (Oracle Data Dictionary) is affected.
- Restore data from last Saturday, and this week's work will be done in vain.
Either of them is not a good choice. Both methods mean that you will lose data. However, if you have previously run in ARCHIVELOG mode, you only need to find another disk. You need to recover the affected files to this disk based on the backup last Saturday. Finally, archive and redo logs and (final) Online redo logs for these files. In fact, the whole week's transactions are replayed in a fast forward manner. In this way, nothing will be lost. The data will be restored to the point at which the failure occurred. Oracle log miningReference: http://en.wikipedia.org/wiki/redo_logdata warehouse fault Oracle Redo Log mechanism Summary