Oracle RAC 归档与非归档切换

Oracle 的生产库都是启动在归档模式下,RAC下归档非归档的切换和单实例也是一样的,都是MOUNT模式下执行ALTER DATABASE ARCHIVELOG/NOARCHIVELOG;命令。 不同的是:RAC环境下所有实例都必须处于非OPEN状态,然后在任意一个处于MOUNT状态的实例执行ALTER DATABASE命令,操作成功后,再正常启动其它实例即可。

注意:RAC数据库由于拥有多个实例,要注意每个实例相关初始化参数:LOG_ARCHIVE_DEST_n的设置,务必需要确保该参数设置的路径合法有效,归档也能顺利进行。

[@more@]

[oracle@node1pub ~]$ echo $ORACLE_SID
orcl1
[oracle@node1pub ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Aug 24 14:05:12 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.


Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, Real Application Clusters, OLAP and Data Mining 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 56
Current log sequence 57
SQL> select inst_id,instance_name,version,archiver,status from gv$instance;

INST_ID INSTANCE_NAME VERSION ARCHIVE STATUS
---------- ---------------- ----------------- ------- ------------
1 orcl1 10.2.0.1.0 STOPPED OPEN
2 orcl2 10.2.0.1.0 STOPPED OPEN


修改归档的默认路径

在两个节点分别建立归档的目录

[oracle@node1pub u01]$ mkdir orcl1_arch

[oracle@node2pub u01]$ mkdir orcl2_arch

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

SQL> alter system set log_archive_dest_1='location=/u01/orcl1_arch' sid='orcl1';

System altered.

SQL> alter system set log_archive_dest_1='location=/u01/orcl2_arch' sid='orcl2';

System altered.

SQL> show parameter log_archive_dest_1

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string location=/u01/orcl1_arch
log_archive_dest_10 string

登出第二个节点查看:

[oracle@node2pub u01]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Aug 24 13:52:44 2012

Copyright (c) 1982, 2005, Oracle. All rights reserved.


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


SQL> show parameter log_archive_dest_1

NAME TYPE VALUE
------------------------------------ ----------- ------------------------------
log_archive_dest_1 string location=/u01/orcl2_arch
log_archive_dest_10 string


切换归档模式:

注意事项: 所有节点都必须处于mount状态。 在其中一个节点修改模式,然后在其他节点正常启动即可。

node1:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 100664936 bytes
Database Buffers 176160768 bytes
Redo Buffers 2973696 bytes
Database mounted.

node2:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup mount;
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 100664936 bytes
Database Buffers 176160768 bytes
Redo Buffers 2973696 bytes
Database mounted.

node1:

SQL> alter database archivelog;

Database altered.

SQL> alter database open;

Database altered.

node2:

SQL> alter database open;

Database altered.


SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/orcl2_arch
Oldest online log sequence 17
Next log sequence to archive 18
Current log sequence 18

node1:

SQL> archive log list;
Database log mode Archive Mode
Automatic archival Enabled
Archive destination /u01/orcl1_arch
Oldest online log sequence 56
Next log sequence to archive 57
Current log sequence 57

至此,现在RAC已经切换到归档模式了。


下面来试试如何切换成非归档:

node1:

SQL> ALTER SYSTEM SET CLUSTER_DATABASE=FALSE SCOPE=SPFILE;

System altered.


====================================================
CLUSTER_DATABASE的意思是:
如果挂接数据库的第一个实例的CLUSTER_DATABASE为false,那么只有这个实例可以挂接这个数据库。如果第一个实例

的CLUSTER_DATABASE参数为true,那么其他参数CLUSTER_DATABASE值为true的实例也可以挂接这个数据库。
也就是保证在下面的步骤中node2不能连接到数据库。

如果node1的CLUSTER_DATABASE=FALSE,node2试图打图数据库时,则会出错:

SQL> startup mount
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 104859240 bytes
Database Buffers 171966464 bytes
Redo Buffers 2973696 bytes
ORA-01102: cannot mount database in EXCLUSIVE mode


======================================================

关闭两边的数据库:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

node2:

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.


node1:

SQL> startup mount
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 104859240 bytes
Database Buffers 171966464 bytes
Redo Buffers 2973696 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 not open


Database dismounted.
ORACLE instance shut down.

现在两个节点可正常打开了:

node1:

SQL> startup
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 104859240 bytes
Database Buffers 171966464 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.

SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/orcl1_arch
Oldest online log sequence 56
Current log sequence 57


node2:

SQL> startup
ORACLE instance started.

Total System Global Area 281018368 bytes
Fixed Size 1218968 bytes
Variable Size 104859240 bytes
Database Buffers 171966464 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.

SQL> archive log list;
Database log mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/orcl2_arch
Oldest online log sequence 17
Current log sequence 18

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/271283/viewspace-1059252/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/271283/viewspace-1059252/

  • 0
    点赞
  • 0
    收藏
    觉得还不错? 一键收藏
  • 0
    评论

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值