oracle 10g rman 备份与恢复 之四

oracle 10g rman备份与恢复
海明老师第六讲
nocatalog rman恢复
    dbid用来恢复spfile和controlfile用到
    CONFIGURE CONTROLFILE AUTOBACKUP ON;
    backup database plus archivelog delete input;
备份补充
RMAN> show all
2> ;
RMAN configuration parameters are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP ON;
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/oracle/ora10g/product/10.2.0/db_1/dbs/snapcf_wolf.f'; # default

防止controlfile丢失
CONFIGURE CONTROLFILE AUTOBACKUP ON;  启用后会自动备份controlfile和spfile
先把之前的备份全部删除
delete backupset
RMAN> delete backupset 652
2> ;
using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
658     652     1   1   AVAILABLE   DISK        /oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_21/o1_mf_s_813295785_8q75c9pw_.bkp

Do you really want to delete the above objects (enter YES or NO)? yes
deleted backup piece
backup piece handle=/oracle/ora10g/flash_recovery_area/WOLF/autobackup/2013_04_21/o1_mf_s_813295785_8q75c9pw_.bkp recid=44 stamp=813295785
Deleted 1 object
下面是我先在系统里面用rm删掉的,os里面删了之后,rman里面还会有信息,必须用crosscheck backupset,做标记,然后在删除。
RMAN> delete backupset 552
2> ;
using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
555     552     1   1   AVAILABLE   DISK        /oracle/ora10g/rmanback/inc0_1eo7jo4g_20130421

Do you really want to delete the above objects (enter YES or NO)? yes

RMAN-06207: WARNING: 1 objects could not be deleted for DISK channel(s) due
RMAN-06208:          to mismatched status.  Use CROSSCHECK command to fix status
RMAN-06210: List of Mismatched objects
RMAN-06211: ==========================
RMAN-06212:   Object Type   Filename/Handle
RMAN-06213: --------------- ---------------------------------------------------
RMAN-06214: Backup Piece    /oracle/ora10g/rmanback/inc0_1eo7jo4g_20130421

RMAN> CROSSCHECK backupset;
using channel ORA_DISK_1
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/oracle/ora10g/rmanback/full_T% recid=35 stamp=813237736
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/oracle/ora10g/rmanback/full_20130420 recid=37 stamp=813238342
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/oracle/ora10g/rmanback/inc0_1co7jn4l_20130421 recid=39 stamp=813292693
crosschecked backup piece: found to be 'EXPIRED'
backup piece handle=/oracle/ora10g/rmanback/inc0_1eo7jo4g_20130421 recid=41 stamp=813293712
Crosschecked 4 objects

RMAN> DELETE NOPROMPT EXPIRED BACKUP;

using channel ORA_DISK_1

List of Backup Pieces
BP Key  BS Key  Pc# Cp# Status      Device Type Piece Name
------- ------- --- --- ----------- ----------- ----------
398     395     1   1   EXPIRED     DISK        /oracle/ora10g/rmanback/full_T%
433     430     1   1   EXPIRED     DISK        /oracle/ora10g/rmanback/full_20130420
494     491     1   1   EXPIRED     DISK        /oracle/ora10g/rmanback/inc0_1co7jn4l_20130421
555     552     1   1   EXPIRED     DISK        /oracle/ora10g/rmanback/inc0_1eo7jo4g_20130421
deleted backup piece
backup piece handle=/oracle/ora10g/rmanback/full_T% recid=35 stamp=813237736
deleted backup piece
backup piece handle=/oracle/ora10g/rmanback/full_20130420 recid=37 stamp=813238342
deleted backup piece
backup piece handle=/oracle/ora10g/rmanback/inc0_1co7jn4l_20130421 recid=39 stamp=813292693
deleted backup piece
backup piece handle=/oracle/ora10g/rmanback/inc0_1eo7jo4g_20130421 recid=41 stamp=813293712
Deleted 4 EXPIRED objects
RMAN> list backupset;
RMAN>

------------------------------------------------------------------------------------------------
backup format ‘/oracle/ora10g/rmanback/full_%u_%T.bak' database plus archivelog;


