环境:两个节点的Oracle10gRAC环境,数据库创建在独立的磁盘阵列上的裸设备上,数据库在非归档模式中,现在需要改为归档模式,具体步骤如下:
在节点1:
-bash-3.2$ sqlplus /
as sysdba
SQL*Plus: Release
10.2.0.5.0 - Production on Wed Jun 20 21:26:57 2012
Copyright (c) 1982,
2010, Oracle.All Rights Reserved.
Connected to:
Oracle Database 10g
Enterprise Edition Release 10.2.0.5.0 - 64bit Production
With the
Partitioning, Real Application Clusters, OLAP, Data Mining
and Real Application
Testing options
SQL> archive log
list;
Database log
modeNo Archive Mode
Automatic
archivalDisabled
Archive
destination/oracle/product/10.2.0/db/dbs/arch
Oldest online log
sequence94
Current log
sequence96
SQL> alter system set cluster_database=false
scope=spfile sid='*';
System altered.
SQL> alter system set
log_archive_dest_1='location=/databak/archivelog' scope=spfile sid='*';
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut
down.[@more@]
在节点2:
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut
down.
在节点1:
SQL> startup mount;
ORACLE instance
started.
Total System Global
Area 1610612736 bytes
Fixed Size2096632 bytes
Variable Size1023410696 bytes
Database
Buffers570425344 bytes
Redo Buffers14680064 bytes
Database mounted.
SQL> alter database archivelog;
Database altered.
SQL> archive log list;
Database log modeArchive Mode
Automatic archivalEnabled
Archive destination/databak/archivelog
Oldest online log
sequence94
Next log sequence to
archive96
Current log
sequence96
SQL> alter
database open;
Database altered.
SQL> alter system set cluster_database=true
scope=spfile sid='*';
System altered.
节点2:
SQL> startup mount;
ORACLE instance
started.
Total System Global
Area 1610612736 bytes
Fixed Size2096632 bytes
Variable Size1124073992 bytes
Database
Buffers469762048 bytes
Redo Buffers14680064 bytes
ORA-01183: cannot mount database in SHARED mode
该提示说明数据库的cluster_database=true参数因scope=spfile原因只会影响到spfile上,而现有内存上的实际状态为cluster_database=false,因此节点2的实例无法启动。要让该参数最新值的生效,需要重启节点1的实例...
节点1:
SQL> shutdown
immediate;
Database closed.
Database dismounted.
ORACLE instance shut
down.
SQL> startup
ORACLE instance
started.
Total System Global
Area 1610612736 bytes
Fixed Size2096632 bytes
Variable Size1040187912 bytes
Database
Buffers553648128 bytes
Redo Buffers14680064 bytes
Database mounted.
Database opened.
SQL> archive log list;
Database log
modeArchive Mode
Automatic
archivalEnabled
Archive
destination/databak/archivelog
Oldest online log
sequence94
Next log sequence to
archive96
Current log
sequence96
SQL> alter system
switch logfile;
System altered.
SQL> /
System altered.
节点2现在可以mount并打开数据库:
SQL> shutdown immediate;
ORA-01507: database
not mounted
ORACLE instance shut
down.
SQL> startup mount;
ORACLE instance
started.
Total System Global
Area 1610612736 bytes
Fixed Size2096632 bytes
Variable Size1124073992 bytes
Database
Buffers469762048 bytes
Redo Buffers14680064 bytes
Database mounted.
SQL> archive log list;
Database log
modeArchive Mode
Automatic
archivalEnabled
Archive
destination/databak/archivelog
Oldest online log
sequence44
Next log sequence to
archive46
Current log
sequence46
SQL> alter database archivelog;
alter database
archivelog
*
ERROR at line 1:
ORA-01126: database must be mounted in this instance
and not open in any
instance
为什么会提示这个呢?是因为spfile在共享存储上,而每个节点相应initSID.ora文件中做了链接,这个有助于两个实例参数内容不一致导致的一些异常情况的避免。
-bash-3.2$ cd product/10.2.0/db/dbs/
-bash-3.2$ ls
hc_gderp1.datinit.orainitdw.orainittest1.oraorapwtest1
-bash-3.2$ more inittest1.ora
SPFILE='/dev/raw/raw14'
-bash-3.2$
SQL> alter
database open;
Database altered.
SQL> archive log
list;
Database log
modeArchive Mode
Automatic
archivalEnabled
Archive
destination/databak/archivelog
Oldest online log
sequence44
Next log sequence to
archive46
Current log
sequence46
最后分别在连个节点多做几次alter system switch logfile或alter system archive
log current操作查看归档是否成功并归档到正确位置。