ITPub博客

首页 > 数据库 > Oracle > 关于DG配置备库无法Real-Time Apply,无法实时查询的一个案例

关于DG配置备库无法Real-Time Apply,无法实时查询的一个案例

原创 Oracle 作者:shawnloong 时间:2015-06-24 09:40:56 0 删除 编辑
好久没折腾过DG今天重新做一遍感觉问题百出。总结了一些错误
检查Alert日志
Destination LOG_ARCHIVE_DEST_2 is SYNCHRONIZED
******************************************************************
LGWR: Setting 'active' archival for destination LOG_ARCHIVE_DEST_2
******************************************************************
Destination LOG_ARCHIVE_DEST_2 no longer supports SYNCHRONIZATION
Thread 1 advanced to log sequence 68 (LGWR switch)
  Current log# 2 seq# 68 mem# 0: +DATA/netdata/onlinelog/group_2.267.882674055
 
开始猜测是因为以下参数的配置问题
ALTER SYSTEM SET log_archive_dest_2='SERVICE=snetdata lgwr sync valid_for=(online_logfile,primary_role) db_unique_name=snetdata' SCOPE=BOTH;

发现改成sync还是一样的。

检查一下logfile是否一致
SQL> select group#,bytes/1024/1024 from v$log;

    GROUP# BYTES/1024/1024
---------- ---------------
     1           100
     2           100
     3           100

SQL> select group#,bytes/1024/1024 from v$standby_log;

    GROUP# BYTES/1024/1024
---------- ---------------
     4           50
     5           50
     6           50
     7           50

SQL>
发现standbylog日志大小和logfile大小不一致
立即将备库的standbylog修正
备库操作:
SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE CANCEL;
SQL> alter system set standby_file_management=manual;

System altered.

SQL> alter database drop standby logfile group 4;

Database altered.

SQL> alter database drop standby logfile group 5;

Database altered.

SQL> alter database drop standby logfile group 6;

Database altered.

SQL> alter database drop standby logfile group 7;

atabase altered.

SQL> alter database add standby logfile group 4 ('/u02/oradata/netdata/stdredo01.log') size 100M;  

Database altered.

SQL> alter database add standby logfile group 5 ('/u02/oradata/netdata/stdredo02.log') size 100M;

Database altered.

SQL> alter database add standby logfile group 6 ('/u02/oradata/netdata/stdredo03.log') size 100M;

Database altered.

SQL> alter database add standby logfile group 7 ('/u02/oradata/netdata/stdredo04.log') size 100M;

Database altered.

SQL> alter system set standby_file_management=auto;

System altered.

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE DISCONNECT FROM SESSION;

Database altered.

主库操作:
SQL> alter system set log_archive_dest_state_2=defer;

系统已更改。

SQL> alter system set log_archive_dest_state_2=enable;

系统已更改。

SQL> insert into netdata.hr values(5555,'sss');

已创建 1 行。

SQL> commit;

提交完成。

备库查看
SQL> select * from netdata.hr;

    ID NAME
---------- --------------------
    33 fdsjk
      1111 mmmfd
      5555 sss
     1 dfs
       999 sss
     88888 mmmm
      1111 mmmfd

7 rows selected.

SQL> select thread#,group#, status from v$standby_log;

   THREAD#     GROUP# STATUS
---------- ---------- ----------
     1        4 ACTIVE
     0        5 UNASSIGNED
     0        6 UNASSIGNED
     0        7 UNASSIGNED

SQL>
创建的原则:
Standby Redo Log 的文件大小与主库 online redo log 文件大小必须相同
Standby Redo Log 日志文件组的个数依照下面的原则进行计算:
Standby redo log组数公式 >= (每个instance日志组个数+1)*instance个数
例如在我的环境中,只有一个节点,这个节点有三组redo,所以
Standby redo log组数公式>=(3+1)*1  == 4
所以需要创建4组Standby redo log
每一日志组为了安全起见,可以做多路镜像;

官方文档关于创建standby log说明

The synchronous and asynchronous redo transport modes require that a redo

transport destination have a standby redo log. A standby redo log is used to store redo

received from another Oracle database. Standby redo logs are structurally identical to

redo logs, and are created and managed using the same SQL statements used to create

and manage redo logs.

Redo received from another Oracle database via redo transport is written to the

current standby redo log group by an RFS foreground process. When a log switch

occurs on the redo source database, incoming redo is then written to the next standby

redo log group, and the previously used standby redo log group is archived by an

ARCn foreground process.

The process of sequentially filling and then archiving redo log file groups at a redo

source database is mirrored at each redo transport destination by the sequential filling

and archiving of standby redo log groups.

Each standby redo log file must be at least as large as the largest redo log file in the

redo log of the redo source database. For administrative ease, Oracle recommends that

all redo log files in the redo log at the redo source database and the standby redo log at

a redo transport destination be of the same size.

The standby redo log must have at least one more redo log group than the redo log at

the redo source database, for each redo thread at the redo source database. At the redo

source database, query the V$LOG view to determine how many redo log groups are in

the redo log at the redo source database and query the V$THREAD view to determine

how many redo threads exist at the redo source database.


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

请登录后发表评论 登录
全部评论

注册时间:2011-08-29

  • 博文量
    110
  • 访问量
    292638