在10grac下,更改归档模式不像单机或主/备模式下那么容易更改,主要是因为cluster_database参数的缘故。通过将 cluster_database参数从true改为false,可以顺利用更改单机归档模式的方式来更改归档设置。更改完毕后,再将 cluster_database参数改回true即可。至于归档日志,可以通过nfs共享来保存两边共有的归档日志,当然也可以用rman直接各自备各个节点的归档日志,当需要恢复时,再将归档日志合并即可。
归档位置说明:
归档位置一(本地) | 归档位置二(远程) | |
实例1 | 本地 /prod1_arch | 远程 /prod2_arch |
实例2 | 本地 /prod2_arch | 远程 /prod1_arch |
步骤一:配置每个实例的归档位置
[root@racr1 ~]# su - oracle
racr1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Aug 19 21:58:59 2014
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 mode No Archive Mode
Automatic archival Disabled
Archive destination /u01/app/oracle/product/10.2.0/db_1/dbs/arch
Oldest online log sequence 3
Current log sequence 4
SQL>
SQL> col instance_name format a30
SQL> col host_name format a30
SQL> col status format a30
SQL>
SQL> select instance_name,host_name,status from gv$instance;
INSTANCE_NAME HOST_NAME STATUS
------------------------------ ------------------------------ ------------------------------
PROD1 racr1 OPEN
PROD2 racr2 OPEN
SQL>
SQL> alter system set log_archive_dest_1='location=/prod2_arch' scope = spfile sid='PROD2';
System altered.
SQL>
SQL>
SQL> alter system set log_archive_dest_2='service=prod1' scope = spfile sid='PROD2';
System altered.
SQL>
SQL> alter system set log_archive_dest_1='location=/prod1_arch' scope = spfile sid='PROD1';
System altered.
SQL>
SQL> alter system set log_archive_dest_2='service=prod2' scope = spfile sid='PROD1';
System altered.
SQL>
SQL> alter system set standby_archive_dest='/prod2_arch' scope = spfile sid='PROD1';
System altered.
SQL>
SQL> alter system set standby_archive_dest='/prod1_arch' scope = spfile sid='PROD2';
System altered.
SQL> alter system set cluster_database=false scope = spfile sid='*';
System altered.
SQL>
步骤二:关闭所有实例
racr1-> srvctl stop database -d PROD
步骤三: 在单一实例上面
racr1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Aug 19 22:37:24 2014
Copyright (c) 1982, 2010, Oracle. All Rights Reserved.
Connected to an idle instance.
SQL> startup mount
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2098112 bytes
Variable Size 163580992 bytes
Database Buffers 427819008 bytes
Redo Buffers 6287360 bytes
Database mounted.
SQL> alter system set cluster_database=true scope = spfile sid='*';
System altered.
SQL> shutdown immediate
ORA-01109: database not open
Database dismounted.
ORACLE instance shut down.
SQL> exit
记得修改完属性后,关闭这个节点,因为下面我们用srvctl命令开启数据库
步骤四:开启数据库
racr1-> srvctl start database -d PROD
步骤五:验证
在2个节点上面切换在线日志,查看相应的归档目录。
racr2-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Aug 19 22:33:27 2014
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> alter system switch logfile;
System altered.
SQL> exit
Disconnected from Oracle Database
[root@racr1 prod1_arch]# cd /prod2_arch/
[root@racr1 prod2_arch]# ls
[root@racr1 prod2_arch]#
[root@racr1 prod2_arch]# ls
1_8_850242437.dbf
[root@racr1 prod2_arch]#
[root@racr1 prod2_arch]#
在节点2切换,在节点1也可以看见归档日志。这样就成功了
racr1-> sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Aug 19 22:33:10 2014
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 mode Archive Mode
Automatic archival Enabled
Archive destination /prod1_arch
Oldest online log sequence 5
Next log sequence to archive 6
Current log sequence 6
SQL>
查看数据库归档状态。