方法一
首先来看一下官方的文档:
How To Enable Archive Logging In RAC Environment [ID 1186764.1] 转到底部 修改时间:2011-6-2类型:HOWTO状态:PUBLISHED优先级:3 注释 (0) In this Document Goal Solution References Applies to: Oracle Server - Enterprise Edition - Version: 10.1.0.2 to 11.2.0.2 - Release: 10.1 to 11.2 Information in this document applies to any platform. Goal How to enable database archivelog in RAC configuration? Solution The following steps need to be taken to enable archive logging in a RAC database environment: -- shutdown immediate all database instances $ srvctl stop database -d-- startup database in mount mode $ srvctl start database -d -o mount -- enable archvive logging $ sqlplus / as sysdba sql> alter database archivelog; sql> exit; -- stop database $ srvctl stop database -d-- restart all database instances $ srvctl start database -d -- verify archiving is enabled by means of: sql> archive log list; You might need to set your log_archive_dest(_n) parameters to a shared location in each spfile, but the log_archive_start parameter does not need to be set anymore as of 10g (see Note 274302.1). To disable archive logging, follow the same steps but use the NOARCHIVELOG clause of the ALTER DATABASE statement.--这儿如果从归档切换回非归档,按照同样的步骤设置为NOARCHIVELOG即可 References NOTE:235158.1 - How To Enable/Disable Archive Log Mode in Real Application Cluster Environment NOTE:274302.1 - ARCHIVELOG mode in Oracle 10g and 11g
归结为如下步骤(包括部分参数的设置,官方文档采用了启动全部实例到mount,这儿只启用一个实例到mount):
$srvctl stop database -d RACDB --节点1 sql>startup mount sql>alter system set log_archive_dest_1='LOCATION=/oracleapp/arch' scope=spfile sid='RACDB1'; sql>alter system set log_archive_dest_1='LOCATION=/oracleapp/arch' scope=spfile sid='RACDB2'; sql>alter system set cluster_database=false scope=spfile;-- sql>shutdown immediate sql>startup mount sql>alter database archivelog sql>alter database open sql>alter system set cluster_database=true scope=spfile;-- sql>shutdown immediate $srvctl start database -d RACDB
对参数cluster_database的说明:
这个参数的取值是TRUE和FALSE。对于所有实例,这个参数的取值应当设置为TRUE。TRUE值将指引实例在启动期间以共享模式挂载控制文件。
如果一个首先启动的实例将该参数设置为FALSE,那么它将能够以独占模式挂载控制文件。但是这样会禁止所有后台实例启动,如果试图去启动别的实例,
则会收到以下错误:
SQL> startup
ORA-01102: cannot mount database in EXCLUSIVE mode
在以下维护操作期间,必须使用cluster_database=FALSE启动实例:
方法二
这种方法收集来自网络,没有试过,其实本质都一样:
节点1 SQL> alter system set log_archive_dest_1='location=/oracleapp/arch' sid='RACDB1'; SQL> alter system set log_archive_dest_1='location=/oracleapp/arch' sid='RACDB2'; 关闭两个节点 shutdown immediate 然后分别将两个节点开启到mount模式 SQL> startup mount 节点1 SQL> alter database archivelog; SQL> alter database open; 节点2 SQL> alter database open;
下面是我的实验记录(包括启用归档和关闭归档,操作都在一个节点进行):
SQL> archive log list Database log mode No Archive Mode Automatic archival Disabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 337 Current log sequence 338 SQL> alter system set cluster_database=false scope=spfile; System altered. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@rac121 ~]$ srvctl stop database -d racdb [oracle@rac121 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on 星期五 8月 31 15:16:23 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to an idle instance. SQL> startup mount ORACLE instance started. Total System Global Area 1.3462E+10 bytes Fixed Size 2241104 bytes Variable Size 7281315248 bytes Database Buffers 6174015488 bytes Redo Buffers 4485120 bytes Database mounted. SQL> alter database archivelog; Database altered. SQL> alter system set cluster_database=true scope=spfile; System altered. SQL> shutdown immediate ORA-01109: 数据库未打开 Database dismounted. ORACLE instance shut down. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@rac121 ~]$ srvctl start database -d racdb [oracle@rac121 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on 星期五 8月 31 15:18:42 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> archive log list Database log mode Archive Mode Automatic archival Enabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 337 Next log sequence to archive 338 Current log sequence 338 SQL> alter system set cluster_database=false scope=spfile; System altered. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@rac121 ~]$ srvctl stop database -d racdb [oracle@rac121 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on 星期五 8月 31 15:19:45 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to an idle instance. SQL> startup mount ORACLE instance started. Total System Global Area 1.3462E+10 bytes Fixed Size 2241104 bytes Variable Size 7281315248 bytes Database Buffers 6174015488 bytes Redo Buffers 4485120 bytes Database mounted. SQL> alter database noarchivelog ; Database altered. SQL> alter system set cluster_database=true scope=spfile; System altered. SQL> shutdown immediate ORA-01109: 数据库未打开 Database dismounted. ORACLE instance shut down. SQL> exit Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options [oracle@rac121 ~]$ srvctl start database -d racdb [oracle@rac121 ~]$ sqlplus / as sysdba SQL*Plus: Release 11.2.0.3.0 Production on 星期五 8月 31 15:21:40 2012 Copyright (c) 1982, 2011, Oracle. All rights reserved. Connected to: Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production With the Partitioning, Real Application Clusters, Automatic Storage Management, OLAP, Data Mining and Real Application Testing options SQL> archive log list Database log mode No Archive Mode Automatic archival Disabled Archive destination USE_DB_RECOVERY_FILE_DEST Oldest online log sequence 338 Current log sequence 339 SQL>