SQL> alter tablespace data offline immediate;
alter tablespace data offline immediate
*
ERROR at line 1:
ORA-01145: offline immediate disallowed unless media recovery enabled
SQL> alter tablespace data begin backup;
alter tablespace data begin backup
*
ERROR at line 1:
ORA-01123: cannot start online backup; media recovery not enabled
这个时候还是启用归档。
SQL> shut immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1261564 bytes
Variable Size 163577860 bytes
Database Buffers 142606336 bytes
Redo Buffers 7127040 bytes
Database mounted.
SQL> alter database archivelog ;
Database altered.
SQL> alter database open;
Database altered.
如果在归档模式中,使用热备份,需要声明begin backup,为了能够修复在热备份过程中可能产生的分裂数据块。
SQL> alter tablespace data begin backup;
Tablespace altered.
这个时候停库就会抛错。
SQL> shutdown immediate;
ORA-01149: cannot shutdown - file 5 has online backup set
ORA-01110: data file 5: '/u02/oracle/oradata/data02.dbf'
如果发生断电现象,则在重启的时候出现ORA-01113: file 5 needs media recovery就需要明辨这个错误背后的意思
SQL> shutdown abort
ORACLE instance shut down.
SQL> startup
ORACLE instance started.
Total System Global Area 314572800 bytes
Fixed Size 1261564 bytes
Variable Size 163577860 bytes
Database Buffers 142606336 bytes
Redo Buffers 7127040 bytes
Database mounted.
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '/u02/oracle/oradata/data02.dbf'
其实碰到这个错误,还是需要结合多种场景来考虑,比如查看是否热备份已经正常完成,之前的操作是什么样的?
SQL> desc v$backup
Name Null? Type
----------------------------------------- -------- ----------------------------
FILE# NUMBER
STATUS VARCHAR2(18)
CHANGE# NUMBER
TIME DATE
SQL> select *from v$backup;
FILE# STATUS CHANGE# TIME
---------- ------------------ ---------- ---------
1 NOT ACTIVE 0
2 NOT ACTIVE 0
3 NOT ACTIVE 0
4 NOT ACTIVE 0
5 ACTIVE 879352 20-JUL-15
可以从SCN的地方看出和重建控制文件的场景还是存在一定的差别。
SQL> select file#,checkpoint_change#,last_change# from v$datafile;