oracle 的归档模式的 开启与关闭

DB version:11.2.0.3.0

OS version:rhel 6.3

PS:测试用的数据库是一个刚刚模拟断电的库

  1. 打开归档模式
已sysdba身份登录数据库
[oracle@oracle ~]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.3.0 Production on Mon Apr 29 16:02:20 2024

Copyright (c) 1982, 2011, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup mount;
ORACLE instance started.

Total System Global Area  626327552 bytes
Fixed Size		    2230952 bytes
Variable Size		  373294424 bytes
Database Buffers	  247463936 bytes
Redo Buffers		    3338240 bytes
Database mounted.

当前状态为非归档模式

SQL> archive log list;
Database log mode	       No Archive Mode
Automatic archival	       Disabled
Archive destination	       USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     5
Current log sequence	       7

开启归档模式
SQL> alter database archivelog;
alter database archivelog
*
ERROR at line 1:
ORA-00265: instance recovery required, cannot set ARCHIVELOG mode

哦?神奇的一幕出现了。。。数据库的非正常关闭的,需要recovery。。当前状态无法打开归档模式

SQL> alter database open;

Database altered.

后台日志如下

332 alter database open
333 Beginning crash recovery of 1 threads
334 Started redo scan
335 Completed redo scan
336  read 6 KB redo, 4 data blocks need recovery
337 Started redo application at
338  Thread 1: logseq 7, block 58339
339 Recovery of Online Redo Log: Thread 1 Group 1 Seq 7 Reading mem 0
340   Mem# 0: /u01/app/oracle/oradata/ORCL/redo01a.log
341 Completed redo application of 0.00MB
342 Completed crash recovery at
343  Thread 1: logseq 7, block 58351, scn 225781
344  4 data blocks read, 4 data blocks written, 6 redo k-bytes read
345 Mon Apr 29 16:03:30 2024
346 Thread 1 advanced to log sequence 8 (thread open)
347 Thread 1 opened at log sequence 8
348   Current log# 2 seq# 8 mem# 0: /u01/app/oracle/oradata/ORCL/redo02a.log
349 Successful open of redo thread 1
350 MTTR advisory is disabled because FAST_START_MTTR_TARGET is not set
351 Mon Apr 29 16:03:30 2024
352 SMON: enabling cache recovery
353 [2743] Successfully onlined Undo Tablespace 2.
354 Undo initialization finished serial:0 start:404654 end:404714 diff:60 (0 seconds)
355 Verifying file header compatibility for 11g tablespace encryption..
356 Verifying 11g file header compatibility for tablespace encryption completed
357 SMON: enabling tx recovery
358 Database Characterset is AL32UTF8
359 No Resource Manager plan active
360 replication_dependency_tracking turned off (no async multimaster replication found)
361 Starting background process QMNC
362 Mon Apr 29 16:03:31 2024
363 QMNC started with pid=20, OS id=2746
364 Completed: alter database open

数据库启动后,正常关闭数据库

SQL> shutdown immediate;  
Database closed.
Database dismounted.
ORACLE instance shut down.
SQL> startup mount;
ORACLE instance started.

Total System Global Area  626327552 bytes
Fixed Size		    2230952 bytes
Variable Size		  373294424 bytes
Database Buffers	  247463936 bytes
Redo Buffers		    3338240 bytes
Database mounted.

SQL> archive log list;
Database log mode	       No Archive Mode
Automatic archival	       Disabled
Archive destination	       USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Current log sequence	       8

启动到mount状态后,打开归档成功
SQL> alter database archivelog;

Database altered.

SQL> alter database open;

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     6
Next log sequence to archive   8
Current log sequence	       8
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
  1. 关闭归档模式
SQL> startup mount;
ORACLE instance started.

Total System Global Area  626327552 bytes
Fixed Size		    2230952 bytes
Variable Size		  373294424 bytes
Database Buffers	  247463936 bytes
Redo Buffers		    3338240 bytes
Database mounted.

启动到mount状态后,关闭归档模式
SQL> alter database noarchivelog;

Database altered.

SQL> archive log list;
Database log mode	       No Archive Mode
Automatic archival	       Disabled
Archive destination	       USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     6
Current log sequence	       8
SQL> alter database open;

Database altered.

posted @ 2024-04-29 16:15  Coye  阅读(4)  评论(0编辑  收藏  举报