Oracle databases have two log operation modes: nonarchivelog and archivelog.
3.1 nonarchivelog Mode
Non-archive mode refers to the log operation mode that does not retain redo records. This mode is only suitable for instance recovery and not for media recovery. Features:
1. After the checkpoint is completed, the lgwr process can overwrite the duplicate log Content.
2. database recovery can only be restored to a previous full backup point
3. When the database is open, it cannot be backed up
4. During database backup, only shutdown immediate, shutdown normal, and shutdown transactional can be performed.
5. During database backup, all control files and redo log files must be backed up.
3.2 archivelog Mode
Archive mode refers to the log operation mode that can retain redo records. This mode is suitable for instance and media recovery. When the database is in archive mode, the background process lgwr will switch logs, copy the redo log content to the archived log file. Features:
1. You can back up a database in the open state.
2. When a media failure occurs, data files in other tablespaces except the system tablespace can be restored in the open state.
3. You can perform full or time-based recovery for database recovery.
3.3 change log Operation Mode
Oracle recommends that the OLTP system adopt archivelog mode and the data warehouse system adopt nonarchivelog. In addition, nonarchivelog can be used for development and archivelog can be used for production.
To change the log operation mode, you must perform the following operations as sysdba or sysoper:
1. Check the log operation mode.
Sqlplus sys/manager @ demo as sysdba <br/> SQL> select log_mode from V $ database; </P> <p> log_mode <br/> ------------ <br/> noarchivelog
2. Shut down the database
SQL> shutdown immediate; <br/> SQL> startup Mount;
3. Change the log Operation Mode
The log running mode can be changed only when the started data block of the instance is loaded but not opened.
SQL> alter database archivelog; <br/> SQL> alter Databse open;
Note: The arch process starts automatically after the database is set to archivelog mode from Oracle 10 Gb. in earlier versions, the initialization parameter log_archive_start = true must be configured;
SQL> alter system set log_archive_start = true scope = spfile ;.
3.4 configure other archive Parameters
From Oracle 10 Gb, archive logs are stored in the directory corresponding to the quick recovery zone (corresponding to the initialization parameter db_recovery_file_dest ). To change the location or name of an archived log file, modify the configuration parameters.
1. Configure the name format of the archive log file
The initialization parameter log_archive_format sets the name format of the archive log. The Wildcards are as follows:
% S: log serial number
% S: log serial number (with leading 0)
% T: Number of the redo thread
% T: Number of the redo thread (with leading 0)
% D: Database ID
% R: ID value of resetlogs
Note: Starting from Oracle 10 Gb, % s, % T, and % R are required. Because the log_archive_format parameter is static, You need to restart the database after modification. Example:
SQL> alter system set log_archive_format = '% S _ % T _ % R. log' scope = spfile;
SQL> shutdown;
SQL> startup;
2. Use log_archive_dest_n to configure the archiving location
The initialization parameter log_archive_dest_n is used to specify the location of multiple archived logs. N represents an integer ranging from 1 to 10. You can use this parameter to configure not only the location of multiple local archived logs, but also the remote archiving location. This parameter differs from log_archive_dest (specify the first location) and log_archive_duplex_dest (specify the second location.
Log_archive_dest_n can be used to configure local and remote archiving locations, while the other two can only be used to configure local archiving locations.
Log_archive_dest_n can be configured with up to 10 archiving locations, while the other two can only be configured with up to two archiving locations.
Log_archive_dest_n cannot be used together with the other two.
Example:
SQL> alter system set log_archive_dest_1 = 'location = C:/demo/log optional ';
SQL> alter system set log_archive_dest_2 = 'location = D:/demo/log mandatory ';
SQL> alter system set log_archive_dest_1 = 'service = afei'; (Remote archiving)
Optional is the default option, indicating that the redo log can be overwritten no matter whether the archiving is successful or not. Mandatory indicates that the redo log can be overwritten only after the archiving is successful.
3. Use log_archive_dest_state_n to control the archiving location
If there is not enough disk space in the archive location, archive will fail. To solve this problem, you may need to temporarily disable the corresponding specified location, this parameter can be used to control whether the specified log location is available. Enable indicates available (default), and defer indicates unavailable. Example:
SQL> alter system set log_archive_dest_state_2 = defer;
4. Use log_archive_max_processes to control the number of archiving processes
By default, Oracle starts two archiving processes. For example:
SQL> alter system set log_archive_max_processes = 4;
5. Use log_archive_min_succeed_dest to control the minimum number of logs successfully archived
SQL> alter system set log_archive_min_succeed_dest = 2;
After the preceding statement is executed, if the number of archived logs generated locally is less than two, the redo logs cannot be overwritten.
3.5 display archive information
1. Use archive log list
2. Display archived log information
SQL> select name, sequence #, first_changed # from V $ archived_log;
3. display the location of archived logs
SQL> select dest_name, destination, status from V $ archive_dest;
4. Display log history information
SQL> select * from V $ loghist;
5. Display archiving process information
SQL> select * from V $ archive_processes;