Data Guard 环境下 主备库Redo log 的添加与删除

2024-04-04 03:38

本文主要是介绍Data Guard 环境下 主备库Redo log 的添加与删除,希望对大家解决编程问题提供一定的参考价值,需要的开发者们随着小编来一起学习吧!

 

 

 

       刚搭建完一个Data Gard 环境。 在服务器上弄的,过几天要上生产线。 安装的时候redo 默认了50M 而且standby redo 也是50M 和同事讨论之后,还是把改成100M50M 确实小了点。

       Standby redo的大小要和redo 的一致,所以主备库都要调整。

 

. 主库操作

 

1.1 查看redo 信息

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

    GROUP# TYPE    MEMBER

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

         3 ONLINE  /u01/app/oracle/oradata/xezf/redo03.log

         2 ONLINE  /u01/app/oracle/oradata/xezf/redo02.log

         1 ONLINE  /u01/app/oracle/oradata/xezf/redo01.log

         4 STANDBY /u01/app/oracle/oradata/xezf/redo04.log

         5 STANDBY /u01/app/oracle/oradata/xezf/redo05.log

         6 STANDBY /u01/app/oracle/oradata/xezf/redo06.log

         7 STANDBY /u01/app/oracle/oradata/xezf/redo07.log

7 rows selected.

 

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;  

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 YES INACTIVE                      50

         2          1 NO  CURRENT                       50

         3          1 YES INACTIVE                      50

 

 

1.2 修改standby redo

SQL> alter database drop logfile group 4;

Database altered.

SQL> alter database drop logfile group 5;

Database altered.

SQL> alter database drop logfile group 6;

Database altered.

SQL> alter database drop logfile group 7;

Database altered.

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

    GROUP# TYPE    MEMBER

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

         3 ONLINE  /u01/app/oracle/oradata/xezf/redo03.log

         2 ONLINE  /u01/app/oracle/oradata/xezf/redo02.log

         1 ONLINE  /u01/app/oracle/oradata/xezf/redo01.log

 

添加standby redo

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/u01/app/oracle/oradata/xezf/std_redo04.log') size 100M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/u01/app/oracle/oradata/xezf/std_redo05.log') size 100M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/u01/app/oracle/oradata/xezf/std_redo06.log') size 100M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/u01/app/oracle/oradata/xezf/std_redo07.log') size 100M;

Database altered.

 

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

 

    GROUP# TYPE    MEMBER

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

         3 ONLINE  /u01/app/oracle/oradata/xezf/redo03.log

         2 ONLINE  /u01/app/oracle/oradata/xezf/redo02.log

         1 ONLINE  /u01/app/oracle/oradata/xezf/redo01.log

         4 STANDBY /u01/app/oracle/oradata/xezf/std_redo04.log

         5 STANDBY /u01/app/oracle/oradata/xezf/std_redo05.log

         6 STANDBY /u01/app/oracle/oradata/xezf/std_redo06.log

         7 STANDBY /u01/app/oracle/oradata/xezf/std_redo07.log

 

7 rows selected.

 

1.3 修改Online redo

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;  

 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 YES INACTIVE                      50

         2          1 NO  CURRENT                       50

         3          1 YES INACTIVE                      50

 

先处理inactive 它表示已经完成规定的,可以删除。

 

SQL>  alter database drop logfile group 1;

Database altered.

SQL> alter database drop logfile group 3;

alter database drop logfile group 3

*

ERROR at line 1:

ORA-01567: dropping log 3 would leave less than 2 log files for instance xezf

(thread 1)

ORA-00312: online log 3 thread 1: '/u01/app/oracle/oradata/xezf/redo03.log'

-- 至少要2redo组,看来还是只能慢慢来了。

 

SQL> alter database add logfile  group 1 ('/u01/app/oracle/oradata/xezf/redo01.log') size 100M;    

alter database add logfile  group 1 ('/u01/app/oracle/oradata/xezf/redo01.log') size 100M

*

ERROR at line 1:

ORA-00301: error in adding log file '/u01/app/oracle/oradata/xezf/redo01.log' -

file cannot be created

ORA-27038: created file already exists

