RMAN恢复完全恢复之部分数据文件丢失

SQL> conn scott/scott;
Connected.
SQL> select * from tab;
TNAME       TABTYPE CLUSTERID
------------------------------ ------- ----------
BONUS       TABLE
DEPT       TABLE
EMP       TABLE
SALGRADE       TABLE
SQL> create table emp1 as select * from emp;
Table created.
SQL> commit;
Commit complete.
SQL> insert into emp1 select * from emp1;
14 rows created.
SQL> select count(*) from emp1;
  COUNT(*)
----------
28
SQL> conn / as sysdba    
Connected.
SQL> set line 9999 pages 9999;
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1       4   52428800   512 1 YES INACTIVE     1116377 28-FEB-17    1138231 28-FEB-17
2    1       5   52428800   512 1 YES ACTIVE     1138231 28-FEB-17    1176125 28-FEB-17
3    1       6   52428800   512 1 NO  CURRENT     1176125 28-FEB-17 2.8147E+14
SQL> conn scott/scott;
Connected.
SQL> commit;
Commit complete.
SQL> conn / as sysdba
Connected.
SQL> alter system switch logfile;
System altered.
SQL> select * from v$log;
    GROUP#    THREAD#  SEQUENCE#      BYTES  BLOCKSIZE  MEMBERS ARC STATUS       FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1    1       7   52428800   512 1 NO  CURRENT     1176322 28-FEB-17 2.8147E+14
2    1       5   52428800   512 1 YES INACTIVE     1138231 28-FEB-17    1176125 28-FEB-17
3    1       6   52428800   512 1 YES ACTIVE     1176125 28-FEB-17    1176322 28-FEB-17
SQL> shutdown abort;
ORACLE instance shut down.
SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
[oracle@node1 ~]$ cd /u01/app/oracle/oradata/
[oracle@node1 oradata]$ ls
DB11G
[oracle@node1 oradata]$ cd DB11G/
[oracle@node1 DB11G]$ ls
control01.ctl      control02.ctl      example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf
control01.ctl.bak  control02.ctl.bak  redo01.log     redo03.log  system01.dbf  undotbs01.dbf  users01.dbf.bak
[oracle@node1 DB11G]$ rm -rf users01.dbf
[oracle@node1 DB11G]$ sqlplus / as sysdba
SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 28 15:20:10 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to an idle instance.
SQL> startup;
ORACLE instance started.
Total System Global Area  409194496 bytes
Fixed Size    2253744 bytes
Variable Size  322964560 bytes
Database Buffers   79691776 bytes
Redo Buffers    4284416 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 4 - see DBWR trace file
ORA-01110: data file 4: '/u01/app/oracle/oradata/DB11G/users01.dbf'
SQL> set time on;
15:20:58 SQL> alter database datafile 4 offline;
Database altered.
15:21:38 SQL> alter database open;
Database altered.
15:22:38 SQL> select file#,error from v$recover_file;
    FILE# ERROR
---------- -----------------------------------------------------------------
4 FILE NOT FOUND
15:22:57 SQL> !
[oracle@node1 DB11G]$ rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Tue Feb 28 15:23:44 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: DB11G (DBID=406755073)
RMAN> restore datafile 4;
Starting restore at 28-FEB-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=37 device type=DISK
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
channel ORA_DISK_1: restoring datafile 00004 to /u01/app/oracle/oradata/DB11G/users01.dbf
channel ORA_DISK_1: reading from backup piece /u02/backup/full_0urtm77a_1_1
channel ORA_DISK_1: piece handle=/u02/backup/full_0urtm77a_1_1 tag=TAG20170228T032425
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
Finished restore at 28-FEB-17
RMAN> recover datafile 4;
Starting recover at 28-FEB-17
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 2 is already on disk as file /u02/archivelog/1_2_937106515.dbf
archived log for thread 1 with sequence 3 is already on disk as file /u02/archivelog/1_3_937106515.dbf
archived log for thread 1 with sequence 4 is already on disk as file /u02/archivelog/1_4_937106515.dbf
archived log for thread 1 with sequence 5 is already on disk as file /u02/archivelog/1_5_937106515.dbf
archived log for thread 1 with sequence 6 is already on disk as file /u02/archivelog/1_6_937106515.dbf
archived log for thread 1 with sequence 7 is already on disk as file /u02/archivelog/1_7_937106515.dbf
archived log file name=/u02/archivelog/1_2_937106515.dbf thread=1 sequence=2
archived log file name=/u02/archivelog/1_3_937106515.dbf thread=1 sequence=3
archived log file name=/u02/archivelog/1_4_937106515.dbf thread=1 sequence=4
archived log file name=/u02/archivelog/1_5_937106515.dbf thread=1 sequence=5
media recovery complete, elapsed time: 00:00:01
Finished recover at 28-FEB-17
RMAN> sql "alter database datafile 4 online";
sql statement: alter database datafile 4 online
RMAN> exit
Recovery Manager complete.
[oracle@node1 DB11G]$ sqlplus scott/scott
SQL*Plus: Release 11.2.0.4.0 Production on Tue Feb 28 15:24:47 2017
Copyright (c) 1982, 2013, Oracle.  All rights reserved.
Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.4.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select count(*) from emp1;
  COUNT(*)
----------
28

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值