首页 » ORACLE 9i-23c » 为什么oracle standby database需要standby log? 为什么需要比主库online redo多一组?

为什么oracle standby database需要standby log? 为什么需要比主库online redo多一组?

很多时候我们在安装配置oracle dataguard时,需要在standby db 增加standby log, 但是有一些限制,如standby log file size和主库的online redo log size相同, standby log每个thread要比主库的online redo log要多1组,为什么需要standby log?为什么会有这样的要求呢?

redo log transfer

在主数据库上,Oracle Data Guard 使用 Log Writer Process (LGWR) 或 Archiver Process (ARCH) 或 Log Writer Network Server Process (LNSn) ,Redo Transport NSA1 Process(NSA)、Redo Transport NSS1 Process(NSS)来收集事务重做数据并将此数据传送到备用数据库, LNSn 可以在 11g 数据库中发送redo , 12c用于 ASYNC 传输的新进程 NSA 和用于 SYNC 传输的 NSS。在备用数据库上,Oracle Data Guard 使用远程文件服务器 (RFS) 进程从主数据库接收REDO LOG,使用托管恢复进程 (MRP) 将重做信息/恢复应用到物理备用数据库。

为什么我们需要备用站点的Standby redo log文件?

在备用站点没有备用重做日志文件时,一旦在主数据库上生成Archivelog 文件,它们就会立即从主数据库传送到备用数据库,然后 MRP 读取它并将redo数据应用到物理备用数据库. 主数据库Redo log文件中的“current” redo log(由 LGWR 进程写入)将保留在主站点。由于主站点上没有为redo log文件中的数据生成archivelog文件,因此该数据不会应用于备用站点,并且在主站点丢失的情况下,备用站点将永远丢失数据。为了避免这种情况,备用站点上的Standby Redo log文件可以帮助我们。

Data Guard 将主节点的current redo log 写入备库“standby redo log”,以便在主站点丢失时完全恢复。可以使用同步 (LGWR SYNC) 或异步重做传输 (LGWR ASYNC) 写入standby redo log文件。
in Dataguard(without Active Dataguard realtime apply), Standby redo logs must be archived on standby database before the data can be applied to the standby database. The standby archival operation occurs automatically, even if the standby database is not in ARCHIVELOG mode. However, the archiver process (ARCn) must be started on the standby database.
ADG模式可以实时应用standby redo log,如果没有ADG license或未实时应用启动时,需要等待standby redo log 归档后应用。
When archiving to a physical standby destination using the LGWR process, changes (transactions) being made and committed on the primary database are not instantly written to the actual database files on the standby database. In Oracle9i Release 2 and higher, when log transport services is configured for Maximum Availability mode or Maximum Protection mode, the LGWR process on the primary database will send redo data to the standby redo logs (located on the standby database) at the same time it is writing redo data to the local (online) redo logs. Keep in mind that the LGWR process is actually communicating with a Remote File Server (RFS) process on the standby database server. This RFS process on the standby database is responsible for capturing and writing the redo data it obtains from the primary database to the standby redo logs (LGWR) or the standby archived redo logs (ARCn).
When a log switch occurs on the primary database, a log switch is also triggered on the standby database where the ARCH process then archives the standby redo logs to the archive destination specified on the standby database.
当在主库上做log switch 时也会级联触发备库的standby log switch, 但是注意standby log file并不是和主库一样滚动使用redo 组号,如swtich group# 1 to group#2 to group#3 …,  有时你会发现standby log它只是在group#1 和group#2 之前切换,即使主库和备库日志组有10组。

在 Oracle9i 中,仅当主数据库上发生日志切换时,MRP进程应用备库从standby log 生成的归档日志,才会对备用数据库上的实际数据库文件进行这些更改。在 Oracle 数据库 10g 中,可以启用一个称为实时应用的新特性,它告诉日志应用服务在收到重做数据时将其应用到备用数据库上的数据库文件,而无需等待当前备用重做日志文件归档 . 这导致更快的切换和故障切换时间,因为在故障切换或切换开始时,备用重做日志文件已经应用到备用数据库。 在oracle 数据库11g中,数据库可以在open read only的状态下,继续实时应用,称为ADG.

简而言之,standby redo log与主库的online redo log一样快地填充重做信息,Standby Redo Logs (SRL) 和 Online Redo Log (ORL)不同是 Standby Redo Log是用来存储redo data接受来自 another database (primary database). 同dataguard standby mrp应用日志时不用等待主库online redo log被归档并传送到备库,可以实时同步online redo log变化(取决于DG保护模式),因此,故障转移事件中的数据丢失被最小化。

为什么需要比主库online redo多一组?
这个问题在freelists多年前有提问过,像Yong Huang提到的如果你有2组redo group,如果LGWR主刚刚完成# 1,switch用# 2,在用完#2 redo时再重用redo #1时,standby db必须跟上,否则主LGWR不能重用# 1,因为standby db正在archiving or appling standby log# 1。如果您有standby log #3,那么在standby db 在standby redo log #1 还在archving或appling时开始使用#3,这样主服务器就可以毫不延迟地重用主服务器的#1。
在redo logfile size小,大量DML分配更多的redo, 测试redo快速切换时,可以模拟出standby redo log使用组数增加的现象。

可以理解在备库中建议standby log 比主库多一组,是为了防止standby 日志switch跟不上主库的switch 写入速度时而产生的积压, 影响了同步的实时性,并非强制而是建议,建议增加一个 SRL 组是为了最大程度的保护.

 

— over —

打赏

,

对不起,这篇文章暂时关闭评论。