If the delete [all] input clause is used to back up archived logs. This article provides examples of restoring archived logs and restoring archived logs separately, as well as restor
If the delete [all] input clause is used to back up archived logs. This article provides examples of restoring archived logs and restoring archived logs separately, as well as restor
I have heard of the restoration (restore) database, tablespace and database files, and the use of archive log recovery (recover) database, tablespace, and database files. Restore. What about restoring archived logs? Yes, we may ignore the archive log restoration process because the archive log is usually automatically restored by Oracle during recover. In most cases, we first restore the database, restore the database, and open the database. In fact, there is an action before restoring the database, that is, restoring the archive log, that is, restoring the log file to the default archive location, if the delete [all] input clause is used to back up archived logs. This article provides examples of restoring archived logs separately and restoring archived logs, as well as some usage of restore archivelog, just to better understand the restoration and restoration processes, because in most cases, the data file is restored to the default path. If it is restored to a non-default path, you need to manually restore archivelog.
1. Understanding restoration and recovery
Restoration: replace or copy a data file (possibly damaged) with a previous backup to a new path. This is usually the case in most cases.
Recovery: apply the archived logs after backup to the database, and refresh the database to a specific or up-to-date state based on the transaction of the archived logs (usually after restoration ). Roll back the committed transactions in the archived logs.
Restore archived logs: Restoring archived logs is a process between restoring a database and restoring a database. It restores the archive logs deleted using the delete [all] input Method When backing up archive logs to the default archive location. After the database is restored, archive logs are required for recover, that is, media recovery. After restoration, perform
Where are the archive logs required for recover? Is there a specified archiving path for archiving logs? If yes, a message is displayed during restoration. The archived log is already in the specified location.
If no, but there is a backup archive backup set. The backup set contains backup slices, that is, archived logs. Now that the package is packaged, You Need To unpackage the package to the default path or the specified path. This is to restore the archive log.
2. The example shows how to restore archived logs.
-- Demo Environment
-- To better simulate the restoration of archive logs, we only use a specific data file for copy backup, and then back up the archive logs (the archive logs are deleted during Backup)
-- Then destroy the data file, restore the data file, restore the archived log file, and restore the log file.
[Oracle @ linux3 ~] $ Cat/etc/issue
Enterprise Linux Server release 5.5 (Carthage)
Kernel \ r on an \ m
[Oracle @ linux3 ~] $ Sqlplus-V
SQL * Plus: Release 11.2.0.1.0 Production
A. Back up data files and archive logs
RMAN> list backup of archivelog all; ---> list archived logs backed up by the current database
Specification does not match any backup in the repository
RMAN> list backupset; ---> list existing backup sets of the current database
Specification does not match any backup in the repository
SQL> select username, default_tablespace from dba_users where username = 'Scott '; --> View the tablespace and data file where user SCOTT is located.
USERNAME DEFAULT_TABLESPACE
------------------------------------------------------------
SCOTT USERS
SQL> select name, file # from v $ datafile where tablespace_name = 'users ';
Name file #
----------------------------------------------------------------------
/U01/database/sybo3/oradata/users01.dbf 4
SQL> conn scott/tiger;
Connected.
SQL> select name, sequence #, status, COMPLETION_TIME from v $ archived_log where status = 'a'; --> the current system does not have any archived logs
No rows selected
SQL> host;
RMAN> copy datafile 4 to '/u01/database/sybo3/fra/SYBO3/backupset/2013_07_26/users01.dbf'; --> Use rman copy to back up data files
RMAN> list copy;
Using target database control file instead of recovery catalog
Specification does not match any control file copy in the repository
Specification does not match any archived log in the repository
List of Datafile Copies
======================================
Key File S Completion Time Ckp SCN Ckp Time
------------------------------------------------------------
3 4 A 20:10:31 961662 20:10:31
Name:/u01/database/sybo3/fra/SYBO3/backupset/2013_07_26/users01.dbf
Tag: tag2013020.t201031
--> Prepare a test table to verify whether the restoration is successful.
SQL> create table t1 (seq varchar2 (10), who varchar2 (20 ));
SQL> insert into t1 select 'first ', 'Robin' from dual;
SQL> commit;
SQL> alter system archive log current; --> Generate archive logs
SQL> select name, sequence #, status, COMPLETION_TIME from v $ archived_log where status = 'a ';
Name sequence # S COMPLETION_TIME
------------------------------------------------------------------------------------------------------------
/U01/database/sybo3/fra/SYBO3/archivelog/2013_07_26/o1_mf_1_27_8z4sy 5ft _. arc 27 A 20130726 20:12:53
SQL> insert into t1 select 'second', 'robinson 'from dual;
SQL> commit;
SQL> alter system archive log current; --> Generate archive logs again
SQL> select name, sequence #, status, COMPLETION_TIME from v $ archived_log where status = 'a ';