1.恢复密码文件
orapwd file=$ORACLE_HOME/dbs/orapwocp password=oracle force=y ignorecase=y;
--注:普通用户的密码大小写是否区分由初始参数sec_case_sensitive_logon,不归密码文件处理
2.恢复参数文件
找alert_sid.log日志
3.无备份的控制文件
*场景1:在线日志无损的情况下的重建
rm -rf control*
shutdown abort;
startup nomount;
CREATE CONTROLFILE REUSE DATABASE "BXDB" NORESETLOGS...
reocver database;
alter database open;
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/bxdb/temp01.dbf' reuse;
*场景2:在线日志损坏的情况下的重建
shutdown immediate; --注这里要正常关闭数据库,否则会要求system做恢复???
rm -rf control*
rm -rf redo*
startup nomount;
CREATE CONTROLFILE REUSE DATABASE "BXDB" RESETLOGS...
recover database until cancel using BACKUP CONTROLFILE;--RMAN>recover database until sequence 2;
alter database open resetlogs;
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/bxdb/temp01.dbf' reuse;
*场景3:具有只读数据文件情况下的重建
startup nomount;
CREATE CONTROLFILE REUSE DATABASE "BXDB" NORESETLOGS...
recover database; --recover database using backup controlfile;
alter database open; --alter database open resetlogs;
alter database rename file '/u01/app/oracle/product/11g/dbs/MISSING00005' to '/u01/app/oracle/oradata/bxdb/tp2.dbf';
alter tablespace tp12 online; --不能设数据文件在线(alter database datafile 7;)
ALTER TABLESPACE TEMP ADD TEMPFILE '/u01/app/oracle/oradata/ocp/temp01.dbf' reuse;
*场景4:使用控制文件快照恢复
cp /u01/app/oracle/product/11g/dbs/snapcf_ocp.f /u01/app/oracle/oradata/ocp/control01.ctl
cp /u01/app/oracle/product/11g/dbs/snapcf_ocp.f /u01/app/oracle/oradata/ocp/control02.ctl
cp /u01/app/oracle/product/11g/dbs/snapcf_ocp.f /u01/app/oracle/oradata/ocp/control03.ctl
startup mount;
recover database using backup controlfile; --RMAN>recover database;
alter database open resetlogs;
4.恢复数据文件
rm -rf tp5.dbf;
alter database datafile 8 offline;
alter database create datafile '/u01/app/oracle/oradata/ocp/tp12.dbf';
select * from t20; ---报错没找到文件
recover datafile 8;
alter database datafile 8 online;
5.恢复临时文件
alter tablesapce temp add tempfile '/u01/app/oracle/oradata/oca/temp02.dbf' size 20M autoextend on;
alter tablesapce temp drop tempfile '/u01/app/oracle/oradata/oca/temp01.dbf';
6.恢复在线重做日志
*场景1:每个日志组有两个在线日志成员,1号组是其中一个redo01B.log损坏了
alter database drop logfile member '/u01/app/oracle/oradata/oca/redo01B.log';
alter database add logfile member '/u01/app/oracle/oradata/oca/redo01B.log' to group 1;
*场景2:每个日志组有两个在线日志成员,1号组的所有日志(redo01A.log和redo01B.log)损坏了
alter database clear logfile group 1;
alter database clear unarchived logfile group 1;
*场景3:所有日志组全部损坏了
rm -rf redo*
shutdown immediate;
startup mount;
recover database until cancel;
alter database open resetlogs;