Additional information: 1

 

-- 物理文件没有删除,手工的把物理文件删除后,在创建:

SQL> alter database add logfile  group 1 ('/u01/app/oracle/oradata/xezf/redo01.log') size 100M;

Database altered.

 

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;  

 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 YES UNUSED                       100

         2          1 NO  CURRENT                       50

         3          1 YES INACTIVE                      50

 

group1 搞定了。

 

SQL> alter database drop logfile group 3;

Database altered.

 

删除对应的物理文件,在添加

SQL> alter database add logfile  group 3 ('/u01/app/oracle/oradata/xezf/redo03.log') size 100M;

 

Database altered.

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 YES UNUSED                       100

         2          1 NO  CURRENT                       50

         3          1 YES UNUSED                       100

 

group3 搞定。

 

切换一下logfile,在删除group2

 

SQL> alter system switch logfile;

System altered.

SQL>  select group#,thread#,archived,status, bytes/1024/1024 from v$log;

 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 NO  CURRENT                      100

         2          1 YES ACTIVE                        50

       -- group 正在归档,我们等会在看一下

         3          1 YES UNUSED                       100

 

几分钟之后:

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 NO  CURRENT                      100

         2          1 YES INACTIVE                      50

         3          1 YES UNUSED                       100

 

SQL>  alter database drop logfile group 2;

Database altered.

删除物理文件,在创建

SQL> alter database add logfile  group 2 ('/u01/app/oracle/oradata/xezf/redo02.log') size 100M;

Database altered.

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;

 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 NO  CURRENT                      100

         2          1 YES UNUSED                       100

         3          1 YES UNUSED                       100

 

主库搞定。

 

 

. 备库操作

 

2.1 查看信息

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

 

    GROUP# TYPE    MEMBER

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

         3 ONLINE  /u01/app/oracle/oradata/xezf/redo03.log

         2 ONLINE  /u01/app/oracle/oradata/xezf/redo02.log

         1 ONLINE  /u01/app/oracle/oradata/xezf/redo01.log

         4 STANDBY /u01/app/oracle/oradata/xezf/redo04.log

         5 STANDBY /u01/app/oracle/oradata/xezf/redo05.log

         6 STANDBY /u01/app/oracle/oradata/xezf/redo06.log

         7 STANDBY /u01/app/oracle/oradata/xezf/redo07.log

 

7 rows selected.

 

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log; 

 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 YES CLEARING_CURRENT              50

         3          1 YES CLEARING                      50

         2          1 YES CLEARING                      50

 

 

2.2 处理standby redo

 

对于standby redo的处理之前,我们要先停掉redo apply

       SQL> alter database recover managed standby database cancel;

 

不然会报如下错误:

       SQL> alter database drop logfile group 2;

       alter database drop logfile group 2

       *

       ERROR at line 1:

       ORA-01156: recovery in progress may need access to files

 

 

SQL> alter database drop logfile group 4;

Database altered.

SQL> alter database drop logfile group 5;

Database altered.

SQL> alter database drop logfile group 6;

Database altered.

SQL> alter database drop logfile group 7;

Database altered.

 

[oracle@qs-xezf-db2 xezf]$ rm redo04.log

[oracle@qs-xezf-db2 xezf]$ rm redo05.log

[oracle@qs-xezf-db2 xezf]$ rm redo06.log

[oracle@qs-xezf-db2 xezf]$ rm redo07.log

 

 

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 4 ('/u01/app/oracle/oradata/xezf/std_redo04.log') size 100M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 5 ('/u01/app/oracle/oradata/xezf/std_redo05.log') size 100M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 6 ('/u01/app/oracle/oradata/xezf/std_redo06.log') size 100M;

Database altered.

SQL> ALTER DATABASE ADD STANDBY LOGFILE GROUP 7 ('/u01/app/oracle/oradata/xezf/std_redo07.log') size 100M;

