ORACLE数据库不完全恢复

版权声明:本文为博主原创文章,未经博主允许不得转载。 https://blog.csdn.net/weixin_39945369/article/details/78031287
备份数据库、参数文件、控制文件。
1.备份参数文件:
RMAN> backup spfile format '/backup/spfile%U';
2.备份控制文件:
RMAN> backup current controlfile format '/backup/control%U.bak';
3.备份数据库:
RMAN> backup database ;
=========================================
数据库的不完全恢复

备份参数文件、控制文件、数据库、没有备份归档和数据文件,是不能进行完全恢复的,在启动到

mount阶段的时候,会提示找不到数据文件

RMAN> restore database;

Starting restore at 08-MAR-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=18 device type=DISK

RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of restore command at 03/08/2017 09:24:03
RMAN-06026: some targets not found - aborting restore
RMAN-06023: no backup or copy of datafile 5 found to restore
RMAN-06023: no backup or copy of datafile 4 found to restore
RMAN-06023: no backup or copy of datafile 3 found to restore
RMAN-06023: no backup or copy of datafile 2 found to restore
RMAN-06023: no backup or copy of datafile 1 found to restore

当报这种error的时候,需要用catalog start with指定数据文件路径。让备份片注册进这个地址,意思是在恢复的时候它可以通过这个地址找到数据文件 格式
catalog start with ‘/backup/';

然后就可以restore database或者是restore datafile 1这样一个一个的找。
============================================

1、确认存在数据库所需的所有备份片
[oracle@db11g rmanfull]$  ll
total 894752
-rw-r----- 1 oracle oinstall 248374272 Jul 24 15:31 arch_full2015072417qcrvcq_1_1
-rw-r----- 1 oracle oinstall 229207552 Jul 24 15:31 arch_full2015072418qcrvcq_1_1
-rw-r----- 1 oracle oinstall      4608 Jul 24 15:31 arch_full2015072419qcrvf5_1_1
-rw-r----- 1 oracle oinstall 118882304 Jul 24 15:32 ctl_DB11G_20150724_885915149.bak
-rw-r----- 1 oracle oinstall 207273984 Jul 24 15:29 full13qcrv7d_1_120150724
-rw-r----- 1 oracle oinstall 110247936 Jul 24 15:29 full14qcrv7d_1_120150724
-rw-r----- 1 oracle oinstall   1196032 Jul 24 15:30 full15qcrvbb_1_120150724
-rw-r----- 1 oracle oinstall     98304 Jul 24 15:32 spfile_DB11G_20150724_43_1.bak
[oracle@db11g rmanfull]$
 
2、删除数据库的参数文件、控制文件、数据文件、 redo 日志等
[oracle@db11g rmanfull]$  rm -f  $ ORACLE_HOME/dbs/spfiledb11g.ora
[oracle@db11g db11g]$  pwd
/oradata/db11g
[oracle@db11g db11g]$  ls
control01.ctl  example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf
control02.ctl  redo01.log     redo03.log  system01.dbf  undotbs01.dbf
[oracle@db11g db11g]$  rm -f *
[oracle@db11g db11g]$
 
