Archive mode for oracle Common commands for ORACLE database archive logs

  • 2021-06-28 14:26:39
  • OfStack

--Connection Recovery Manager

C:\Documents and Settings\mengzhaoliang > rman target/

--Archive log list
RMAN > list archivelog all;

--Delete archive logs where physical files do not exist
RMAN > delete expired archivelog all;

--Delete archive logs 7 days ago
RMAN > DELETE ARCHIVELOG ALL COMPLETED BEFORE 'SYSDATE-7';

Archiving mode for oracle

1.Check if the oracle database is in archive mode:
1.select name,log_mode from v$database;
NAME LOG_MODE
------------------ ------------------------
QUERY NOARCHIVELOG
2. Use the ARCHIVE LOG LIST command
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /data/oracle/product/10.2.0/db_1//dbs/arch
Oldest online log sequence 739
Current log sequence 741

2.What is Oracle archiving mode?

The Oracle database has an online redo log, which records changes made to the database, such as insertions, deletions, updates, and so on, all of which are recorded in the online redo log.1 General databases must have at least two online redo log groups.When an online redo log group is full, a log switch occurs. Online redo log group 2 becomes the current log used. When online redo log group 2 is full, a log switch occurs to write online redo log group 1, which is repeated.
Online logs are discarded when switching if the database is in non-archiving mode. In archiving mode, switched logs are archived when log switching occurs.For example, currently using online redo log 1, when 1 is full, a log switch occurs and online redo log 2 starts to be written. The contents of online redo log 1 will be copied to another specified directory.This directory is called the archive directory, and copied files are called archive redo logs.
Catastrophic recovery is only possible when the database is running as an archive.
1. Differences between archived and non-archived log modes
Non-archive mode can only make cold backups, and full backups can only be made when restoring. Data from the last full backup to the time of system error cannot be restored.
Archive mode can make hot backup, incremental backup and partial recovery.
With ARCHIVE LOG LIST, you can see whether the archive mode or the non-archive mode is in the state of the period mode.

3.Configure the archiving mode of the database

Change non-archive mode to archive mode:
1)SQL > SHUTDOWN NORMAL/IMMEDIATE;
2)SQL > START MOUNT;
3)SQL > ALTER DATABASE ARCHIVELOG;
4)SQL > ALTER DATABASE OPEN;
5)SQL > Make a full backup because the backup log generated in non-archived log mode is no longer available for archive mode. This step is not very important!

Change the archive mode to non-archive mode:
1)SQL > SHUTDOWN NORMAL/IMMEDIATE;
2)SQL > START MOUNT;
3)SQL > ALTER DATABASE NOARCHIVELOG;
4)SQL > ALTER DATABASE OPEN;

3. Enable automatic archiving: LOG_ARCHIVE_START=TRUE

In archive mode, log filegroups are not allowed to be overwritten (rewritten). If no manual archiving is performed after the log files are full, the system will hang until the archiving is complete.
You can only read but not write at this time.
Close and restart the archive log process while running
SQL > ARCHIVE LOG STOP
SQL > ARCHIVE LOG START

4. Manual archiving: LOG_ARCHIVE_START=FALSE

Archive the current log file
SQL > ALTER SYSTEM ARCHIVE LOG CURRENT;
Archive log file with serial number 052
SQL >ALTER SYSTEM ARCHIVE LOG SEQUENCE 052;
Archive all log files
SQL > ALTER SYSTEM ARCHIVE LOG ALL;
Change archive log target
SQL > ALTER SYSTEM ARCHIVE LOG CURRENT TO ' & PATH

Related articles: