搭建Oracle11gR2 DataGuard

安装好两台Oracle11gR2后,简单的建了个测试库,然后搭建了一套物理备库。整个过程非常简单,和以前的版本也没多大区别。不过因为11g密码以及密码文件名大小写的问题折腾了一下。

按照以前9i和10g的文档,使用如下语句创建了passwordfile:

orapwd file=$ORACLE_HOME/dbs/orapwTEST password=pass entries=30

结果发现主库的归档一直无法传递到备库,报:

ORA-16191: Primary log shipping client not logged on standby

根据以前的经验,重新创建了住备库的password file,根据metalink,修改了sec_case_sensitive_logon参数为false,都不行。最后才发现,必须将passwordfile中的sid改成小写才行。

orapwd file=$ORACLE_HOME/dbs/orapwtest password=pass entries=30

Oracle11g,最吸引人的特性是Active Data Guard,也就是物理备库在open read only的同时,可以apply log。启用该特性非常简单,首先要确保compatible=11.0.0.0以上,然后在open read only的状态下执行recover managed standby database disconnect即可。开启该特性最好能同时开启实时日志应用,以减少主备库之间数据的延迟,所以在备库添加好standby logfile:

recover managed standby database cancel;

alter database open;

alter database add standby logfile group 10 ('/u01/oracle/oradata/test/stbredo01.dbf') size 100m reuse; 
alter database add standby logfile group 11 ('/u01/oracle/oradata/test/stbredo02.dbf') size 100m reuse;
alter database add standby logfile group 12 ('/u01/oracle/oradata/test/stbredo03.dbf') size 100m reuse;
alter database add standby logfile group 13 ('/u01/oracle/oradata/test/stbredo04.dbf') size 100m reuse;

然后将备库置于实时日志应用模式:

SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY

SQL> alter database recover managed standby database using current logfile disconnect; 
Database altered.

SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY

在主库创建测试表并插入数据:

SQL> create table ningoo.test_table(i int);
Table created.

SQL> insert into ningoo.test_table values(1);
1 row created.

SQL> commit;
Commit complete.

SQL> alter system archive log current;
System altered.

在备库查询:

SQL> select * from ningoo.test_table;
         I
----------
         1


无觅相关文章插件,快速提升流量

没有评论


(Required)
(Required, will not be published)