Database altered.

 

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

    GROUP# TYPE    MEMBER

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

         3 ONLINE  /u01/app/oracle/oradata/xezf/redo03.log

         2 ONLINE  /u01/app/oracle/oradata/xezf/redo02.log

         1 ONLINE  /u01/app/oracle/oradata/xezf/redo01.log

         4 STANDBY /u01/app/oracle/oradata/xezf/std_redo04.log

         5 STANDBY /u01/app/oracle/oradata/xezf/std_redo05.log

         6 STANDBY /u01/app/oracle/oradata/xezf/std_redo06.log

         7 STANDBY /u01/app/oracle/oradata/xezf/std_redo07.log

 

7 rows selected.

 

2.3 处理online redo

 

先将standby_file_management设为手动:

SQL> alter system set standby_file_management=manual;

System altered.

 

不然会报错:

SQL>  alter database drop logfile group 2;

 alter database drop logfile group 2

*

ERROR at line 1:

ORA-01275: Operation DROP LOGFILE is not allowed if standby file management is automatic.

 

 

Oracle 官网上搜了一下,找到了一篇文章:

 

How to Add/Drop/Resize Redo Log with Physical Standby in place. [ID 473442.1]

http://www.cndba.cn/Dave/article/1437

 

 

SQL> SELECT GROUP#, STATUS FROM V$LOG;

 

    GROUP# STATUS

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

         1 CLEARING_CURRENT

         3 CLEARING

         2 CLEARING

 

SQL>

SQL> alter database clear logfile group 2;

alter database clear logfile group 2

*

ERROR at line 1:

ORA-19527: physical standby redo log must be renamed

ORA-00312: online log 2 thread 1: '/u01/app/oracle/oradata/xezf/redo02.log'

 

 

ORA-19527:

physical standby redo log must be renamed

Cause:

The CLEAR LOGFILE command was used at a physical standby database. This command cannot be used at a physical standby database unless the LOG_FILE_NAME_CONVERT initialization parameter is set. This is required to avoid overwriting the primary database's logfiles.

Action:

Set the LOG_FILE_NAME_CONVERT initialization parameter.

 

我们需要设置LOG_FILE_NAME_CONVERT 参数,才能使用clear logfile命令。 参考:

ORA-00313, ORA-00312, ORA-27037 in Standby Database [ID 601835.1]

http://www.cndba.cn/Dave/article/556

 

 

解决方法如下:

SQL> shutdown immediate

ORA-01109: database not open

Database dismounted.

ORACLE instance shut down.

 

pfile里添加参数:

语法:*.log_file_name_convert = '<location on primary>','<location on standby>'

*.log_file_name_convert ='/u01/app/oracle/oradata/xezf/','/u01/app/oracle/oradata/xezf/'

 

pfile 启动备库:

SQL> startup nomount pfile='/u01/app/oracle/product/10.2.0/db_1/dbs/initxezf.ora';

ORACLE instance started.

 

Total System Global Area 1610612736 bytes

Fixed Size                  2096632 bytes

Variable Size             385876488 bytes

Database Buffers         1207959552 bytes

Redo Buffers               14680064 bytes

SQL> alter database mount standby database;

Database altered.

 

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

 

    GROUP# STATUS

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

         1 CLEARING

         3 CLEARING

         2 CLEARING_CURRENT

 

SQL> show parameter log_file_name_convert

NAME                                 TYPE        VALUE

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

log_file_name_convert                string      /u01/app/oracle/oradata/xezf,                                                /u01/app/oracle/oradata/xezf/

 

SQL> alter database clear logfile group 1;

Database altered.

 

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='MANUAL';

System altered.

 

SQL> alter database drop logfile group 1;

Database altered.

 

删除物理文件:

[oracle@qs-xezf-db2 xezf]$ rm redo01.log

 

创建新的日志组:

SQL> alter database add logfile  group 1 ('/u01/app/oracle/oradata/xezf/redo01.log') size 100M;

Database altered.

 

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

 

    GROUP# STATUS

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

         1 UNUSED

         3 CLEARING

         2 CLEARING_CURRENT

 

处理下一个redo 日志:

SQL> alter database clear logfile group 3;

Database altered.

 

SQL> alter database drop logfile group 3;

Database altered.

 

删除物理文件:

[oracle@qs-xezf-db2 xezf]$ rm redo03.log

 

