Oracle Learning Rman (12) Resumes combat-control file loss

Source: Internet
Author: User

    1. Let's start with a full-library backup.

rman> run {  backup database   format  '/backup/full_%d_%T_%s '   plus archivelog   format  '/backup/arch_%d_%t_%s '   delete  all input; } starting backup at 2015/07/09 09:35:03current log  archivedusing channel ora_disk_1channel ora_disk_1: starting archived log  Backup setchannel ora_disk_1: specifying archived log (s)  in backup  setinput archived log thread=1 sequence=28 recid=27 stamp=884590414channel  Ora_disk_1: starting piece 1 at 2015/07/09 09:35:03channel ora_disk_1:  finished piece 1 at 2015/07/09 09:35:04piece handle=/backup/arch_devdb_ 20150709_115 tag=tag20150709t093503 comment=nonechannel ora_disk_1: backup set  complete, elapsed  Time: 00:00:01channel ora_disk_1: deleting archived log (s) archived log  File name=/backup/archivelog/1_28_884357806.dbf recid=27 stamp=884590414channel ora_disk_1 : starting archived log backup setchannel ora_disk_1: specifying  Archived log (s)  in backup setinput archived log thread=1 sequence=1  recid=28 stamp=884597703channel ora_disk_1: starting piece 1 at 2015/ 07/09 09:35:05channel ora_disk_1: finished piece 1 at 2015/07/09  09:35:06piece handle=/backup/arch_devdb_20150709_116 tag=tag20150709t093503 comment=nonechannel  ora_disk_1: backup set complete, elapsed time: 00:00:01channel ora_ Disk_1: deleting archived log (s) archived log file name=/backup/archivelog/1_1_ 884591314.dbf recid=28&nbSp stamp=884597703finished backup at 2015/07/09 09:35:06starting backup at  2015/07/09 09:35:06using channel ora_disk_1channel ora_disk_1: starting full  datafile backup setchannel ora_disk_1: specifying datafile (s)  in  backup setinput datafile file number=00001 name=/u01/app/oracle/oradata/devdb/ system01.dbfinput datafile file number=00002 name=/u01/app/oracle/oradata/devdb/ sysaux01.dbfinput datafile file number=00005 name=/u01/app/oracle/oradata/devdb/ example01.dbfinput datafile file number=00003 name=/u01/app/oracle/oradata/devdb/ undotbs01.dbfinput datafile file number=00004 name=/u01/app/oracle/oradata/devdb/ users01.dbfinput datafile file number=00006 name=/u01/app/oracle/oradata/devdb/ idx01.dbfchannel ora_disk_1: starting piece 1 at 2015/07/09 09:35:06channel ora_disk_1: finished piece 1 at 2015/07/09  09:36:41piece handle=/backup/full_devdb_20150709_117 tag=tag20150709t093506 comment= Nonechannel ora_disk_1: backup set complete, elapsed time: 00:01:35channel  ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1:  Specifying datafile (s)  in backup setincluding current control file in  backup setincluding current spfile in backup setchannel ora_disk_1:  starting piece 1 at 2015/07/09 09:36:42channel ora_disk_1: finished  piece 1 at 2015/07/09 09:36:43piece handle=/backup/full_devdb_20150709_118  tag=tag20150709t093506 comment=nonechannel ora_disk_1: backup set complete,  elapsed time: 00:00: 01finished backup at 2015/07/09 09:36:43starting backup at 2015/07/09  09:36:43current log archivedusing channel ORA_DISK_1channel ORA_DISK_1:  Starting archived log backup setchannel ora_disk_1: specifying archived  log (s)  in backup setinput archived log thread=1 sequence=2 recid =29 stamp=884597804channel ora_disk_1: starting piece 1 at 2015/07/09  09:36:44channel ora_disk_1: finished piece 1 at 2015/07/09 09:36:45piece  handle=/backup/arch_devdb_20150709_119 tag=tag20150709t093644 comment=nonechannel ora_ Disk_1: backup set complete, elapsed time: 00:00:01channel ora_disk_1:  deleting archived log (s) archived log file name=/backup/archivelog/1_2_ 884591314.dbf recid=29 stamp=884597804finished backup at 2015/07/09 09:36:45rman> 


2. Make data modifications to the tables in the database.

Sql> Conn Scott/tigerconnected.sql> Select COUNT (*) from emp_new; COUNT (*)----------229376sql> Delete from emp_new where deptno=10;49152 rows deleted. Sql> commit; Commit complete.  Sql> Select COUNT (*) from emp_new; COUNT (*)----------180224

3. Close the database.

Sql> conn/as sysdbaconnected.sql> shutdown immediatedatabase closed. Database dismounted. ORACLE instance shut down. Sql>

4. Delete the control file

Sql>! Rm/u01/app/oracle/oradata/devdb/control01.ctl sql>! Rm/u01/app/oracle/fast_recovery_area/devdb/control02.ctl

5. Using Rman Recovery control files

