11g R2 RAC 環境下開啓歸檔模式的方法

方法一

首先來看一下官方的文檔:

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 <db_unique_name>

-- startup database in mount mode
$ srvctl start database -d <db_unique_name> -o mount

-- enable archvive logging
$ sqlplus / as sysdba
sql> alter database archivelog;
sql> exit;

-- stop database
$ srvctl stop database -d <db_unique_name>

-- restart all database instances
$ srvctl start database -d <db_unique_name>

-- 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啓動實例:

  • 從無存檔日誌模式轉換爲存檔日誌模式及反向轉換。
  • 啓用閃回數據庫功能。
  • 升級期間。
  • 對系統表空間執行介質恢復。
  • 從Oracle RAC 數據庫轉換爲單實例數據庫及反向轉換。
這個參數的默認值是FALSE,爲了在Oracle RAC環境中啓動實例,這個參數必須設置爲TRUE。



方法二

這種方法收集來自網絡,沒有試過,其實本質都一樣:

節點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> 



發表評論
所有評論
還沒有人評論,想成為第一個評論的人麼? 請在上方評論欄輸入並且點擊發布.
相關文章