SQL> alter database add logfile  group 3 ('/u01/app/oracle/oradata/xezf/redo03.log') size 100M;

Database altered.

 

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

 

    GROUP# STATUS

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

         1 UNUSED

         3 UNUSED

         2 CLEARING_CURRENT

 

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log;  

 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 YES UNUSED                       100

         3          1 YES UNUSED                       100

         2          1 YES CLEARING_CURRENT              50

 

还有最后一个redo 组没有处理,这个要先切换过来:

1)在备库启动recover 进程:

SQL> alter database recover managed standby database disconnect from session;

SQL>ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='AUTO';

 

2)到主库手动切换几次redo

SQL> alter system switch logfile;

System altered.

SQL> alter system switch logfile;

System altered.

 

在查看备库的redo

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='MANUAL';

System altered.

 

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

    GROUP# STATUS

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

         1 UNUSED

         3 CLEARING_CURRENT

         2 CLEARING

 

SQL> alter database clear logfile group 2;

Database altered.

 

SQL> alter database drop logfile group 2;

Database altered.

 

物理删除文件:

[oracle@qs-xezf-db2 xezf]$ rm redo02.log

 

添加redo

SQL> alter database add logfile  group 2 ('/u01/app/oracle/oradata/xezf/redo02.log') size 100M;

Database altered.

 

查看:

SQL> select group#,thread#,archived,status, bytes/1024/1024 from v$log; 

    GROUP#    THREAD# ARC STATUS           BYTES/1024/1024

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

         1          1 YES UNUSED                       100

         3          1 YES CLEARING_CURRENT             100

         2          1 YES UNUSED                       100

 

搞定,最后启动recover,验证:

SQL> ALTER SYSTEM SET STANDBY_FILE_MANAGEMENT='AUTO';

System altered.

 

SQL> alter database recover managed standby database disconnect from session;

Database altered.

 

主库:

SQL> alter system switch logfile;

System altered.

 

SQL> alter system switch logfile;                           

System altered.

 

