Oracle RMAN完全恢复案例(一)

案例1:数据库大部分datafile丢失(recover database,必须在mount下)



1)测试环境


07:21:12 SQL> conn scott/tiger


Connected.


07:21:16 SQL>


07:21:16 SQL> select * from tab;


TNAME                          TABTYPE  CLUSTERID


------------------------------ ------- ----------


DEPT                           TABLE


EMP                            TABLE


BONUS                          TABLE


SALGRADE                       TABLE


SYS_TEMP_FBT                   TABLE


TEST                           TABLE


EMP1                           TABLE


7 rows selected.


07:21:20 SQL> select * from test;


EMPNO ENAME      JOB              MGR HIREDATE         SAL       COMM     DEPTNO


---------- ---------- --------- ---------- --------- ---------- ---------- ----------


7369 SMITH      CLERK           7902 17-DEC-80        800                    20


7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30


7369 SMITH      CLERK           7902 17-DEC-80        800                    20


7499 ALLEN      SALESMAN        7698 20-FEB-81       1600        300         30


7521 WARD       SALESMAN        7698 22-FEB-81       1250        500         30


7566 JONES      MANAGER         7839 02-APR-81       2975                    20


7654 MARTIN     SALESMAN        7698 28-SEP-81       1250       1400         30


7698 BLAKE      MANAGER         7839 01-MAY-81       2850                    30


7782 CLARK      MANAGER         7839 09-JUN-81       2450                    10


7788 SCOTT      ANALYST         7566 19-APR-87       3000                    20


7839 KING       PRESIDENT            17-NOV-81       5000                    10


7844 TURNER     SALESMAN        7698 08-SEP-81       1500          0         30


7876 ADAMS      CLERK           7788 23-MAY-87       1100                    20


7900 JAMES      CLERK           7698 03-DEC-81        950                    30


7902 FORD       ANALYST         7566 03-DEC-81       3000                    20


7934 MILLER     CLERK           7782 23-JAN-82       1300                    10


16 rows selected.


07:21:27 SQL> insert into test select * from test;


16 rows created.


07:21:43 SQL> commit;


Commit complete.


07:21:45 SQL> select count(*) from test;


COUNT(*)


----------


32


07:21:50 SQL> conn /as sysdba


Connected.


07:21:56 SQL>


07:22:03 SQL> select * from v$log;


GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS           FIRST_CHANGE# FIRST_TIM


---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ---------


1          1          8   52428800          1 NO  CURRENT                1321561 18-AUG-11


2          1          7   52428800          1 YES INACTIVE               1321559 18-AUG-11


3          1          6   52428800          1 YES INACTIVE               1316062 18-AUG-11


07:22:09 SQL> alter system switch logfile;


System altered.


07:22:15 SQL>


07:22:15 SQL> shutdown abort


ORACLE instance shut down.


07:23:03 SQL> !


