Oracle的生产库都是启动在归档模式下,RAC下归档非归档的切换和单实例也是一样的,都是在MOUNT模式下执行ALTERDATABASEARCHIVELOG/NOARCHIVELOG;命令。不同的是:RAC环境下所有实例都必须处于非OPEN状态,然后在任意一个处于MOUNT状态的实例执行ALTERDATABASE命令,操作成功后,再正常启动其它实例即可。
注意:RAC数据库由于拥有多个实例,要注意每个实例相关初始化参数:LOG_ARCHIVE_DEST_n的设置,务必需要确保该参数设置的路径合法有效,归档也能顺利进行。
切换示例:
[oracle@raw1dbs]$exportORACLE_SID=raw1
[oracle@raw1dbs]$sqlplus/nolog
SQL*Plus:Release10.2.0.1.0-ProductiononMonApr1916:17:432010
Copyright(c)1982,2005,Oracle.Allrightsreserved.
SQL>conn/assysdba
Connected.
SQL>archiveloglist
DatabaselogmodeNoArchiveMode
AutomaticarchivalDisabled
ArchivedestinationUSE_DB_RECOVERY_FILE_DEST
Oldestonlinelogsequence21
Currentlogsequence22
SQL>
SQL>selectinst_id,instance_name,version,archiver,statusfromgv$instance;
INST_ID INSTANCE_NAMEVERSIONARCHIVE STATUS
---------- ---------------- ------------------------------- ------------
1 raw110.2.0.1.0STOPPED OPEN
2 raw210.2.0.1.0STOPPED OPEN
修改归档的默认路径:
SQL>altersystemsetlog_archive_dest_1='location=/u01/raw1arch'sid='raw1';
Systemaltered.
SQL>altersystemsetlog_archive_dest_1='location=/u01/raw2arch'sid='raw2';
Systemaltered.
SQL>showparameterlog_archive
NAMETYPEVALUE
-----------------------------------------------------------------------------
log_archive_configstring
log_archive_deststring
log_archive_dest_1stringlocation=/u01/raw2arch
.......
log_archive_dest_state_1stringenable
.......
NAMETYPEVALUE
-----------------------------------------------------------------------------
log_archive_duplex_deststring
log_archive_formatstring%t_%s_%r.dbf
log_archive_local_firstbooleanTRUE
log_archive_max_processesinteger2
log_archive_min_succeed_destinteger1
log_archive_startbooleanFALSE
log_archive_traceinteger0
切换归档模式:
注意事项:所有节点都必须处于mount状态。在其中一个节点修改模式,然后在其他节点正常启动即可。
SQL>startupmount;
ORACLEinstancestarted.
TotalSystemGlobalArea184549376bytes
FixedSize1218412bytes
VariableSize113248404bytes
DatabaseBuffers67108864bytes
RedoBuffers2973696bytes
Databasemounted.
SQL>alterdatabasearchivelog;
Databasealtered.
SQL>alterdatabaseopen;
Databasealtered.
SQL>archiveloglist;
DatabaselogmodeArchiveMode
AutomaticarchivalEnabled
Archivedestination/u01/raw2arch
Oldestonlinelogsequence14
Nextlogsequencetoarchive15
Currentlogsequence15
启动另一个节点,查看状态:
SQL>alterdatabaseopen;
Databasealtered.
SQL>archiveloglist;
DatabaselogmodeArchiveMode
AutomaticarchivalEnabled
Archivedestination/u01/raw1arch
Oldestonlinelogsequence21
Nextlogsequencetoarchive22
Currentlogsequence22
SQL>
至此,现在RAC已经切换到归档模式了。
二.切换成非归档
在一台主机上执行:
SQL>ALTERSYSTEMSETCLUSTER_DATABASE=FALSESCOPE=SPFILE;
在两台主机上执行:
SQL>shutdownimmediate;
在一台主机上执行:
SQL>startupmount;
SQL>alterdatabasenoarchivelog;
SQL>ALTERSYSTEMSETCLUSTER_DATABASE=TRUESCOPE=SPFILE;
SQL>shutdownimmediate;
在两台主机上执行:
SQL>STARTUP