oracle之rman恢复spfile练习

来源:互联网 发布:php进销存源码erp 编辑:程序博客网 时间:2024/05/01 18:33

今天开始学习rman恢复技术,今天初入门,先学习spfile丢失后的恢复操作,分为两部分:1、环境搭建以及前提准备;2、恢复操作过程

一、环境准备

先对数据库进行全备份

1、  连接数据库

[oracle@rac3 ~]$ rman target /

 

Recovery Manager: Release 10.2.0.1.0 - Production on Sun Jun 3006:29:22 2013

 

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

                           

connected to target database: ORCL(DBID=1347045716)

此处要将DBID记录下来,因为后面的恢复需要用到。

2、  对数据库进行全备份包括归档日志

 RMAN> backup database plus archivelogdelete input;

3、  查看备份后备份片的位置

 RMAN> list backup;

 

 

List of BackupSets

===================

 

BS Key  Size      Device Type Elapsed Time Completion Time

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

6       121.91M    DISK       00:00:09     30-JUN-13     

        BP Key: 6   Status: AVAILABLE  Compressed: NO  Tag: TAG20130630T063920

        Piece Name:/opt/oracle/flash_recovery_area/ORCL/backupset/2013_06_30/o1_mf_annnn_TAG20130630T063920_8wyrjstl_.bkp

 

  List of Archived Logs in backup set 6

  Thrd Seq    Low SCN    Low Time  Next SCN  Next Time

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

  1   5       513406     29-JUN-13 537794     30-JUN-13

  1   6       537794     30-JUN-13 538554     30-JUN-13

  1   7       538554     30-JUN-13 538768     30-JUN-13

  1   8       538768     30-JUN-13 540931     30-JUN-13

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

7       Full   615.30M    DISK        00:00:50     30-JUN-13     

        BP Key: 7   Status: AVAILABLE  Compressed: NO  Tag: TAG20130630T063937

        Piece Name:/opt/oracle/flash_recovery_area/ORCL/backupset/2013_06_30/o1_mf_nnndf_TAG20130630T063937_8wyrk9os_.bkp

  List of Datafiles in backup set 7

  File LV Type Ckp SCN    Ckp Time Name

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

  1      Full 540941     30-JUN-13/opt/oracle/oradata/orcl/system01.dbf

  2      Full 540941     30-JUN-13/opt/oracle/oradata/orcl/undotbs01.dbf

  3      Full 540941     30-JUN-13/opt/oracle/oradata/orcl/sysaux01.dbf

  4      Full 540941     30-JUN-13/opt/oracle/oradata/orcl/users01.dbf

  5      Full 540941     30-JUN-13/opt/oracle/oradata/orcl/rhf.dbf

 

BS Key  Size       Device Type Elapsed Time Completion Time

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

8       3.00K      DISK        00:00:01     30-JUN-13     

        BP Key: 8   Status: AVAILABLE  Compressed: NO  Tag: TAG20130630T064032

        Piece Name:/opt/oracle/flash_recovery_area/ORCL/backupset/2013_06_30/o1_mf_annnn_TAG20130630T064032_8wyrm218_.bkp

 

  List of Archived Logs in backup set 8

  Thrd Seq    Low SCN    Low Time  Next SCN  Next Time

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

  1   9       540931     30-JUN-13 540961     30-JUN-13

 

BS Key  Type LV Size       Device Type Elapsed Time Completion Time

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

9      Full    6.80M     DISK        00:00:01     30-JUN-13     

       BP Key: 9   Status: AVAILABLE  Compressed: NO  Tag: TAG20130630T064035

       Piece Name:/opt/backup/c-1347045716-20130630-00

 Control FileIncluded: Ckp SCN: 540967       Ckp time:30-JUN-13

 SPFILE Included:Modification time: 30-JUN-13

从此处可看到spfile的备份文件路径。

4、  获取到spfile文件路径,并将spfile文件移走

 [oracle@rac3 ~]$ sqlplus '/ as sysdba'

 SQL> show parameter spfile

 

NAME   TYPE    VALUE

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

Spfile   string    /opt/oracle/product/10.2.0/db_1/dbs/spfileorcl.ora                                                 

 [oracle@rac3 dbs]$ mv spfileorcl.oraspfileorcl.ora.bak

          [oracle@rac3 dbs]$ ls

hc_orcl.dat initdw.ora  init.ora  lkORCL orapworcl  snapcf_orcl.f  spfileorcl.ora.bak

 

二、恢复

1、  关闭数据库

RMAN>shutdown immediate;

database closed

databasedismounted

Oracle instanceshut down

2、  将数据库启动到nomount状态

RMAN> startupnomount;

 

connected totarget database (not started)

startup failed:ORA-01078: failure in processing system parameters

LRM-00109: couldnot open parameter file '/opt/oracle/product/10.2.0/db_1/dbs/initorcl.ora'

 

starting Oracleinstance without parameter file for retrival of spfile

Oracle instancestarted

 

Total SystemGlobal Area     159383552 bytes

 

Fixed Size                     1218268 bytes

VariableSize                 54528292 bytes

DatabaseBuffers             100663296 bytes

RedoBuffers                   2973696 bytes

3、  设置dbid

RMAN> setdbid 1347045716;

executingcommand: SET DBID

4RMAN>restore spfile from '/opt/backup/c-1347045716-20130630-00';

 

Starting restoreat 30-JUN-13

allocatedchannel: ORA_DISK_1

channelORA_DISK_1: sid=36 devtype=DISK

 

channelORA_DISK_1: autobackup found: /opt/backup/c-1347045716-20130630-00

channel ORA_DISK_1:SPFILE restore from autobackup complete

Finished restoreat 30-JUN-13

4、  spfile文件所在位置查看spfile文件是否已经回复出现

[oracle@rac3dbs]$ ls

hc_orcl.dat  init.ora orapworcl     spfileorcl.ora

initdw.ora   lkORCL   snapcf_orcl.f spfileorcl.ora.bak

5、  重新启动数据库

RMAN>shutdown immediate;

 

Oracle instanceshut down

 

RMAN> startup

 

connected totarget database (not started)

Oracle instancestarted

database mounted

database opened

 

Total SystemGlobal Area     218103808 bytes

 

Fixed Size                     1218604 bytes

VariableSize                 62916564 bytes

DatabaseBuffers             150994944 bytes

RedoBuffers                   2973696 bytes

原创粉丝点击