数据库:oracle 11.2.0.4
系统:centos 7.9
问题描述:将数据文件users02.dbf离线时,出现“ORA-01145:除非启用介质恢复,否则不允许立即脱机”告警,如下所示:
SQL> alter database datafile 5 offline;
alter database datafile 5 offline
*
ERROR at line 1:
ORA-01145: offline immediate disallowed unless media recovery enabled
SQL> select d.tablespace_name,v.file#,d.file_name,d.bytes/1024/1024,v.status,v.enabled,d.autoextensible,d.increment_by from dba_data_files d,v$datafile v where d.file_id=v.file#
TABLESPACE_NAME FILE# FILE_NAME D.BYTES/1024/1024 STATUS ENABLED AUT INCREMENT_BY
--------------- ---------- -------------------------------------------------- ----------------- ------- ---------- --- ------------
USERS 4 /u01/app/oracle/oradata/leodb/users01.dbf 5 ONLINE READ WRITE YES 160
UNDOTBS1 3 /u01/app/oracle/oradata/leodb/undotbs01.dbf 70 ONLINE READ WRITE YES 640
SYSAUX 2 /u01/app/oracle/oradata/leodb/sysaux01.dbf 490 ONLINE READ WRITE YES 1280
SYSTEM 1 /u01/app/oracle/oradata/leodb/system01.dbf 740 SYSTEM READ WRITE YES 1280
USERS 5 /u01/app/oracle/oradata/leodb/users02.dbf 10 ONLINE READ WRITE YES 1
异常原因:数据库处于非归档模式.
解决方案:开启归档,实际操作如下:
SQL> select name,log_mode from v$database;
NAME LOG_MODE
-------------------------------------------------- ------------
LEODB NOARCHIVELOG
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount
ORACLE instance started.
Total System Global Area 3006406656 bytes
Fixed Size 2257032 bytes
Variable Size 704647032 bytes
Database Buffers 2281701376 bytes
Redo Buffers 17801216 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence 3
Next log sequence to archive 5
Current log sequence 5
SQL> alter system set log_archive_dest_1='location=/u01/app/oracle/archivelog/';
System altered.
SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/app/oracle/archivelog/
Oldest online log sequence 3
Next log sequence to archive 5
Current log sequence 5
SQL> alter database open;
Database altered.
SQL> alter database datafile 5 offline;
Database altered.