search
HomeDatabaseMysql TutorialOracle Dataguard Standby Redo Log的两个实验

在Data Guard环境中,Standby Redo Log是一个比较特殊的日志类型。从最新的DG安装指导中,都推荐在Primary和Standby端,都配置St

在Data Guard环境中,Standby Redo Log是一个比较特殊的日志类型。从最新的DG安装指导中,都推荐在Primary和Standby端,都配置Standby Redo Log。
 
简单的说,Standby Redo Log就是在Standby端应用传递Redo Log过程中,逐步执行的online redo log。Standby端虽然也有online redo log,但是在redo apply应用的过程中,是不使用online redo log的。即使是11g Active Data Guard支持apply中读取standby数据,这个操作也是read-only的,并不涉及当前实例redo log的生成(注意是生成)。所以,如果一直是在Standby角色,online redo log是不需要的。
 
Primary传递过来的redo log信息,是存放在standby redo log组内进行apply的。并且随着主库Primary日志的切换动作而切换。这也就是为什么推荐standby redo log的大小和Primary online redo log的大小保持一致的原因。
 
下面会从维护角度,讨论Standby Redo log维护过程中的方法。

--------------------------------------分割线 --------------------------------------

相关参考:

Oracle Data Guard 重要配置参数

基于同一主机配置 Oracle 11g Data Guard

探索Oracle之11g DataGuard

Oracle Data Guard (RAC+DG) 归档删除策略及脚本

Oracle Data Guard 的角色转换

Oracle Data Guard的日志FAL gap问题

Oracle 11g Data Guard Error 16143 Heartbeat failed to connect to standby 处理方法

--------------------------------------分割线 --------------------------------------

1、环境介绍

 

数据库版本为11.2.0.4,已经构建好DG环境。Primary数据库实例名ora11g。

 

SQL> select name, DATABASE_ROLE from v$database;

 

NAME      DATABASE_ROLE

--------- ----------------

ORA11G    PRIMARY

 

Primary上也是需要配置standby redo log的。但是,这个redo log和Standby端的online redo log一样,都是在角色switch/failover之后,才会发挥作用。
 
 

SQL> col dbid for a20;

SQL> select group#, dbid, sequence#, archived, status from v$standby_log;

 

    GROUP# DBID                  SEQUENCE# ARCHIVED STATUS

---------- -------------------- ---------- -------- ----------

        4 UNASSIGNED                    0 YES      UNASSIGNED

        5 UNASSIGNED                    0 YES      UNASSIGNED

        6 UNASSIGNED                    0 YES      UNASSIGNED

 

文件自动管理参数设置为Auto。

 

SQL> show parameter standby_file

 

NAME                                TYPE        VALUE

------------------------------------ ----------- ------------------------------

standby_file_management              string      AUTO

 

2、Primary端Standby Redo Log配置

 

Primary角色下,Standby Redo Log是不使用的。原则上也没有什么特殊的用途。所以,我们查看v$standby_log视图时查看到的Primary端状态都是unsigned,也就是没有使用。
 
在Primary正常Read Write状态下,,我们是可以添加standby log group的。

 

SQL> alter database add standby logfile group 8 size 100m;

Database altered

 

SQL> select group#, dbid, sequence#, archived, status from v$standby_log;

 

    GROUP# DBID                  SEQUENCE# ARCHIVED STATUS

---------- -------------------- ---------- -------- ----------

        4 UNASSIGNED                    0 YES      UNASSIGNED

        5 UNASSIGNED                    0 YES      UNASSIGNED

        6 UNASSIGNED                    0 YES      UNASSIGNED

        8 UNASSIGNED                    0 YES      UNASSIGNED

 

在v$logfile中,可以看到对应的添加文件。由于使用的OMF特性,创建成员组为两个,在recovery area中有对应镜像。

 

SQL> select group#, type, member from v$logfile;

 

    GROUP# TYPE    MEMBER

---------- ------- --------------------------------------------------------------------------------
 
        (篇幅原因,有省略……)

        7 ONLINE  /u01/app/fast_recovery_area/ORA11G/onlinelog/o1_mf_7_9pclt1lt_.log
 
        8 STANDBY /u01/app/oradata/ORA11G/onlinelog/o1_mf_8_9pgqt9hg_.log

        8 STANDBY /u01/app/fast_recovery_area/ORA11G/onlinelog/o1_mf_8_9pgqtcgj_.log
 
 

