步骤1:备份数据库
run
{
shutdown immediate;
startup mount; #noarchive mode,must be mount
allocate channel c1 type disk;
allocate channel c2 type disk;
backup database format '/u01/rman_backup/2011/201112/20111201/df_%t_%s_%p.bak';
release channel c1;
release channel c2;
alter database open;
}
步骤2:停止数据库
SQL> connect / as sysdba
Connected.
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> exit
步骤3.删除数据文件
[oracle@rac1 oracl]$ rm hxl01.dbf
步骤3:试着启动数据库(这个时候因为数据文件hxl01.dbf删除了,所以无法启动)
[oracle@rac1 oracl]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 1 12:55:56 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect / as sysdba
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 524288000 bytes
Fixed Size 1220360 bytes
Variable Size 163578104 bytes
Database Buffers 356515840 bytes
Redo Buffers 2973696 bytes
Database mounted.
ORA-01157: cannot identify/lock data file 5 - see DBWR trace file
ORA-01110: data file 5: '/u01/app/oracle/oradata/oracl/hxl01.dbf'
步骤4:恢复
run
{
shutdown immediate;
startup mount; #noarchive mode,must be mount
allocate channel c1 type disk;
allocate channel c2 type disk;
restore database;
recover database;
release channel c1;
release channel c2;
alter database open;
}
步骤5:检查是否恢复
[oracle@rac1 myscript]$ sqlplus /nolog
SQL*Plus: Release 10.2.0.1.0 - Production on Thu Dec 1 13:07:50 2011
Copyright (c) 1982, 2005, Oracle. All rights reserved.
SQL> connect / as sysdba
Connected.
SQL> select * from dual;
D
-
X
至此,数据库完成恢复.
总结:数据库在非归档模式下,备份和恢复操作都必须在mount状态下执行.
阅读(3410) | 评论(0) | 转发(0) |