RMAN backup and recovery control file loss

Source: Internet
Author: User
To back up the RMAN backup and recovery control files, we must first back up the database. The database backup process is as follows: RMAN backs up the entire database

To back up the RMAN backup and recovery control files, we must first back up the database. The database backup process is as follows: RMAN backs up the entire database

1. Preface

As a saying goes, "You must know what it is, but you must know what it is ". But I don't know why. Why. This series of articles will show you how to do it and why it will also be involved. However, due to the limited level, the principle is not profound enough. I hope that the readers can understand the concept.

I have read a lot of materials recently and are also thinking about the value that the technology we are pursuing can bring to this society. It's a bit boring to walk on the road of technology, but why?

2. Description of RMAN backup and recovery Control Files

We often say "backup is more important than everything". If there is a problem, it can be recovered from the backup file. This series of articles explains how to back up and restore RMAN. RMAN can be used to back up and restore database files, archive logs and control files. It can also be used to perform full or incomplete database Recovery. RMAN Backup methods include Full Backup, Incremental Backup, Open Backup, Closed Backup, and Consistent Backup) inconsistent Backup ). RMAN recovery has full recovery and Incomplete recovery. Incomplete recovery can be performed based on the time, SCN, log serial number, and backup control file.

The control file records the structure and behavior of the database. For the database, the control file is very important. If the control file is faulty and the parameter file is normal, the database can only start to NOMOUNT. By default, the Oracle 11g control file is stored in the data directory and the other in the flashback directory. There are also multiple control files in the real environment. Generally, three files are recommended.

To back up the RMAN backup and recovery control files, we must first back up the database. The database backup process is as follows: After RMAN issues the backup full database command, RMAN generates the bequeath connection to the target database, that is, it checks the Instance name in the parameter la_sid variable, in addition, a server process is generated on the instance and then logged on as sysdba. Then a backup channel is generated (in fact, it is also a process, and storage is allocated in PGA or SGA ). Then RMAN calls SYS. DBMS_RCVMAN to request the database structure information, including the control file information (current serial number, creation time ......), Because the full backup database is specified, RMAN will request the data file information in the database and determine whether there is an offline data file (including the location and working method ). RMAN starts backup. To maintain data consistency, RMAN must create a snapshot of the control file. Next, RMAN calls the DBMS _ BACKUP_RESTORE data package. This call can create a backup file. RMAN has a file list, so it allocates a memory buffer for data file read operations. After the buffer is allocated, RMAN initializes the backup disk. Once the backup file is initialized, RMAN determines whether the server parameter file is used. If yes, it will be used as a part of the backup and also backup the control file before backing up the data file, and push it to the memory. To implement this function, the channel process performs a pre-read operation on the disk and reads multiple data files into the memory. RMAN checks whether the data block header information is still zero, if the data block has not been used, it will not be written to the output buffer, and the data block will be discarded (this is why RMAN only backs up the used data, is also its advantage ). RMAN also checks whether the data block has an uption operation. When the check is passed, it is written to the output buffer. Once the output buffer is full, it is pushed to the backup file location. When backing up data blocks, the RMAN shadow process obtains the backup status information and sends it to the V $ session_longops view to query the information. When all data blocks in the data file are read into the input buffer and the status is determined, RMAN will end the backup operation by writing the data file to the backup file. After all data files are written to the BACKUP file, RMAN generates the last call to the sys dbms backup restore data packet. This call writes the BACKUP information (including the BACKUP name, the SCN of the checkpoint when the backup operation is started and the time when the backup is completed). This completes the backup!

After the database is backed up, we need to shut down the database consistently because the database is in the running state and writes content to the control file. If it is not closed, the version of the control file is inconsistent. After the database is shut down in consistency mode, we need to simulate the loss of control files. To avoid recovery errors, we do not use the rm command. It is also very dangerous to use this command in the real environment. We use the mv command. Then we start the database to the NOMOUNT state. Why is it NOMOUNT? Because the database starts up in three phases: instance startup, Database loading, database opening, and NOMOUNT, parameter files are used, because our control file is lost, it cannot be read and can only be started to NOMOUNT. Then, RMAN restores the database through the backup control file. Because the control file recovery is complete, the database can be started to the MOUNT state, so we continue to make the database to the MOUNT state, because the Database Control file is recovered through RMAN, we need to restore the database so that the control file takes effect and proofread and synchronize the control file version. Then we use RESETLOGS to open the database. Because the log file is cleared and the previous backup is invalid, we should back up the database again. This is crucial.

We can also use the RUN Command to write all operations into a human script, which can reduce many operations, provided that such a script has undergone rigorous testing.

Control File loss use the run Command

Syntax:

RUN {

Startup mount;

Restore controlfile from '/';

Alter database mount;

Recover database;

Alter database open resetlogs;

}

Example:

RUN {

STARTUPNOMOUNT;

Restorecontrolfile from '/u01/oracle/fast_recovery_area/JUSTDB/backupset/2013_12_11/o1_mf_ncsnf_TAG20131211T164208_9bj9c8rp _. bkp ';

Alterdatabase mount;

RECOVERDATABASE;

Alterdatabase open resetlogs;

}

Of course, this is just a simulation, and the control files are basically not lost in the real environment.

Three Control File loss simulation

Step 1: Back up the database

RMAN> backup database;

Related Article

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.