16 rows selected

 

在standby端,我们查看是否有对应standby redo log自动添加。

 

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

 

    GROUP#  SEQUENCE# DBID                STATUS

---------- ---------- -------------------- ----------

        4        34 4239941846          ACTIVE

        5          0 UNASSIGNED          UNASSIGNED

        6          0 UNASSIGNED          UNASSIGNED

 

Primary端删除standby redo log。

 

SQL> alter database drop standby logfile group 8;

Database altered

 

SQL> select group#, dbid, sequence#, archived, status from v$standby_log;

 

    GROUP# DBID                  SEQUENCE# ARCHIVED STATUS

---------- -------------------- ---------- -------- ----------

        4 UNASSIGNED                    0 YES      UNASSIGNED

        5 UNASSIGNED                    0 YES      UNASSIGNED

        6 UNASSIGNED                    0 YES      UNASSIGNED

 

从实验情况看:在Primary端,我们进行standby redo log的管理是比较方便的。没有过多的限制。

 

3、Standby端Standby Redo Log维护

 

当前Primary端的Online Redo Log情况。

 

SQL> select group#, sequence#, bytes, status from v$log;

 

    GROUP#  SEQUENCE#      BYTES STATUS

---------- ---------- ---------- ----------------

        1        32  104857600 INACTIVE

        2        34  52428800 INACTIVE

        3        35  52428800 CURRENT

        7        33  10485760 INACTIVE

 

此时,standby端的standby redo log情况如下:

 

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

 

    GROUP#  SEQUENCE# DBID                STATUS

---------- ---------- -------------------- ----------

        4        35 4239941846          ACTIVE

        5          0 UNASSIGNED          UNASSIGNED

        6          0 UNASSIGNED          UNASSIGNED

 

standby redo log对应的是当前Primary的online current redo log。反映在sequence#相同。我们尝试直接添加standby日志。
 
 

SQL> alter database add standby logfile group 8 size 100m;

alter database add standby logfile group 8 size 100m

 

ORA-01156: 进行中的恢复或闪回可能需要访问文件

 

当前standby处在apply过程,终止apply动作。

 

 

SQL> alter database recover managed standby database cancel;

Database altered

 

SQL> alter database add standby logfile group 8 size 100m;

Database altered

 

standby redo log日志情况。

 

SQL> select group#, dbid, sequence#, archived, status from v$standby_log;

 

    GROUP# DBID                  SEQUENCE# ARCHIVED STATUS

---------- -------------------- ---------- -------- ----------

        4 4239941846                  35 YES      ACTIVE

        5 UNASSIGNED                    0 NO      UNASSIGNED

        6 UNASSIGNED                    0 NO      UNASSIGNED

        8 UNASSIGNED                    0 YES      UNASSIGNED

 

之后可以启动redo apply过程。

 

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

更多详情见请继续阅读下一页的精彩内容:

linux

Statement
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn
MySQL: BLOB and other no-sql storage, what are the differences?MySQL: BLOB and other no-sql storage, what are the differences?May 13, 2025 am 12:14 AM

MySQL'sBLOBissuitableforstoringbinarydatawithinarelationaldatabase,whileNoSQLoptionslikeMongoDB,Redis,andCassandraofferflexible,scalablesolutionsforunstructureddata.BLOBissimplerbutcanslowdownperformancewithlargedata;NoSQLprovidesbetterscalabilityand

MySQL Add User: Syntax, Options, and Security Best PracticesMySQL Add User: Syntax, Options, and Security Best PracticesMay 13, 2025 am 12:12 AM

ToaddauserinMySQL,use:CREATEUSER'username'@'host'IDENTIFIEDBY'password';Here'showtodoitsecurely:1)Choosethehostcarefullytocontrolaccess.2)SetresourcelimitswithoptionslikeMAX_QUERIES_PER_HOUR.3)Usestrong,uniquepasswords.4)EnforceSSL/TLSconnectionswith

MySQL: How to avoid String Data Types common mistakes?MySQL: How to avoid String Data Types common mistakes?May 13, 2025 am 12:09 AM

