【ARCHIVE】使用startup mount force启动数据库后无法修改归档模式的模拟

如果您需要调整数据库的归档模式,在启动数据库之前,数据库一定要保证“彻底关闭”,否则归档模式是不允许修改的。
简单模拟一下。

1.查看数据库归档模式
$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.3.0 - Production on Wed Mar 3 00:10:42 2010

Copyright (c) 1982, 2006, Oracle.  All Rights Reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.3.0 - Production
With the Partitioning, OLAP and Data Mining options

sys@ora10g> archive log list;
Database log mode              No Archive Mode
Automatic archival             Disabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     17
Current log sequence           19

2.使用“startup mount force”启动数据库到mount状态(相当于一次异常断电后的重启)
sys@ora10g> startup mount force;
ORACLE instance started.

Total System Global Area  104857600 bytes
Fixed Size                  1289172 bytes
Variable Size              88081452 bytes
Database Buffers            8388608 bytes
Redo Buffers                7098368 bytes
Database mounted.

3.此时如果修改归档模式将会收到“ORA-00265”的报错
sys@ora10g> alter database archivelog;
alter database archivelog
*
ERROR at line 1:
ORA-00265: instance recovery required, cannot set ARCHIVELOG mode

原因很简单,数据库没有处于一个稳定一致的状态,因此无法完成归档模式的调整。

4.正确的调整方法如下
1)先OPEN数据库
sys@ora10g> alter database open;

Database altered.

2)使用“shutdown immediate”彻底关闭数据库
sys@ora10g> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

3)将数据库启动到mount状态
sys@ora10g> startup mount;
ORACLE instance started.

Total System Global Area  104857600 bytes
Fixed Size                  1289172 bytes
Variable Size              88081452 bytes
Database Buffers            8388608 bytes
Redo Buffers                7098368 bytes
Database mounted.

4)调整数据库的归档模式
sys@ora10g> alter database archivelog;

Database altered.

成功!

5)OPEN数据库
sys@ora10g> alter database open;

Database altered.

6)最后确认数据库已处于归档模式
sys@ora10g> archive log list;
Database log mode              Archive Mode
Automatic archival             Enabled
Archive destination            USE_DB_RECOVERY_FILE_DEST
Oldest online log sequence     18
Next log sequence to archive   20
Current log sequence           20

5.小结
技术的每一个细节都值得去尝试和推敲。做过了,思考了,也就得到了。

Good luck.

secooler
10.03.02

-- The End --

请使用浏览器的分享功能分享到微信等