rman> restore Controlfile from '//backup/full_devdb_20150709_118 '; Starting restore at 2015/07/09 09:46:41using target database control file instead of recovery catalogallocated channel:or A_disk_1channel ora_disk_1:sid=19 device Type=diskchannel ora_disk_1:restoring control FileChannel Ora_disk_1:restore Complete, elapsed time:00:00:02output file Name=/u01/app/oracle/oradata/devdb/control01.ctloutput file Name=/u01/app /oracle/fast_recovery_area/devdb/control02.ctlfinished Restore at 2015/07/09 09:46:43rman>

6. Booting the database to the Mount state

rman> ALTER DATABASE Mount;database mountedreleased channel:ora_disk_1

7. Restore and restore the database

rman> restore database; Starting restore at 2015/07/09 09:48:56starting implicit crosscheck backup  at 2015/07/09 09:48:56allocated channel: ora_disk_1channel ora_disk_1: sid =21 device type=diskcrosschecked 3 objectsfinished implicit crosscheck  backup at 2015/07/09 09:48:56starting implicit crosscheck copy at 2015 /07/09 09:48:56using channel ora_disk_1finished implicit crosscheck copy at  2015/07/09 09:48:56searching for all files in the recovery  Areacataloging files...no files catalogedusing channel ora_disk_1channel ora_ Disk_1: starting datafile backup set restorechannel ora_disk_1: specifying  datafile (s)  to restore from backup setchannel ora_disk_1:  Restoring datafile 00001 to /u01/app/oracle/oradata/devdb/system01.dbfchannel ora_ Disk_1: restoring datafile 00002 to /u01/app/oracle/oradata/devdb/sysaux01.dbfchannel  ora_disk_1: restoring datafile 00003 to /u01/app/oracle/oradata/devdb/ undotbs01.dbfchannel ora_disk_1: restoring datafile 00004 to /u01/app/oracle/ oradata/devdb/users01.dbfchannel ora_disk_1: restoring datafile 00005 to /u01/ App/oracle/oradata/devdb/example01.dbfchannel ora_disk_1: restoring datafile 00006 to  /u01/app/oracle/oradata/devdb/idx01.dbfchannel ORA_DISK_1: reading from backup  Piece /backup/full_devdb_20150709_117channel ora_disk_1: piece handle=/backup/full_devdb_ 20150709_117 tag=tag20150709t093506channel ora_disk_1: restored backup piece  1channel ora_disk_1:  restore complete, elapsed time: 00:01:15finished restore at 2015/07/09  09:50:12RMAN> recover database; Starting recover at 2015/07/09 09:51:57using channel ora_disk_1datafile 6  not processed because file is read-onlystarting media  Recoveryarchived log for thread 1 with sequence 2 is already  on disk as file /u01/app/oracle/oradata/devdb/redo02.logarchived log for  thread 1 with sequence 3 is already on disk as file  /u01/app/oracle/oradata/devdb/redo03.logarchived log file name=/u01/app/oracle/oradata/ devdb/redo02.log thread=1 sequence=2archived log file name=/u01/app/oracle/oradata/ Devdb/redo03.log thread=1 sequence=3oracle error: ora-01547: warning: recover succeeded but open resetlogs would get error belowora-01190:  control file or data file 6 is from before the last  resetlogsora-01110: data file 6:  '/u01/app/oracle/oradata/devdb/idx01.dbf ' media  recovery complete, elapsed time: 00:00:04finished recover at 2015/07/09  09:52:02

We can see that the recovery is complete. However, according to the log can be seen, resetlogs open the database will be error.

Let's try to open it.

rman> ALTER DATABASE open resetlogs; RMAN-00571: ===========================================================rman-00569: =============== ERROR MESSAGE STACK follows ===============rman-00571: ===========================================================rman-03002: Failure of Alter DB command at 07/09/2015 09:53:21ora-01190:control file or data file 6 are from before the last Resetlogs Ora-01110:data file 6: '/U01/APP/ORACLE/ORADATA/DEVDB/IDX01.DBF '

When recovering a database, there is a message

DataFile 6 processed because file is read-only

DataFile 6 is read-only when doing a database backup. When we have finished backing up, we change the data in table Emp_new to read-write mode datafile 6. When doing recovery, did not go to recover datafile 6. Cause the data file to eventually be inconsistent.

So it can be concluded that once a table space is read-only into read-write mode, make sure to do a full backup

We will datafile 6 offline. Open the database again.

Sql> ALTER DATABASE datafile 6 offline;database altered. rman> ALTER DATABASE open Resetlogs;database openedrman>

Although we are using Resetlogs to open the database, but when the database recovery, but also the use of online logs. Then the data should not be lost. Let's do a test.

Sql> Conn Scott/tigerconnected.sql> Select COUNT (*) from emp_new; COUNT (*)----------180224sql>


But if we think about it carefully, there is a problem. I lost only control files and should not really go back to my database. If it is a manually managed backup recovery, simply execute the following statement to complete the recovery

sql> Recover database using Backup controlfile;

The recovery will be much faster. Why does Rman not provide similar functionality?


This article is from the "Ding Dong" blog, please be sure to keep this source http://lqding.blog.51cto.com/9123978/1680701

Oracle Learning Rman (12) Resumes combat-control file loss

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.