SQL> select max(sequence#) from v$archived_log;

MAX(SEQUENCE#)

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

            15

 

备库:

SQL> select sequence#,applied from v$archived_log;

 SEQUENCE# APP

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

         2 YES

         3 YES

         5 YES

         4 YES

         7 YES

         6 YES

         8 YES

         9 YES

        13 YES

        10 YES

        11 YES

 SEQUENCE# APP

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

        12 YES

        14 YES

        15 YES

 

14 rows selected.

 

同步正常。 ok

 

 

 

 

 

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

QQ:492913789

Email:ahdba@qq.com

Blog: http://www.cndba.cn/dave 


网上资源: http://tianlesoftware.download.csdn.net

相关视频:http://blog.csdn.net/tianlesoftware/archive/2009/11/27/4886500.aspx

DBA1 群:62697716(); DBA2 群:62697977()

DBA3 群:62697850   DBA 超级群:63306533;    

聊天 群:40132017

--加群需要在备注说明Oracle表空间和数据文件的关系,否则拒绝申请

 

这篇关于Data Guard 环境下 主备库Redo log 的添加与删除的文章就介绍到这儿,希望我们推荐的文章对编程师们有所帮助!



http://www.chinasem.cn/article/874711

相关文章

电脑桌面文件删除了怎么找回来?别急,快速恢复攻略在此

在日常使用电脑的过程中,我们经常会遇到这样的情况:一不小心,桌面上的某个重要文件被删除了。这时,大多数人可能会感到惊慌失措,不知所措。 其实,不必过于担心,因为有很多方法可以帮助我们找回被删除的桌面文件。下面,就让我们一起来了解一下这些恢复桌面文件的方法吧。 一、使用撤销操作 如果我们刚刚删除了桌面上的文件,并且还没有进行其他操作,那么可以尝试使用撤销操作来恢复文件。在键盘上同时按下“C

阿里开源语音识别SenseVoiceWindows环境部署

SenseVoice介绍 SenseVoice 专注于高精度多语言语音识别、情感辨识和音频事件检测多语言识别: 采用超过 40 万小时数据训练,支持超过 50 种语言,识别效果上优于 Whisper 模型。富文本识别:具备优秀的情感识别,能够在测试数据上达到和超过目前最佳情感识别模型的效果。支持声音事件检测能力,支持音乐、掌声、笑声、哭声、咳嗽、喷嚏等多种常见人机交互事件进行检测。高效推

内核启动时减少log的方式

内核引导选项 内核引导选项大体上可以分为两类:一类与设备无关、另一类与设备有关。与设备有关的引导选项多如牛毛,需要你自己阅读内核中的相应驱动程序源码以获取其能够接受的引导选项。比如,如果你想知道可以向 AHA1542 SCSI 驱动程序传递哪些引导选项,那么就查看 drivers/scsi/aha1542.c 文件,一般在前面 100 行注释里就可以找到所接受的引导选项说明。大多数选项是通过"_

安装nodejs环境

本文介绍了如何通过nvm(NodeVersionManager)安装和管理Node.js及npm的不同版本,包括下载安装脚本、检查版本并安装特定版本的方法。 1、安装nvm curl -o- https://raw.githubusercontent.com/nvm-sh/nvm/v0.39.0/install.sh | bash 2、查看nvm版本 nvm --version 3、安装

【IPV6从入门到起飞】5-1 IPV6+Home Assistant(搭建基本环境)

【IPV6从入门到起飞】5-1 IPV6+Home Assistant #搭建基本环境 1 背景2 docker下载 hass3 创建容器4 浏览器访问 hass5 手机APP远程访问hass6 更多玩法 1 背景 既然电脑可以IPV6入站,手机流量可以访问IPV6网络的服务,为什么不在电脑搭建Home Assistant(hass),来控制你的设备呢?@智能家居 @万物互联

高并发环境中保持幂等性

在高并发环境中保持幂等性是一项重要的挑战。幂等性指的是无论操作执行多少次,其效果都是相同的。确保操作的幂等性可以避免重复执行带来的副作用。以下是一些保持幂等性的常用方法: 唯一标识符: 请求唯一标识:在每次请求中引入唯一标识符(如 UUID 或者生成的唯一 ID),在处理请求时,系统可以检查这个标识符是否已经处理过,如果是,则忽略重复请求。幂等键(Idempotency Key):客户端在每次

pico2 开发环境搭建-基于ubuntu

pico2 开发环境搭建-基于ubuntu 安装编译工具链下载sdk 和example编译example 安装编译工具链 sudo apt install cmake gcc-arm-none-eabi libnewlib-arm-none-eabi libstdc++-arm-none-eabi-newlib 注意cmake的版本,需要在3.17 以上 下载sdk 和ex

pip-tools:打造可重复、可控的 Python 开发环境,解决依赖关系,让代码更稳定

在 Python 开发中,管理依赖关系是一项繁琐且容易出错的任务。手动更新依赖版本、处理冲突、确保一致性等等,都可能让开发者感到头疼。而 pip-tools 为开发者提供了一套稳定可靠的解决方案。 什么是 pip-tools? pip-tools 是一组命令行工具,旨在简化 Python 依赖关系的管理,确保项目环境的稳定性和可重复性。它主要包含两个核心工具:pip-compile 和 pip

论文翻译:arxiv-2024 Benchmark Data Contamination of Large Language Models: A Survey

Benchmark Data Contamination of Large Language Models: A Survey https://arxiv.org/abs/2406.04244 大规模语言模型的基准数据污染:一项综述 文章目录 大规模语言模型的基准数据污染:一项综述摘要1 引言 摘要 大规模语言模型(LLMs),如GPT-4、Claude-3和Gemini的快

跨系统环境下LabVIEW程序稳定运行

在LabVIEW开发中,不同电脑的配置和操作系统(如Win11与Win7)可能对程序的稳定运行产生影响。为了确保程序在不同平台上都能正常且稳定运行,需要从兼容性、驱动、以及性能优化等多个方面入手。本文将详细介绍如何在不同系统环境下,使LabVIEW开发的程序保持稳定运行的有效策略。 LabVIEW版本兼容性 LabVIEW各版本对不同操作系统的支持存在差异。因此,在开发程序时,尽量使用