rman恢复system表空间

来源:互联网 发布:证券交易网络 编辑:程序博客网 时间:2024/05/17 21:48
本文描述:模拟恢复system表空间丢失并恢复的过程
试验如下:
(1)连接sqlplus,并创建一张表
C:\Users\Administrator>sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on 星期二 6月 13 16:12:50 2017Copyright (c) 1982, 2010, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> create table temp as select * from scott.emp;Table created.
(2)使用rman对数据看进行全备或者0级备份(代码为后来补充)
C:\Users\Administrator>rman target /Recovery Manager: Release 11.2.0.1.0 - Production on 星期四 6月 15 13:57:50 2017Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.connected to target database: ORCL (DBID=1468451227)RMAN> backup database format 'g:\rmanbp\f%d%T%s.bak'; --全备如要备份日志文件则加上plus archivelogStarting backup at 15-6月 -17using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=11 device type=DISKchannel ORA_DISK_1: starting full datafile backup setchannel ORA_DISK_1: specifying datafile(s) in backup setinput datafile file number=00009 name=F:\ORADATA\MATCH_INDEX01.DBFinput datafile file number=00008 name=F:\ORADATA\MATCH_DATA01.DBFinput datafile file number=00006 name=F:\ORADATA\BASE_DATA01.DBFinput datafile file number=00007 name=F:\ORADATA\BASE_INDEX01.DBFinput datafile file number=00010 name=F:\ORADATA\MATCHDETAIL_DATA01.DBFinput datafile file number=00011 name=F:\ORADATA\MATCHDETAIL_INDEX01.DBFinput datafile file number=00001 name=F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBFinput datafile file number=00002 name=F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSAUX01.DBFinput datafile file number=00003 name=F:\APP\ADMINISTRATOR\ORADATA\ORCL\UNDOTBS01.DBFinput datafile file number=00005 name=F:\APP\ADMINISTRATOR\ORADATA\ORCL\EXAMPLE01.DBFinput datafile file number=00004 name=F:\APP\ADMINISTRATOR\ORADATA\ORCL\USERS01.DBFchannel ORA_DISK_1: starting piece 1 at 15-6月 -17channel ORA_DISK_1: finished piece 1 at 15-6月 -17piece handle=G:\RMANBP\FORCL2017061520.BAK tag=TAG20170615T135940 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:03:56channel 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 15-6月 -17channel ORA_DISK_1: finished piece 1 at 15-6月 -17piece handle=G:\RMANBP\FORCL2017061521.BAK tag=TAG20170615T135940 comment=NONEchannel ORA_DISK_1: backup set complete, elapsed time: 00:00:01Finished backup at 15-6月 -17RMAN>
(3)删除system01.dbf(由于使用的是Win7,删除文件用360粉碎机),查看表temp报错如下
SQL> select * from temp;select * from temp              *ERROR at line 1:ORA-01115: 从文件  读取块时出现 IO 错误 (块 # )ORA-01110: 数据文件 1: 'F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBF'ORA-27070: 异步读取/写入失败OSD-04006: ReadFile() failure, unable to read from fileO/S-Error: (OS 6) 句柄无效。SQL> show user;    --这一步要有,不然rman登录报错(或者)USER is "SYS"SQL>
(4)登录rman进行恢复
C:\Users\Administrator>rman target /Recovery Manager: Release 11.2.0.1.0 - Production on 星期三 6月 14 09:40:57 2017Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.connected to target database (not started)RMAN> startup mountOracle instance starteddatabase mountedTotal System Global Area     430075904 bytesFixed Size                     2176448 bytesVariable Size                322964032 bytesDatabase Buffers              96468992 bytesRedo Buffers                   8466432 bytesRMAN> run{2> restore datafile 1;3> recover datafile 1;4> sql 'alter database open';5> }Starting restore at 14-6月 -17using target database control file instead of recovery catalogallocated channel: ORA_DISK_1channel ORA_DISK_1: SID=63 device type=DISKchannel 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 F:\APP\ADMINISTRATOR\ORADATA\ORCL\SYSTEM01.DBFchannel ORA_DISK_1: reading from backup piece G:\RMANBP\FDB_ORCL_20170613_14.BAKchannel ORA_DISK_1: piece handle=G:\RMANBP\FDB_ORCL_20170613_14.BAK tag=TAG20170613T123834channel ORA_DISK_1: restored backup piece 1channel ORA_DISK_1: restore complete, elapsed time: 00:00:45Finished restore at 14-6月 -17Starting recover at 14-6月 -17using channel ORA_DISK_1starting media recoveryarchived log for thread 1 with sequence 74 is already on disk as file F:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2017_06_13\O1_MF_1_74_DMYVCR6Q_.ARCarchived log for thread 1 with sequence 75 is already on disk as file F:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2017_06_13\O1_MF_1_75_DMYVTGMD_.ARCarchived log for thread 1 with sequence 76 is already on disk as file F:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2017_06_13\O1_MF_1_76_DMZ8PWJ1_.ARCarchived log file name=F:\APP\ADMINISTRATOR\FLASH_RECOVERY_AREA\ORCL\ARCHIVELOG\2017_06_13\O1_MF_1_74_DMYVCR6Q_.ARC thread=1 sequence=74media recovery complete, elapsed time: 00:00:03Finished recover at 14-6月 -17sql statement: alter database openRMAN>
(5)登录sqlplus查看结果
C:\Users\Administrator>sqlplus / as sysdbaSQL*Plus: Release 11.2.0.1.0 Production on 星期三 6月 14 09:46:37 2017Copyright (c) 1982, 2010, Oracle.  All rights reserved.Connected to:Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit ProductionWith the Partitioning, OLAP, Data Mining and Real Application Testing optionsSQL> select * from temp where rownum=1;     EMPNO ENAME      JOB              MGR HIREDATE              SAL       COMM---------- ---------- --------- ---------- -------------- ---------- ----------    DEPTNO----------      7369 SMITH      CLERK           7902 17-12月-80            800        20SQL>
恢复成功!
原创粉丝点击