RMAN restores archivelog)

Source: Internet
Author: User
Tags file copy

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 ). For
The committed transactions in the log are rolled back, and uncommitted transactions are rolled back.
Restore archived logs: Restoring archived logs is a process between restoring a database and restoring a database. It uses the Delete [all] Input Method When backing up archived logs.
The deleted archive log is restored 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 packed, unpack the package to the default path.
Or specify the 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 (deleting the archive logs 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/issueenterprise Linux Enterprise Linux Server Release 5.5 (Carthage) kernel \ r on an \ m [Oracle @ linux3 ~] $ Sqlplus-vsql * Plus: Release 11.2.0.1.0 productiona, backup data files and archive logs RMAN> List backup of archivelog all; ---> list the archived logs that have been backed up by the current database specification does not match any backup in the repositoryrman> 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 username default_tablespace -------------------------------- Scott userssql> select name, file # from V $ datafile where tablespace_name = 'users '; name file # -------------------------------------------------------- ----------/u01/database/sybo3/oradata/users01.dbf 4sql> 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 selectedsql> host; RMAN> copy datafile 4 to '/u01/database/sybo3/FRA/sybo3/backupset/2013_07_26/users01.dbf'; --> Use RMAN copy to back up the data file RMAN> List copy; using target database control file instead of recovery catalogspecification does not match any control file copy in the repositoryspecification does not match any archived log in the repositorylist 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: tag201301_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 an archived log SQL> select name, sequence #, status, completion_time from V $ archived_log where status = 'a'; Name sequence # s completion_time hour -----------hour/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/hour 5ft _. arc 27 A 20130726 20: 12: 53sql> insert into T1 select 'second', 'robinson 'from dual; SQL> commit; SQL> alter system archive log current; --> Generate an archived log SQL statement again> select name, sequence #, status, completion_time from V $ archived_log where status = 'a '; name sequence # s completion_time parameter --------------------------/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_27_8z4sy 5ft _. arc 27 A 20130726 20:12:53/u01/database/Sybo/FRA/Sybo/archivelog/2013_07_26/o1_mf_1_28_8z4t1q0s _. arc 28 A 20130726 20:14:47 --> back up and archive the following logs and delete the backed up logs RMAN> Backup archivelog all Delete input; starting backup at 20: 16: 39 current log archivedusing target database control file instead of recovery catalogallocated channel: ora_disk_1channel ora_disk_1: SID = 21 device type = diskchannel ora_disk_1: Starting archived log backup setchannel ora_disk_1: specifying archived log) in backup set ---> archive log input archived log thread = 1 sequence = 27 recid = 23 stamp = 821823173 input archived log thread = 1 sequence = 28 recid = 24 stamp = 821823287 input archived log thread = 1 sequence = 29 recid = 25 stamp = 821823400 channel ora_disk_1: starting piece 1 at 2013/07/26 20: 16: 40 channel ora_disk_1: finished piece 1 at 2013/07/26 20: 16: 41 piece handle =/u01/database/Sybo/FRA/Sybo/backupset/2013_07_26/o1_mf_annnn_tag201301_t201640_8z4t58tn _. bkp tag = tag201301_t201640 comment = nonechannel ora_disk_1: Backup set complete, elapsed time: 00: 00: 01 channel ora_disk_1: deleting archived log (s) ---> the following message is displayed: delete archived log file name =/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_27_8z4sy 5ft _. arc recid = 23 stamp = 821823173 archived log file name =/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_28_8z4t1q0s _. arc recid = 24 stamp = 821823287 archived log file name =/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_29_8z4t585k _. arc recid = 25 stamp = 821823400 finished backup at 2013/07/26 20: 16: 41B. Simulate the destruction data file SQL> insert into T1 select 'La', 'end of test' from dual; SQL> commit; SQL> Ho CAT/dev/null>/u01/database/sybo3/oradata/users01.dbf ---> destroy data file SQL> select * from T1; ---> at this time, the buffer cache can still query the data seq who ---------- ------------------ first wait second until sonlast end of testsql> alter system checkpoint; ---> implements the Checkpoint Process System altered. SQL> select * from T1; ---> in this case the data file is not accessible select * from T1 * error at line 1: ORA-00376: file 4 cannot be read at this timeORA-01110: data file 4: '/u01/database/sybo3/oradata/users01.dbf' SQL> select * from V $ recover_file; select * from V $ recover_file * error at line 1: ORA-01135: file 4 accessed for DML/query is offlineORA-01110: data file 4: '/u01/database/sybo3/oradata/users01.dbf' C. Restore and recover corrupted data file SQL> select tablespace_name, status from dba_tablespaces where tablespace_name = 'users'; ---> tablespace is still onlinetablespace_name status --------- users onlinesql> alter tablespace users offline immediate; ---> tablespacetablespace altered damaged by offline. SQL> select tablespace_name, status from dba_tablespaces where tablespace_name = 'users'; ---> the status is offlinetablespace_name status -------------------------- --------- users offlinerman> restore datafile 4; ---> at this time, the restore datafile method prompts failure starting restore at 20: 30: 20 using channel ORA_DISK_1RMAN-00571: ========================================================== ============================== RMAN-00569: ================ error message stack follows ============================ RMAN-00571: ========================================================== ============================== RMAN-03002: failure of restore command at 07/26/2013 20: 30: 20ora-01135: file 4 accessed for DML/query is offlineORA-01110: data file 4: '/u01/database/sybo3/oradata/users01.dbf' RMAN-06010: Error while looking up datafile: 4 RMAN> restore tablespace users; ---> in this case, the system prompts "failed" using restore tablespace, it seems that for copy-based backup, you must copy it back ---> and look at the syntax. Restore (datafile 4) from datafilecopy can be done. The brackets cannot omit starting restore at 20: 31: 12 using channel ORA_DISK_1RMAN-00571: ========================================================== ============================== RMAN-00569: ================ error message stack follows ============================ RMAN-00571: ========================================================== ============================== RMAN-03002: failure of restore command at 07/26/2013 20: 31: 12ora-01135: file 4 accessed for DML/query is offlineORA-01110: data file 4: '/u01/database/sybo3/oradata/users01.dbf' RMAN-06019: cocould not translate tablespace name "users" --> Use copy to restore SQL> Ho CP/u01/database/sybo3/FRA/sybo3/backupset/2013_07_26/users01.dbf/u01/ database/sybo3/oradata/users01.dbf --> next we will restore the archived log, the from sequence clause is formulated. In fact, if we do not specify the restore archivelog, the archived log RMAN> restore archivelog from sequence 27; starting restore at will be automatically restored during RECOVER: 36: 55 using channel ora_disk_1channel ora_disk_1: Starting archived log restore to default destination ---> This is a key prompt. restore it to the default location of channel ora_disk_1: restoring archived logarchived log thread = 1 sequence = 27 channel ora_disk_1: Restoring archived logarchived log thread = 1 sequence = 28 channel failed: Restoring archived logarchived log thread = 1 sequence = 29 channel ora_disk_1: reading from backup piece/u01/database/Sybo/FRA/Sybo/backupset/2013_07_26/o1_mf_annnn_tag201301_t201640_8z4t58tn _. bkpchannel ora_disk_1: piece handle =/u01/database/sybo3/FRA/sybo3/backupset/2013_07_26/o1_mf_annnn_tag201301_t201640_8z4t58tn _. bkp tag = tag20130316t201640channel ora_disk_1: restored backup piece 1 channel ora_disk_1: restore complete, elapsed time: 00: 00: 01 finished restore at 20:36:57 -- Author: Robinson -- Blog: http://blog.csdn.net/robinson_0612 --> now you can see the restored archive log file SQL under the default path> Ho LS-hltr/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26 /* -RW-r ----- 1 Oracle oinstall 13 K Jul 26 20:36/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_29_8z4vc85w _. arc-RW-r ----- 1 Oracle oinstall 4.5 K Jul 26 20:36/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_28_8z4vc85z _. arc-RW-r ----- 1 Oracle oinstall 4.0 m Jul 26 20:36/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_27_8z4vc85o _. arc --> restore media RMAN> recover datafile 4; starting recover at 2013/07/26 20: 39: 56 using channel ora_disk_1starting media recovery ----> the following message indicates that the archived log already exists, this is because we previously performed restore archivelogarchived log for thread 1 with sequence 27 is already on disk as file/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/pai _. arcarchived log for thread 1 with sequence 28 is already on disk as file/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_28_8z4vc85z _. arcarchived log for thread 1 with sequence 29 is already on disk as file/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_29_8z4vc85w _. arcarchived log file name =/u01/database/sybo3/FRA/sybo3/archivelog/2013_07_26/o1_mf_1_27_8z4vc85o _. arc thread = 1 sequence = 27 media recovery complete, elapsed time: 00: 00: 00 finished recover at 20:39:56 --> online tablespacesql> alter tablespace users online; tablespace altered. --> verify that the SQL statement has been completed> select * from T1; seq who ---------- -------------------- first wait second then sonlast end of test

3. Other restore archivelog usage
Restore archivelog all; restore all archived log files
Restore archivelog from logseq 27; restore all archived logs after the log sequence is 27
Restore archivelog from logseq 27 until logseq 29; restore these archive logs whose log sequence is 27 to 29
Restore archivelog from time 'sysdate-7'; restore archived logs within seven days
Restore archivelog until logseq 29; restore to log files with a seqence of 29
Set archivelog destination to '/u01/database/sybo5/arch'; set the log file to the new path, as shown in figure
Run {
Set archivelog destination to '/u01/database/sybo5/arch ';
Restore archivelog low logseq 27 ;}
More use of resoter archive: http://docs.oracle.com/cd/B19306_01/backup.102/b14194/rcmsynta008.htm

 

References
Method for converting the cloned file location in the RMAN Database

RMAN-based database cloning on the same machine

User-managed database clone

Oracle cold backup

Oracle Hot Backup

Concept of Oracle backup recovery

Oracle instance recovery

Oracle recovery based on user management

System tablespace management and Backup Recovery

Sysaux tablespace management and recovery

Oracle backup control file recovery (unsing backup controlfile)

RMAN overview and architecture

RMAN configuration, Monitoring and Management

Detailed description of RMAN backup

RMAN restoration and recovery

Create and use RMAN catalog

Create RMAN storage script based on catalog

Catalog-based RMAN backup and recovery

RMAN backup path confusion

Customize the date and time format displayed by RMAN

Backup and recovery of read-only tablespace

Incomplete recovery of Oracle based on user management

Understanding using backup controlfile

Use RMAN for recovery from different machine backups (WIN platform)

Use RMAN to migrate a file system database to ASM

Oracle backup policy (RMAN) in Linux)

Linux RMAN backup shell script

Use RMAN to migrate the database to a different machine

Run the SQL statement at the RMAN prompt.

Oracle RMAN-based Incomplete recovery (Incomplete recovery by RMAN)

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.