3、关闭数据库
[oracle@db11g ~]$  ps -ef |grep ora_
oracle    1789     1  0 16:10 ?        00:00:00 ora_pmon_db11g
oracle    1791     1  0 16:10 ?        00:00:00 ora_psp0_db11g
oracle    1793     1  0 16:10 ?        00:00:10 ora_vktm_db11g
oracle    1797     1  0 16:10 ?        00:00:00 ora_gen0_db11g
oracle    1799     1  0 16:10 ?        00:00:00 ora_diag_db11g
oracle    1801     1  0 16:10 ?        00:00:00 ora_dbrm_db11g
oracle    1803     1  0 16:10 ?        00:00:00 ora_dia0_db11g
oracle    1805     1  0 16:10 ?        00:00:00 ora_mman_db11g
oracle    1807     1  0 16:10 ?        00:00:00 ora_dbw0_db11g
oracle    1809     1  0 16:10 ?        00:00:00 ora_lgwr_db11g
oracle    1811     1  0 16:10 ?        00:00:01 ora_ckpt_db11g
oracle    1813     1  0 16:10 ?        00:00:00 ora_smon_db11g
oracle    1815     1  0 16:10 ?        00:00:00 ora_reco_db11g
oracle    1817     1  0 16:10 ?        00:00:02 ora_mmon_db11g
oracle    1819     1  0 16:10 ?        00:00:00 ora_mmnl_db11g
oracle    1821     1  0 16:10 ?        00:00:00 ora_d000_db11g
oracle    1823     1  0 16:10 ?        00:00:00 ora_s000_db11g
oracle    3573     1  0 16:16 ?        00:00:00 ora_arc0_db11g
oracle    3581     1  0 16:16 ?        00:00:00 ora_arc1_db11g
oracle    3586     1  0 16:16 ?        00:00:00 ora_arc2_db11g
oracle    3590     1  0 16:16 ?        00:00:00 ora_arc3_db11g
oracle    3592     1  0 16:16 ?        00:00:00 ora_arc4_db11g
oracle    3594     1  0 16:16 ?        00:00:00 ora_nsa2_db11g
oracle    3623     1  0 16:16 ?        00:00:00 ora_qmnc_db11g
oracle    3636     1  0 16:17 ?        00:00:01 ora_cjq0_db11g
oracle    3638     1  0 16:17 ?        00:00:00 ora_q000_db11g
oracle    3640     1  0 16:17 ?        00:00:00 ora_q001_db11g
oracle    4067     1  0 16:20 ?        00:00:00 ora_smco_db11g
oracle    4071     1  0 16:20 ?        00:00:00 ora_w000_db11g
oracle    4396     1  0 16:25 ?        00:00:00 ora_w001_db11g
oracle    4663  4489  0 16:28 pts/1    00:00:00 grep ora_
[oracle@db11g ~]$
 
root 用户杀死 pmon 进程,等一会儿数据库即可关闭
[root@db11g backup]#  kill -9 1789
[root@db11g backup]#  ps -ef|grep ora_
root      4814  3302  0 16:30 pts/1    00:00:00 grep ora_
 
4、进行数据库的不完全恢复
4.1、 rman 启动 dummy 实例,恢复参数文件
[oracle@db11g rmanfull]$  rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jul 24 16:39:56 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target  database (not started)
RMAN>  startup
startup failed: ORA-01078: failure in processing system parameters
LRM-00109: could not open parameter file '/u01/app/oracle/product/11.2.0/db_1/dbs/initdb11g.ora'
starting Oracle instance without parameter file for retrieval of spfile
Oracle instance started
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of startup command at 07/24/2015 16:40:01
ORA-00205: error in identifying control file, check alert log for more info
RMAN>
 
重新登陆 rman ,恢复参数文件
[oracle@db11g rmanfull]$  rman target /
Recovery Manager: Release 11.2.0.4.0 - Production on Fri Jul 24 16:40:35 2015
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database:  DUMMY (not mounted)
RMAN>  restore spfile from '/backup/rmanfull/spfile_DB11G_20150724_43_1.bak';
Starting restore at 24-JUL-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=172 device type=DISK
channel ORA_DISK_1: restoring spfile from AUTOBACKUP /backup/rmanfull/spfile_DB11G_20150724_43_1.bak
channel ORA_DISK_1: SPFILE restore from AUTOBACKUP complete
Finished restore at 24-JUL-15
RMAN>
 
4.2、使用恢复的参数文件启动数据库到 nomount 状态,恢复控制文件
connected to target database:  DUMMY (not mounted)
RMAN>  shutdown immediate
using target database control file instead of recovery catalog
Oracle instance shut down
RMAN>  startup nomount
connected to target database (not started)
Oracle instance started
Total System Global Area     471830528 bytes
Fixed Size                     2254344 bytes
Variable Size                197134840 bytes
Database Buffers             264241152 bytes
Redo Buffers                   8200192 bytes
RMAN>
RMAN>  restore controlfile from '/backup/rmanfull/ctl_DB11G_20150724_885915149.bak';
Starting restore at 24-JUL-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=134 device type=DISK
channel ORA_DISK_1: restoring control file
channel ORA_DISK_1: restore complete, elapsed time: 00:00:25
output file name=/oradata/db11g/control01.ctl
output file name=/oradata/db11g/control02.ctl
Finished restore at 24-JUL-15
RMAN>
 
