Oracle controlfile backup and recovery

Source: Internet
Author: User

Backup:

Alter Database Backup controlfile to 'xxxxxxx' reuse;
Alter database bakcup controlfile to trace as 'xxxxxxx ';
RMAN backup control file

Restore an instance:

1. Use binary backup for recovery after the control file is damaged (abnormal power failure)

Backup control file:
Alter Database Backup controlfile to '/home/Oracle/control. CTL' reuse;
Insert test data:
SQL> insert into T1 values (1 );
SQL> commit;
Simulated power failure:
SQL> shutdown abort;
Simulate Control File Failure:
Rm-RF/database/oradata/skyread/control01.ctl
Rm-RF/database/oradata/skyread/control02.ctl
Rm-RF/database/oradata/skyread/control03.ctl
Enable the database again:
SQL> startup;
ORA-00205: Error in identifying control file, check Alert Log for more info
00205 error reported
Copy the backup file to the location of the Database Control file:
CP/home/Oracle/control. CTL/database/oradata/skyread/control01.ctl
CP/home/Oracle/control. CTL/database/oradata/skyread/control02.ctl
CP/home/Oracle/control. CTL/database/oradata/skyread/control03.ctl
SQL> startup force Mount
Total system global area 5049942016 bytes
Fixed size 2090880 bytes
Variable Size 1375733888 bytes
Database buffers 3657433088 bytes
Redo buffers 14684160 bytes
Database mounted.

Check the SCN information of data files, data file headers, log files, and control files. The fuzzy status here is yes because the machine loses power.

SQL> SELECT FILE #, status, fuzzy, checkpoint_change # from V $ datafile_header;
File # status fuz checkpoint_change # -------------------- ------- --- -------------------- 1 online Yes 122694280130 2 online Yes 122694280130 3 online Yes 122694280130 4 online Yes 122694280130 18 online Yes 122694280130 26 online Yes 122694280130 31 online Yes 122694280130

SQL> select group #, sequence #, members, archived, status, first_change # from V $ log;
Group # sequence # members arc status first_change # specified sequence -------------------- --- ---------------- -------------------- 1 1 1 1 no current 122694212304 2 2 1 Yes inactive 122693905385 5 3 1 Yes inactive 122694191761 4 4 1 Yes inactive 122694190542 3 5 1 Yes inactive 122694168156

Controlfile_change # is the control file SCN during backup. The data file checkpoint must be greater than the backup control file at that time. Therefore, when data is opened, data files, log files, the checkpoint information of the control file is inconsistent and can be opened only after the media is restored to the same level. The above V $ log and V $ datafile are consistent with the checkpoint of the backup control file. However, V $ datafile_header records the latest information, that is, before the database is closed. Therefore, if it is enabled, it will check whether the checkpoint count in the data file header is equal to the checkpoint Technology in the current control file. If it is equal, perform the second check, that is, check whether the SCN at the beginning of the data file header is equal to the SCN at the end of the control file. If they are equal, you do not need to restore them. If they are not equal, you need to restore them. This is obviously not the same, so we need a recovery.SQL> select checkpoint_change #, controlfile_change #, resetlogs_change # from V $ database;
Checkpoint_change # controlfile_change # resetlogs_change # -------------------- ---------------------- 122694212305

122694259161
122693676208

Media recovery database: prompted to apply redo01.log SQL> recover database using backup controlfile; ORA-00279: Change 122694280130 generated at 05/03/2013 11:25:37 needed for thread 1 ORA-00289: Suggestion: /database/oradata/ARCH/connector 814447469.dbf ORA-00280: Change 122694280130 for thread 1 is in sequence #1

Specify log: {<RET> = suggested | filename | auto | cancel}/database/oradata/skyread/redo01.log log applied. media recovery complete. reset the log file to open the database: SQL> alter database open resetlogs; database altered.


2. after the control file is corrupted, use the trace file to recreate the control file (normally shut down). The backup control file is in the text format: SQL> alter Database Backup controlfile to trace as '/home/Oracle/controlfile. SQL 'reuse; database altered. clean and close the database and destroy all control files SQL> shutdown immediate;

MV/database/oradata/skyread/control01.ctl/database/oradata/skyread/control01.ctl. bak mV/database/oradata/skyread/control02.ctl/database/oradata/skyread/control02.ctl. bak mV/database/oradata/skyread/control03.ctl/database/oradata/skyread/control03.ctl. bak

An error occurred while opening the database: SQL> startup; Oracle instance started.
Total system global area 5049942016 bytes fixed size 2090880 bytes variable size 1375733888 bytes database buffers 3657433088 bytes redo buffers 14684160 bytes ORA-00205: Error in identifying control file, check Alert Log for more info

In nomount mode, use/home/Oracle/controlfile. the SQL statement re-constructs the control file. Note that noresetlogs is used here. Here, we close the data for testing, which is equivalent to no damage to both the data file and log file, the control file is constructed based on the information of the data file header and Log File Header. Therefore, the control file and the data file header are consistent with the log file header. Since they are consistent, no recover is required, open the database directly. Note: If the binary backup control file is used for restoration, recover is required because the backup binary file is inconsistent with the current data file header information.Create controlfile reuse Database "skyread" noresetlogs force logging archivelog maxlogfiles 20 maxlogmembers 5 maxdatafiles 1000 maxinstances 8 maxloghistory 2337 logfile group 1'/database/oradata/skyread/redo01.log 'size 512 m, group 2'/database/oradata/skyread/redo02.log 'size 512 M, group 3'/database/oradata/skyread/redo03.log' size 512 m, group 4'/database/oradata/skyread/redo04.log 'size 512 m, group 5'/database/oradata/skyread/redo05.log 'size 512 M datafile'/database/oradata/skyread/system01.dbf', '/database/oradata/skyread/tbs_test.dbf ', '/database/oradata/skyread/sysaux01.dbf','/database/oradata/skyread/users01.dbf ','/database2/oradata/skyread/tbs_mrpmusic01.dbf ', '/database/oradata/skyread/sf01.dbf','/database2/oradata/skyread/undotbs02 'character set utf8;

SQL> alter database open; database altered

 

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.