oracle10g数据库恢复(异地恢复)

丢失所有的数据文件、参数文件、控制文件、密码文件

打开控制文件与参数文件的自动备份
RMAN>CONFIGURE CONTROLFILE AUTOBACKUP ON;

做一个RMAN完全备份
RMAN>backup database format'/u01/rback/rm_22 _%U' plus archivelog delete input;

切换日志文件
SQL>alter system switch logfile;


关闭数据库
SQL> shutdown immediate;

***********
【模拟丢失所有文件】
删除所有文件
cd /u01/oracle/oradata/orcl
$rm -f *

删除所有参数文件
cd $ORACLE_HOME/dbs
$ rm -f spfileorcl.ora
$rm -f pfileorcl.ora
删除密码文件
$ rm -f orapworcl
**************

1.找任意一个参数文件启动数据库
$ /u01/oracle/admin/orcl/pfile


2.启动到mount状态前设置一下环境变量
$ export ORACLE_SID=orcl

3.启动到nomount【注意用init.ora启动】
SQL> startup nomount pfile='/u01/oracle/admin/orcl/pfile/init.ora';

4.还原参数文件。
RMAN> restore spfile from autobackup;


Starting restore at 20-MAR-14
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
recovery area destination: /u01/oracle/flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/oracle/flash_recovery_area/ORCL/autobackup/2014_03_20/o1_mf_s_842721192_9lod9bdd_.bkp
channel ORA_DISK_1: SPFILE restore from autobackup complete
Finished restore at 20-MAR-14


5.重启数据库【用恢复的参数文件启动数据库】
RMAN> shutdown immediate;

RMAN> startup nomount;

6.恢复控制文件
RMAN> restore controlfile from autobackup;


Starting restore at 20-MAR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
recovery area destination: /u01/oracle/flash_recovery_area
database name (or database unique name) used for search: ORCL
channel ORA_DISK_1: autobackup found in the recovery area
channel ORA_DISK_1: autobackup found: /u01/oracle/flash_recovery_area/ORCL/autobackup/2014_03_20/o1_mf_s_842721192_9lod9bdd_.bkp
channel ORA_DISK_1: control file restore from autobackup complete
output filename=/u01/oracle/oradata/orcl/control01.ctl
output filename=/u01/oracle/oradata/orcl/control02.ctl
output filename=/u01/oracle/oradata/orcl/control03.ctl
Finished restore at 20-MAR-14


7.启动到mount状态
RMAN> alter database mount;



8.还原数据库
RMAN> restore database;


Starting restore at 20-MAR-14
Starting implicit crosscheck backup at 20-MAR-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 3 objects
Finished implicit crosscheck backup at 20-MAR-14
Starting implicit crosscheck copy at 20-MAR-14
using channel ORA_DISK_1
Finished implicit crosscheck copy at 20-MAR-14
searching for all files in the recovery area
cataloging files...
cataloging done
List of Cataloged Files
=======================
File Name: /u01/oracle/flash_recovery_area/ORCL/autobackup/2014_03_20/o1_mf_s_842721192_9lod9bdd_.bkp
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backupset restore
channel ORA_DISK_1: specifying datafile(s) to restore from backup set
restoring datafile 00001 to /u01/oracle/oradata/orcl/system01.dbf
restoring datafile 00002 to /u01/oracle/oradata/orcl/undotbs01.dbf
restoring datafile 00003 to /u01/oracle/oradata/orcl/sysaux01.dbf
restoring datafile 00004 to /u01/oracle/oradata/orcl/users01.dbf
channel ORA_DISK_1: reading from backup piece /u01/rmbak/rm_22_03p3lprb_1_1
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/rmbak/rm_22_03p3lprb_1_1 tag=TAG20140320T171211
channel ORA_DISK_1: restore complete, elapsed time: 00:01:05
Finished restore at 20-MAR-14



9.恢复数据库
RMAN> recover database;


Starting recover at 20-MAR-14
using channel ORA_DISK_1
starting media recovery
channel ORA_DISK_1: starting archive log restore to default destination
channel ORA_DISK_1: restoring archive log
archive log thread=1 sequence=8
channel ORA_DISK_1: reading from backup piece /u01/oracle/flash_recovery_area/ORCL/backupset/2014_03_20/o1_mf_annnn_TAG20140320T171310_9lod97wc_.bkp
channel ORA_DISK_1: restored backup piece 1
piece handle=/u01/oracle/flash_recovery_area/ORCL/backupset/2014_03_20/o1_mf_annnn_TAG20140320T171310_9lod97wc_.bkp tag=TAG20140320T171310
channel ORA_DISK_1: restore complete, elapsed time: 00:00:01
archive log filename=/u01/arch/1_8_842690420.dbf thread=1 sequence=8
archive log filename=/u01/arch/1_9_842690420.dbf thread=1 sequence=9
archive log filename=/u01/arch/1_9_842690420.dbf thread=1 sequence=10
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of recover command at 03/20/2014 17:34:53
RMAN-11003: failure during parse/execution of SQL statement: alter database recover logfile '/u01/arch/1_9_842690420.dbf'
ORA-00310: archived log contains sequence 9; sequence 10 required
ORA-00334: archived log: '/u01/arch/1_9_842690420.dbf'
【这个错误可以不用考虑


10.以resetlogs方式打开数据库
RMAN> alter database open resetlogs;

11.添加临时表空间
SQL>alter tablespace temp add tempfile'/u01/oracle/oradata/orcl/temp01.dbf'size 10m;


创建密码文件
$ orapwd file=$ORACLE_HOME/dbs/orapworcl password=oracle force=y
【force=y要是以前有的话就替换掉】

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/29509120/viewspace-1147913/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/29509120/viewspace-1147913/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值