我是靠谱客的博主 虚心发箍,最近开发中收集的这篇文章主要介绍Data Guard启动实时日志应用,觉得挺不错的,现在分享给大家,希望可以做个参考。

概述

1. REDO数据实时应用

启动实时应用的优势在于,REDO数据不需要等待归档完成,接收到即可被应用,这样执行角色切换时,操作能够执行得更快,因为日志是被即时应用的。

要启动实时应用也简单,前提是Standby数据库端配置了Standby Redologs。

物理Standby要启用实时应用,要在启动REDO应用的语句后附加USING CURRENT LOGFIE子句,例如:

SQL> ALTER DATABASE RECOVER MANAGED STANDBY DATABASE USING CURRENT LOGFILE ; 

2. 启动实时应用redo日志操作

2.1添加standby redo log

首先查询当前redo log的大小、位置;Standby redo的大小要和redo 的一致

primary>col status format 'a10'
primary>select group#,thread#,archived,status, bytes/1024/1024 from v$log;
GROUP#
THREAD# ARCHIVED
STATUS
BYTES/1024/1024
---------- ---------- --------- ---------- ---------------
1
1 YES
INACTIVE
50
2
1 NO
CURRENT
50
3
1 YES
INACTIVE
50
primary>col member format 'a35';
primary>select group#,type, member from v$logfile;
GROUP# TYPE
MEMBER
---------- --------------------- -----------------------------------
1 ONLINE
/u01/app/oradata/ora234/redo01.log
2 ONLINE
/u01/app/oradata/ora234/redo02.log
3 ONLINE
/u01/app/oradata/ora234/redo03.log

添加standby redo 操作;主库/备库都操作;
主库操作原因;当发生故障;主备库发生切换;减少切换过程操作

主库操作
primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/home/oracle/oradata/redolog/std_redo04.log') size 50M;
Database altered.
primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/home/oracle/oradata/redolog/std_redo05.log') size 50M;
Database altered.
primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/home/oracle/oradata/redolog/std_redo06.log') size 50M;
Database altered.
primary> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/home/oracle/oradata/redolog/std_redo07.log') size 50M;
Database altered.
备库操作
standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/home/oracle/oradata/redolog/std_redo04.log') size 50M;
Database altered.
standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/home/oracle/oradata/redolog/std_redo05.log') size 50M;
Database altered.
standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/home/oracle/oradata/redolog/std_redo06.log') size 50M;
Database altered.
standby> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/home/oracle/oradata/redolog/std_redo07.log') size 50M;
Database altered.

2.2修改主备库参数;

启动实时应用日志;需采用lgwr模式;即应用redolog。不再是archivelog

primary>alter system set LOG_ARCHIVE_DEST_2='SERVICE=tns_standby LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db_standby' ;
System altered.
standby>alter system set log_archive_dest_2='SERVICE=tns_primary LGWR VALID_FOR=(ONLINE_LOGFILES,PRIMARY_ROLE) DB_UNIQUE_NAME=db_primary';
System altered.

2.3启用实时StandBy端redo应用

StandBy>alter database recover managed standby database using current logfile disconnect from session;
取消实时应用:alter database recover managed standby database cancel;

2.4验证结果

primary>truncate table t;
Table truncated.
primary>insert into t values (1000);
1 row created.
primary>commit;
Commit complete.
standby>select * from t;
no rows selected
standby>select * from t;
ID
----------
1000

最后

以上就是虚心发箍为你收集整理的Data Guard启动实时日志应用的全部内容,希望文章能够帮你解决Data Guard启动实时日志应用所遇到的程序开发问题。

如果觉得靠谱客网站的内容还不错,欢迎将靠谱客网站推荐给程序员好友。

本图文内容来源于网友提供,作为学习参考使用,或来自网络收集整理,版权属于原作者所有。
点赞(43)

评论列表共有 0 条评论

立即
投稿
返回
顶部