pfile里面都是我们设置的一些基本参数。 但是备库有冗余的作用,所以这里还是建议用主库的pfile copy过来,然后修改相关参数后,在创建spfile。这样即使切换了,对DB的影响也不大。
2. 只要备库的监听不重启,重启备库后,主库还是能识别的。 如果备库的监听重启了。那么主库也就需要重启。
3. 复制结束后的Standby 只启动到mount standby 的状态。 并没有启动MRP的应用归档程序。 所以这个时候查询主备库,归档是不同步的。需要手动的启动MRP进程。
SQL> alter database recover managed standby database disconnect from session;
4. 备库Standby redo log 问题:
在duplicate 结束后,备库没有添加standby redo log file。 但是主库采用的是:lgwr async传送的日志。 当备库的RFS 进程接收到日志后,发现备库没有standby redo log的时候,备库会自动用ARCH将其写入归档文件。
以下是备库的alert log:
Tue Mar 08 16:53:32 2011
Archived Log entry 9 added for thread 1 sequence 21 rlc 745174404 ID 0x4bdfd301 dest 2:
RFS[2]: Opened log for thread 1 sequence 22 dbid 1272955137 branch 745174404
Tue Mar 08 16:53:36 2011
Media Recovery Log /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_21_745174404.dbf
Media Recovery Waiting for thread 1 sequence 22 (in transit) --传输中
Tue Mar 08 16:58:58 2011
Archived Log entry 10 added for thread 1 sequence 22 rlc 745174404 ID 0x4bdfd301 dest 2:
RFS[2]: Opened log for thread 1 sequence 23 dbid 1272955137 branch 745174404
Tue Mar 08 16:59:00 2011
Media Recovery Log /u01/app/oracle/product/11.2.0/dbhome_1/dbs/arch1_22_745174404.dbf
Media Recovery Waiting for thread 1 sequence 23 (in transit)
-- 注意这里归档文件目录,使用的是$ORACLE_HOME/dbs, 自动转换为ARCH时,也是使用默认的归档目录。
5. 在备库添加standby redo log:
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dave/stdbyredo01.log' size 50m;
alter database add standby logfile '/u01/app/oracle/oradata/dave/stdbyredo01.log' size 50m
*
ERROR at line 1:
ORA-01156: recovery or flashback in progress may need access to files
--在备库添加standby redo log需要先停MRP
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dave/stdbyredo01.log' size 50m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dave/stdbyredo02.log' size 50m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dave/stdbyredo03.log' size 50m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/dave/stdbyredo04.log' size 50m;
Database altered.
SQL> alter database recover managed standby database disconnect from session;
Database altered.
在看一下日志:
Tue Mar 08 17:47:39 2011
Archived Log entry 15 added for thread 1 sequence 27 ID 0x4bdfd301 dest 1:
RFS[2]: Selected log 4 for thread 1 sequence 28 dbid 1272955137 branch 745174404
Tue Mar 08 17:47:43 2011
Archived Log entry 16 added for thread 1 sequence 28 ID 0x4bdfd301 dest 1:
Media Recovery Log /u01/archivelog/1_27_745174404.dbf
RFS[2]: Selected log 4 for thread 1 sequence 29 dbid 1272955137 branch 745174404
Media Recovery Log /u01/archivelog/1_28_745174404.dbf
Media Recovery Waiting for thread 1 sequence 29 (in transit)
--我们添加standby redo log 之后,归档文件变成了我们指定的Log_archive_dest_n 指定的参数。
6. 在主库也添加一下standby redo log
SQL> alter database add standby logfile '/u01/app/oracle/oradata/orcl/stdbyredo01.log' size 50m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/orcl/stdbyredo02.log' size 50m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/orcl/stdbyredo03.log' size 50m;
Database altered.
SQL> alter database add standby logfile '/u01/app/oracle/oradata/orcl/stdbyredo04.log' size 50m;
Database altered.
7. 启用real-time apply,从而实现real-time query:
SQL> alter database recover managed standby database cancel;
Database altered.
SQL> ALTER DATABASE OPEN;
Database altered.
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT;
Database altered.
8. 验证real-time apply 和real-time query:
Primary:
SQL> create table dave(id number,name varchar2(20));
Table created.
SQL> insert into dave values(1,'tianlesoftware');
1 row created.
SQL> commit;
Commit complete.
Standby:
SQL> select open_mode from v$database;
OPEN_MODE
--------------------
READ ONLY WITH APPLY
SQL> select * from dave;
ID NAME
---------- ---------------
1 tianlesoftware
小结:
Oracle 11gR2 的物理Data Guard 功能很强大。
--------------------------------------分割线 --------------------------------------
相关参考:
基于同一主机配置 Oracle 11g Data Guard
Oracle Data Guard (RAC+DG) 归档删除策略及脚本
Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法
--------------------------------------分割线 --------------------------------------