[oracle@work ~]$ rm /u01/app/oracle/oradata/prod/*.dbf



2)启动database


[oracle@work ~]$ !sql


sqlplus / as sysdba


SQL*Plus: Release 10.2.0.1.0 - Production on Thu Aug 18 07:23:17 2011


Copyright (c) 1982, 2005, Oracle.  All rights reserved.


Connected to an idle instance.


07:23:17 SQL>


07:23:17 SQL> startup


ORACLE instance started.


Total System Global Area  314572800 bytes


Fixed Size                  1219184 bytes


Variable Size              79693200 bytes


Database Buffers          230686720 bytes


Redo Buffers                2973696 bytes


Database mounted.


ORA-01157: cannot identify/lock data file 1 - see DBWR trace file


ORA-01110: data file 1: '/u01/app/oracle/oradata/prod/system01.dbf'


07:23:25 SQL> select file#,error from v$recover_file;


FILE# ERROR


---------- -----------------------------------------------------------------


1 FILE NOT FOUND


2 FILE NOT FOUND


3 FILE NOT FOUND


4 FILE NOT FOUND


5 FILE NOT FOUND


6 FILE NOT FOUND


7 FILE NOT FOUND


8 FILE NOT FOUND


9 FILE NOT FOUND


9 rows selected.


07:23:38 SQL>




3)利用rman 恢复database


[oracle@work ~]$ rman target /


Recovery Manager: Release 10.2.0.1.0 - Production on Thu Aug 18 07:24:09 2011


Copyright (c) 1982, 2005, Oracle.  All rights reserved.


connected to target database: PROD (DBID=170319990, not open)


RMAN> run {


2> startup force mount;


3> allocate channel c1 type disk;


4> allocate channel c2 type disk;


5> restore database;


6> recover database;


7> alter database open;


8> }


Oracle instance started


database mounted


Total System Global Area     314572800 bytes


Fixed Size                     1219184 bytes


Variable Size                 79693200 bytes


Database Buffers             230686720 bytes


Redo Buffers                   2973696 bytes


using target database control file instead of recovery catalog


allocated channel: c1


channel c1: sid=157 devtype=DISK


allocated channel: c2


channel c2: sid=154 devtype=DISK


Starting restore at 18-AUG-11


channel c1: starting datafile backupset restore


channel c1: specifying datafile(s) to restore from backup set


restoring datafile 00001 to /u01/app/oracle/oradata/prod/system01.dbf


restoring datafile 00002 to /u01/app/oracle/oradata/prod/users01.dbf


restoring datafile 00003 to /u01/app/oracle/oradata/prod/sysaux01.dbf


restoring datafile 00004 to /u01/app/oracle/oradata/prod/index01.dbf


restoring datafile 00005 to /u01/app/oracle/oradata/prod/example01.dbf


restoring datafile 00006 to /u01/app/oracle/oradata/prod/test01.dbf


restoring datafile 00007 to /u01/app/oracle/oradata/prod/undo_tbs01.dbf


restoring datafile 00008 to /u01/app/oracle/oradata/prod/test02.dbf


restoring datafile 00009 to /u01/app/oracle/oradata/prod/cuug01.dbf


channel c1: reading from backup piece /disk1/rman/prod/PROD_31.bak


channel c1: restored backup piece 1


piece handle=/disk1/rman/prod/PROD_31.bak tag=TAG20110818T071905


channel c1: restore complete, elapsed time: 00:00:57


Finished restore at 18-AUG-11


Starting recover at 18-AUG-11


starting media recovery


media recovery complete, elapsed time: 00:00:03


Finished recover at 18-AUG-11


database opened


released channel: c1


released channel: c2


RMAN>


告警日志信息:


Full restore complete of datafile 6 /u01/app/oracle/oradata/prod/test01.dbf.  Elapsed time: 0:00:01


checkpoint is 1321672


Full restore complete of datafile 8 /u01/app/oracle/oradata/prod/test02.dbf.  Elapsed time: 0:00:02


checkpoint is 1321672


Full restore complete of datafile 9 /u01/app/oracle/oradata/prod/cuug01.dbf.  Elapsed time: 0:00:01


checkpoint is 1321672


Thu Aug 18 07:25:40 2011


Full restore complete of datafile 2 /u01/app/oracle/oradata/prod/users01.dbf.  Elapsed time: 0:00:16


checkpoint is 1321672


Full restore complete of datafile 4 /u01/app/oracle/oradata/prod/index01.dbf.  Elapsed time: 0:00:18


checkpoint is 1321672


Full restore complete of datafile 5 /u01/app/oracle/oradata/prod/example01.dbf.  Elapsed time: 0:00:20


checkpoint is 1321672


Full restore complete of datafile 7 /u01/app/oracle/oradata/prod/undo_tbs01.dbf.  Elapsed time: 0:00:21


checkpoint is 1321672


Thu Aug 18 07:26:00 2011


Full restore complete of datafile 3 /u01/app/oracle/oradata/prod/sysaux01.dbf.  Elapsed time: 0:00:35


checkpoint is 1321672


Thu Aug 18 07:26:12 2011


Full restore complete of datafile 1 /u01/app/oracle/oradata/prod/system01.dbf.  Elapsed time: 0:00:47


checkpoint is 1321672


Thu Aug 18 07:26:20 2011


alter database recover datafile list clear


Thu Aug 18 07:26:20 2011


Completed: alter database recover datafile list clear


Thu Aug 18 07:26:21 2011


alter database recover datafile list


1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9


Completed: alter database recover datafile list


1 , 2 , 3 , 4 , 5 , 6 , 7 , 8 , 9


Thu Aug 18 07:26:21 2011


alter database recover if needed


start


Media Recovery Start


Thu Aug 18 07:26:21 2011


Recovery of Online Redo Log: Thread 1 Group 1 Seq 8 Reading mem 0


Mem# 0 errs 0: /u01/app/oracle/oradata/prod/redo01.log


Thu Aug 18 07:26:22 2011


Recovery of Online Redo Log: Thread 1 Group 3 Seq 9 Reading mem 0


Mem# 0 errs 0: /u01/app/oracle/oradata/prod/redo03.log


Thu Aug 18 07:26:22 2011


Media Recovery Complete (prod)



4)验证:


07:28:10 SQL> select count(*) from scott.test;


COUNT(*)


----------


32



oracle视频教程请关注:http://u.youku.com/user_video/id_UMzAzMjkxMjE2.html

你可能感兴趣的:(oracle,oracle,oracle,rman,RMAN完全恢复)