Time-point-based Incomplete recovery for RMAN backup and recovery

Source: Internet
Author: User
RMAN recovery is divided into full recovery and Incomplete recovery. Full recovery, as its name implies, is to restore data based on full backup. However, in the real environment, such recovery is very useful.

RMAN recovery is divided into full recovery and Incomplete recovery. Full recovery, as its name implies, is to restore data based on full backup. However, in the real environment, such recovery is very useful.

Explanation of Incomplete recovery

In the previous article (loss of the UNDO tablespace caused by RMAN backup and recovery), we talked about how to deal with the loss of the UNDO tablespace. The UNDO tablespace cannot be taken offline. Similarly, the SYSTEM tablespace cannot be taken offline. Therefore, the solution for the loss of the SYSTEM tablespace is similar to that for the loss of the UNDO tablespace.

RMAN recovery is divided into full recovery and Incomplete recovery. Full recovery, as its name implies, is to restore data based on full backup. However, in the real environment, such recovery is rarely used. On the contrary, Incomplete recovery is often used. Incomplete recovery, that is, restoring a misoperation or data loss in a certain period of time through the backup file. Incomplete recovery can be based on the time, SCN, log serial number, and backup control file. This article describes Incomplete recovery based on time points.

2. Explanation of Incomplete recovery based on time points

As in the previous article, to restore a database, we must first have a backup file. We use the RMAN tool to back up the database. After the backup is complete, we switch to SQL Plus to enable the option of displaying the full time. Why do we need to display the full time? Because recovery based on time points requires a time point, after enabling this option, we can conveniently view the time experienced in the operation process, the second is to ensure the accuracy of the time point selection. Then we log on to SCOTT, create a test table, insert data, and manually submit the table. Note: To ensure data consistency, we recommend that you SWITCH to the SYS user to manually SWITCH the log (alter system switch logfile) and manually trigger the CKPT (altersystem checkpoint ). Now, the data preparation is complete. At this time, we delete the table, clear the recycle bin, and write down the time point before the table is deleted. We will use the recovery operation later. Now we force close the database, log on to RMAN, start the database to the MOUNT state, and then check the current INCARNATION number. What is the INCARNATION number. We can understand that every RESETLOGS will cause INCARNATION + 1. If you want to restore to the scn (or time point) of INCARNATION, You need to jump to the previous INCARNATION first. TO jump TO the previous INCARNATION, we can use the following command: RESET DATABASE TO INCARNATION . An inappropriate analogy is that INCARNATION is like we are at a crossroads. At this time, we don't know which direction to take. If you go wrong, you have to go back to this crossroads and select the next one. In this case, we need to edit the recovery script to tell Oracle at which point to restore and restore the database. After the restoration, we need to use the RESETLOGS method to open the database. At this time, we log on to SQL Plus to view only the data in the table. If the data can be queried successfully, it indicates that the restoration is successful. If no query is available, check whether the time point is correct, check whether the INCARNATION number is correct, and check whether the third data is consistent. Because we reset the log, we need to back up the database again. So far, the complete recovery operation has been completed.

3. Recovery Simulation Based on Time points

Step 1. Make sure that the database is in archive mode and that the database is backed up in RMAN in SQL Plus.

SQL> ARCHIVE LOG LIST;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 68
Next log sequence to archive 70
Current log sequence 70
[Oracle @ orcl ~] $ Uniread rman target/
[Uniread] Loaded history (2 lines)

Recovery Manager: Release 11.2.0.3.0-Production on Fri Jan 17 09:44:40 2014

Copyright (c) 1982,201 1, Oracle and/or its affiliates. All rights reserved.

Connected to target database: LARRRDB (DBID = 3428598070)

RMAN> backup database;

Starting backup at 17-JAN-14
Using target database control file instead of recovery catalog
Allocated channel: ORA_DISK_1
Channel ORA_DISK_1: SID = 36 device type = DISK
Channel ORA_DISK_1: starting full datafile backup set
Channel ORA_DISK_1: specifying datafile (s) in backup set
Input datafile file number = 00001 name =/u01/oracle/oradata/larrrdb/system01.dbf
Input datafile file number = 00003 name =/u01/oracle/oradata/larrrdb/undotbs01.dbf
Input datafile file number = 00002 name =/u01/oracle/oradata/larrrdb/sysaux01.dbf
Input datafile file number = 00004 name =/u01/oracle/oradata/larrrdb/users01.dbf
Channel ORA_DISK_1: starting piece 1 at 17-JAN-14
Channel ORA_DISK_1: finished piece 1 at 17-JAN-14
Piece handle =/u01/oracle/fast_recovery_area/LARRRDB/backupset/2014_01_17/blank _. bkp tag = TAG20140117T094447 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:04:07
Channel ORA_DISK_1: starting full datafile backup set
Channel ORA_DISK_1: specifying datafile (s) in backup set
Including current control file in backup set
Including current SPFILE in backup set
Channel ORA_DISK_1: starting piece 1 at 17-JAN-14
Channel ORA_DISK_1: finished piece 1 at 17-JAN-14
Piece handle =/u01/oracle/fast_recovery_area/LARRRDB/backupset/2014_01_17/blank _. bkp tag = TAG20140117T094447 comment = NONE
Channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 17-JAN-14

Step 2: enable SQL Plus to display the full time

SQL> CONN SCOTT/tiger;
Connected.
SQL> SET TIME ON;
09:53:34 SQL>

Step 3: Create a test table using SQL Plus

09:53:34 SQL> CREATE TABLE test (id NUMBER (2), name VARCHAR (20 ));

Table created.

09:53:59 SQL>

Step 4: insert and submit data in SQL Plus. To maintain data consistency, it is best to use sys to manually switch logs (ALTER SYSTEM SWITCHLOGFILE) and trigger CKPT (ALTERSYSTEM CHECKPOINT)

09:53:59 SQL> INSERT INTO test VALUES (1, 'justdb ');

1 row created.

09:54:16 SQL> COMMIT;

Commit complete.

09:54:25 SQL> SELECT * FROM test;

ID NAME
------------------------------
1 justdb

09:54:33 SQL>

Step 5: Delete the test table in SQL Plus

At 09:54:33 SQL> DROP TABLE test PURGE;

Table dropped.

Step 6: Disable Database Consistency in SQL Plus

10:00:09 SQL> SHUTDOWN IMMEDIATE;
Database closed.
Database dismounted.
ORACLE instance shut down.
10:01:57 SQL>

Step 7: edit the recovery script based on time points. Pay attention to the selection of time points. Select the time point for table deletion (09:54:33). Pay attention to the time point.

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.