4.3、启动数据库到 mount 状态,恢复数据文件
RMAN>  alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN>
RMAN>  restore database;
Starting restore at 24-JUL-15
allocated channel: ORA_SBT_TAPE_1
channel ORA_SBT_TAPE_1: SID=134 device type=SBT_TAPE
channel ORA_SBT_TAPE_1: Oracle Secure Backup
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=10 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 00001 to /oradata/db11g/system01.dbf
channel ORA_DISK_1: restoring datafile 00003 to /oradata/db11g/undotbs01.dbf
channel ORA_DISK_1: restoring datafile 00004 to /oradata/db11g/users01.dbf
channel ORA_DISK_1: reading from backup piece /backup/rmanfull/full13qcrv7d_1_120150724
channel ORA_DISK_1: piece handle=/backup/rmanfull/full13qcrv7d_1_120150724 tag=TAG20150724T152740
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:02:20
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 00002 to /oradata/db11g/sysaux01.dbf
channel ORA_DISK_1: restoring datafile 00005 to /oradata/db11g/example01.dbf
channel ORA_DISK_1: reading from backup piece /backup/rmanfull/full14qcrv7d_1_120150724
channel ORA_DISK_1: piece handle=/backup/rmanfull/full14qcrv7d_1_120150724 tag=TAG20150724T152740
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:01:55
Finished restore at 24-JUL-15
RMAN>
RMAN>  recover database;
Starting recover at 24-JUL-15
using channel ORA_SBT_TAPE_1
using channel ORA_DISK_1
starting media recovery
archived log for thread 1 with sequence 69 is already on disk as file /oradata/backup/1_69_840464833.dbf
archived log for thread 1 with sequence 70 is already on disk as file /oradata/backup/1_70_840464833.dbf
archived log for thread 1 with sequence 71 is already on disk as file /oradata/backup/1_71_840464833.dbf
archived log for thread 1 with sequence 72 is already on disk as file /oradata/backup/1_72_840464833.dbf
archived log file name=/oradata/backup/1_69_840464833.dbf thread=1 sequence=69
archived log file name=/oradata/backup/1_70_840464833.dbf thread=1 sequence=70
archived log file name=/oradata/backup/1_71_840464833.dbf thread=1 sequence=71
archived log file name=/oradata/backup/1_72_840464833.dbf thread=1 sequence=72
archived log file name=/oradata/backup/1_73_840464833.dbf thread=1 sequence=73
archived log file name=/oradata/backup/1_74_840464833.dbf thread=1 sequence=74
archived log file name=/oradata/backup/1_75_840464833.dbf thread=1 sequence=75
media recovery complete, elapsed time: 00:00:13
Finished recover at 24-JUL-15
RMAN>
 
5、检查恢复的数据文件是否存在
[oracle@db11g rmanfull]$  ll /oradata/db11g/*
-rw-r----- 1 oracle oinstall 118833152 Jul 24 16:50 /oradata/db11g/control01.ctl
-rw-r----- 1 oracle oinstall 118833152 Jul 24 16:50 /oradata/db11g/control02.ctl
-rw-r----- 1 oracle oinstall 346038272 Jul 24 16:49 /oradata/db11g/example01.dbf
-rw-r----- 1 oracle oinstall 618668032 Jul 24 16:49 /oradata/db11g/sysaux01.dbf
-rw-r----- 1 oracle oinstall 796925952 Jul 24 16:49 /oradata/db11g/system01.dbf
-rw-r----- 1 oracle oinstall 235937792 Jul 24 16:49 /oradata/db11g/undotbs01.dbf
-rw-r----- 1 oracle oinstall   5251072 Jul 24 16:49 /oradata/db11g/users01.dbf
[oracle@db11g rmanfull]$
 
6、打开数据库
SQL>  alter database open resetlogs;
Database altered.
SQL>
 
至此,数据库不完全恢复成功。
==================================================
noarchivelog下 的数据库恢复:
备注:已经恢复了参数文件和控制文件。
1.startup mount;
2.restore database
3.recover database noredo; #因为这个数据库在noarchivelog模式下,不应用任何归档的redo log并且丢失了redo log,座椅要加参数noredo.
4.alter database open resetlogs; #重新构建联机重做日志,必须使用resetlogs日志。


noarchivelog模式下































猜你喜欢

转载自blog.csdn.net/weixin_39945369/article/details/78031287