ToavoidcommonmistakeswithstringdatatypesinMySQL,understandstringtypenuances,choosetherighttype,andmanageencodingandcollationsettingseffectively.1)UseCHARforfixed-lengthstrings,VARCHARforvariable-length,andTEXT/BLOBforlargerdata.2)Setcorrectcharacters

MySQL: String Data Types and ENUMs?MySQL: String Data Types and ENUMs?May 13, 2025 am 12:05 AM

MySQloffersechar, Varchar, text, Anddenumforstringdata.usecharforfixed-Lengthstrings, VarcharerForvariable-Length, text forlarger text, AndenumforenforcingdataAntegritywithaetofvalues.

MySQL BLOB: how to optimize BLOBs requestsMySQL BLOB: how to optimize BLOBs requestsMay 13, 2025 am 12:03 AM

Optimizing MySQLBLOB requests can be done through the following strategies: 1. Reduce the frequency of BLOB query, use independent requests or delay loading; 2. Select the appropriate BLOB type (such as TINYBLOB); 3. Separate the BLOB data into separate tables; 4. Compress the BLOB data at the application layer; 5. Index the BLOB metadata. These methods can effectively improve performance by combining monitoring, caching and data sharding in actual applications.

Adding Users to MySQL: The Complete TutorialAdding Users to MySQL: The Complete TutorialMay 12, 2025 am 12:14 AM

Mastering the method of adding MySQL users is crucial for database administrators and developers because it ensures the security and access control of the database. 1) Create a new user using the CREATEUSER command, 2) Assign permissions through the GRANT command, 3) Use FLUSHPRIVILEGES to ensure permissions take effect, 4) Regularly audit and clean user accounts to maintain performance and security.

Mastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMastering MySQL String Data Types: VARCHAR vs. TEXT vs. CHARMay 12, 2025 am 12:12 AM

ChooseCHARforfixed-lengthdata,VARCHARforvariable-lengthdata,andTEXTforlargetextfields.1)CHARisefficientforconsistent-lengthdatalikecodes.2)VARCHARsuitsvariable-lengthdatalikenames,balancingflexibilityandperformance.3)TEXTisidealforlargetextslikeartic

MySQL: String Data Types and Indexing: Best PracticesMySQL: String Data Types and Indexing: Best PracticesMay 12, 2025 am 12:11 AM

Best practices for handling string data types and indexes in MySQL include: 1) Selecting the appropriate string type, such as CHAR for fixed length, VARCHAR for variable length, and TEXT for large text; 2) Be cautious in indexing, avoid over-indexing, and create indexes for common queries; 3) Use prefix indexes and full-text indexes to optimize long string searches; 4) Regularly monitor and optimize indexes to keep indexes small and efficient. Through these methods, we can balance read and write performance and improve database efficiency.

See all articles

Hot AI Tools

Undresser.AI Undress

Undresser.AI Undress

AI-powered app for creating realistic nude photos

AI Clothes Remover

AI Clothes Remover

Online AI tool for removing clothes from photos.

Undress AI Tool

Undress AI Tool

Undress images for free

Clothoff.io

Clothoff.io

AI clothes remover

Video Face Swap

Video Face Swap

Swap faces in any video effortlessly with our completely free AI face swap tool!

Hot Article

Hot Tools

Dreamweaver Mac version

Dreamweaver Mac version

Visual web development tools

SublimeText3 Mac version

SublimeText3 Mac version

God-level code editing software (SublimeText3)

EditPlus Chinese cracked version

EditPlus Chinese cracked version

Small size, syntax highlighting, does not support code prompt function

MinGW - Minimalist GNU for Windows

MinGW - Minimalist GNU for Windows

This project is in the process of being migrated to osdn.net/projects/mingw, you can continue to follow us there. MinGW: A native Windows port of the GNU Compiler Collection (GCC), freely distributable import libraries and header files for building native Windows applications; includes extensions to the MSVC runtime to support C99 functionality. All MinGW software can run on 64-bit Windows platforms.

SecLists

SecLists

SecLists is the ultimate security tester's companion. It is a collection of various types of lists that are frequently used during security assessments, all in one place. SecLists helps make security testing more efficient and productive by conveniently providing all the lists a security tester might need. List types include usernames, passwords, URLs, fuzzing payloads, sensitive data patterns, web shells, and more. The tester can simply pull this repository onto a new test machine and he will have access to every type of list he needs.