-----------------------------------------------------------------------
恢复
1、口令文件恢复
[root@redhat dbs]# pwd
/oracle/ora10g/product/10.2.0/db_1/dbs
[root@redhat dbs]# ls
hc_wolf.dat  initdw.ora  init.ora  lkDUMMY  lkWOLF  orapwwolf  snapcf_wolf.f  spfilewolf.ora
[root@redhat dbs]#
假设口令文件丢失
重建口令文件
[oracle@redhat ~]$ cd /oracle/ora10g/product/10.2.0/db_1/dbs
[oracle@redhat dbs]$ orapwd file=orapwwolf password=123456 entries=5
[oracle@redhat dbs]$ ls
hc_wolf.dat  initdw.ora  init.ora  lkDUMMY  lkWOLF  orapwwolf  orapwwolf.bak  snapcf_wolf.f  spfilewolf.ora
[oracle@redhat dbs]$

[oracle@redhat dbs]$ orapwd
Usage: orapwd file=<fname> password=<password> entries=<users> force=<y/n>

  where
    file - name of password file (mand),
    password - password for SYS (mand),
    entries - maximum number of distinct DBA and     force - whether to overwrite existing file (opt),
OPERs (opt),
  There are no spaces around the equal-to (=) character.

2、spfile丢失(dbid=3778783462)
   startup nomount
   set dbid dbid_number
   restore spfile from autobackup
   shutdown immediate
   set dbid dbid_number
   startup
  
模拟丢失spfile
SQL> show parameter spfile

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /oracle/ora10g/product/10.2.0/
                                                 db_1/dbs/spfilewolf.ora
SQL>
      ([root@redhat db_1]# cd dbs
        [root@redhat dbs]# ls
         hc_wolf.dat  init.ora  lkWOLF     snapcf_wolf.f
         initdw.ora   lkDUMMY   orapwwolf  spfilewolf.ora
        [root@redhat dbs]# mv spfilewolf.ora spfilewolf.ora.bak
        [root@redhat dbs]# ls
         hc_wolf.dat  init.ora  lkWOLF     snapcf_wolf.f
         initdw.ora   lkDUMMY   orapwwolf  spfilewolf.ora.bak
        [root@redhat dbs]# pwd
        /oracle/ora10g/product/10.2.0/db_1/dbs
        )

RMAN>startup nomount;
RMAN>set dbid 3778783462
RMAN>restore spfile from autobackup(真实的路径也行)
RMAN>shutdown immediate
RMAN>set dbid 3778783462              (直接启动如果有问题,再设置一下dbid)
RMAN>startup

RMAN> shutdown immediate
database closed
database dismounted
Oracle instance shut down
RMAN> startup nomount
connected to target database (not started)
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/oracle/ora10g/product/10.2.0/db_1/dbs/initwolf.ora'
starting Oracle instance without parameter file for retrival of spfile
Oracle instance started
Total System Global Area     159383552 bytes
Fixed Size                     1218268 bytes
Variable Size                 54528292 bytes
Database Buffers             100663296 bytes
Redo Buffers                   2973696 bytes
RMAN> set dbid 3778783462
executing command: SET DBID
RMAN> restore spfile from autobackup;
Starting restore at 21-4月 -13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=36 devtype=DISK
channel ORA_DISK_1: looking for autobackup on day: 20130421
channel ORA_DISK_1: looking for autobackup on day: 20130420
channel ORA_DISK_1: looking for autobackup on day: 20130419
channel ORA_DISK_1: looking for autobackup on day: 20130418
channel ORA_DISK_1: looking for autobackup on day: 20130417
channel ORA_DISK_1: looking for autobackup on day: 20130416
channel ORA_DISK_1: looking for autobackup on day: 20130415
channel ORA_DISK_1: no autobackup in 7 days found
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 04/21/2013 10:02:43
RMAN-06172: no autobackup found or specified handle is not a valid copy or piece

 

RMAN>

RMAN> restore spfile from '/oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_21/o1_mf_ncsnf_TAG20130421T095042_8q7vtb8b_.bkp';

Starting restore at 21-4月 -13
using channel ORA_DISK_1

channel ORA_DISK_1: autobackup found: /oracle/ora10g/flash_recovery_area/WOLF/backupset/2013_04_21/o1_mf_ncsnf_TAG20130421T095042_8q7vtb8b_.bkp
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 21-4月 -13
      ([root@redhat dbs]# ls
         hc_wolf.dat  init.ora  lkWOLF     snapcf_wolf.f   spfilewolf.ora.bak
         initdw.ora   lkDUMMY   orapwwolf  spfilewolf.ora
         )
RMAN> shutdown immediate

Oracle instance shut down

RMAN> startup

connected to target database (not started)
Oracle instance started
database mounted
database opened

Total System Global Area     285212672 bytes

Fixed Size                     1218992 bytes
Variable Size                 92276304 bytes
Database Buffers             188743680 bytes
Redo Buffers                   2973696 bytes

RMAN>

 

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值