Oracle 11g rac + Dataguard 环境调整 redo log 大小

news2025/1/10 2:46:32

Oracle 11g rac + Dataguard 环境调整 redo log 大小

目录

  • Oracle 11g rac + Dataguard 环境调整 redo log 大小
    • 一、问题的产生
        • 1、查看日志文件、日志组信息
        • 2、日志切换较快出现的问题
    • 二、 确认 DG 同步是否正常
        • 1、检查数据库角色
        • 2、查看进程信息
        • 3、检查归档是否一致
        • 4、查看 GAP 是否有延迟
    • 三、在主库上重建 redo log file
        • 1、查看 redo 日志组及大小
        • 2、在主库删除 standby log
        • 3、在主库替换 redo log
        • 4、主库添加 standby log
    • 四、在备库上重建 standby log
        • 步骤1:查看 redo 日志组及大小
        • 步骤2:备库取消日志应用
        • 步骤3:修改日志管理模式为手动
        • 步骤4:删除备库 standby log
        • 步骤5:备库新建 standby log
        • 步骤6:主库切日志,将临时`standby logfile`切到`UNASSIGNED`状态,然后删除:
        • 步骤7:打开实时应用日志和自动日志管理
        • 步骤8:重新启动备库,查看数据同步情况

一、问题的产生

客户的生产库为 Oracle 11g rac双节点集群,并且配置有Dataguard,近期业务出现卡顿,检查发现日志文件异常,系统一共配置6redo log1号线程与2号线程各3组,每个日志文件的大小为100MB)与8standby log1号线程与2号线程各4组)。

1、查看日志文件、日志组信息

(1)日志文件信息

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE MEMBER   IS_
-----------------------------------------------------------------------------------
	 1	   ONLINE  +DATA/hisdb/onlinelog/redo01.log  NO
	 2	   ONLINE  +DATA/hisdb/onlinelog/redo02.log  NO
	 4	   ONLINE  +DATA/hisdb/onlinelog/redo04.log  NO
	 5	   ONLINE  +DATA/hisdb/onlinelog/redo05.log  NO
	 6	   ONLINE  +DATA/hisdb/onlinelog/redo06.log  NO
	 3	   ONLINE  +DATA/hisdb/onlinelog/redo03.log  NO
	 7	   STANDBY  +DATA/hisdb/onlinelog/group_7.446.1121009477   NO
	 8	   STANDBY  +DATA/hisdb/onlinelog/group_8.447.1121009483   NO
	 9	   STANDBY  +DATA/hisdb/onlinelog/group_9.448.1121009489   NO
	10	   STANDBY  +DATA/hisdb/onlinelog/group_10.449.1121009493  NO
	11	   STANDBY  +DATA/hisdb/onlinelog/group_11.450.1121009499  NO
	12	   STANDBY  +DATA/hisdb/onlinelog/group_12.451.1121009507  NO
	13	   STANDBY  +DATA/hisdb/onlinelog/group_13.452.1121009507  NO
	14	   STANDBY  +DATA/hisdb/onlinelog/group_14.453.1121009507  NO
14 rows selected.

(2)日志组信息

SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS  FIRST_CHANGE# FIRST_TIME
------------- ---------------------- ---------- ---------- ---------- ---------- --- ----------
	 1	    2	  114460	100	     1 YES ACTIVE    9057709636 03-JAN-25
	 2	    2	  114461	100	     1 YES ACTIVE    9057751045 03-JAN-25
	 3	    2	  114462	100	     1 NO  CURRENT   9057800557 03-JAN-25
	 4	    1	  324121	100	     1 YES ACTIVE    9057794541 03-JAN-25
	 5	    1	  324122	100	     1 NO  CURRENT   9057807196 03-JAN-25
	 6	    1	  324120	100	     1 YES ACTIVE   9057790272 03-JAN-25
6 rows selected.

(3)standby log信息

SQL> select group#,thread#,round(bytes/1024/1024,2) size_mb,status from v$standby_log;

    GROUP#    THREAD#	 SIZE_MB STATUS
---------- ---------- ---------- ----------
	 7	    1	     100 UNASSIGNED
	 8	    1	     100 UNASSIGNED
	 9	    1	     100 UNASSIGNED
	10	    1	     100 UNASSIGNED
	11	    2	     100 UNASSIGNED
	12	    2	     100 UNASSIGNED
	13	    2	     100 UNASSIGNED
	14	    2	     100 UNASSIGNED
8 rows selected.
2、日志切换较快出现的问题

频繁的日志切换会增加CPUI/O负载,因为每次切换都需要更新控制文件和数据字典,并且产生新的归档。

日志组循环写满以后,LGWR进程要覆盖先前的日志文件,如果未完成归档会导致无法切换,出现等待,数据库将陷于停顿状态,直到要覆盖的日志文件完成归档。

在生产环境中,设置一个相对合理的redo log大小是十分重要的,可以提升数据库的整体性能,减轻系统I/O负担,数据库恢复时间合理。

理想性状态下,平均一个小时切换2-4次较为合理。

使用以下脚本可以查看日志每小时切换次数,平均每小时2-4次合适,也就是15-30分钟切一次日志。

set linesize 120
set pagesize 100
column  day     format a15              heading 'Day'
column  d_0     format a3               heading '00'
column  d_1     format a3               heading '01'
column  d_2     format a3               heading '02'
column  d_3     format a3               heading '03'
column  d_4     format a3               heading '04'
column  d_5     format a3               heading '05'
column  d_6     format a3               heading '06'
column  d_7     format a3               heading '07'
column  d_8     format a3               heading '08'
column  d_9     format a3               heading '09'
column  d_10    format a3               heading '10'
column  d_11    format a3               heading '11'
column  d_12    format a3               heading '12'
column  d_13    format a3               heading '13'
column  d_14    format a3               heading '14'
column  d_15    format a3               heading '15'
column  d_16    format a3               heading '16'
column  d_17    format a3               heading '17'
column  d_18    format a3               heading '18'
column  d_19    format a3               heading '19'
column  d_20    format a3               heading '20'
column  d_21    format a3               heading '21'
column  d_22    format a3               heading '22'
column  d_23    format a3               heading '23'
select
        substr(to_char(FIRST_TIME,'YYYY/MM/DD,DY'),1,15) day,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'00',1,0))) d_0,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'01',1,0))) d_1,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'02',1,0))) d_2,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'03',1,0))) d_3,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'04',1,0))) d_4,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'05',1,0))) d_5,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'06',1,0))) d_6,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'07',1,0))) d_7,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'08',1,0))) d_8,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'09',1,0))) d_9,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'10',1,0))) d_10,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'11',1,0))) d_11,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'12',1,0))) d_12,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'13',1,0))) d_13,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'14',1,0))) d_14,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'15',1,0))) d_15,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'16',1,0))) d_16,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'17',1,0))) d_17,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'18',1,0))) d_18,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'19',1,0))) d_19,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'20',1,0))) d_20,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'21',1,0))) d_21,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'22',1,0))) d_22,
        decode(sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0)),0,'-',sum(decode(substr(to_char(FIRST_TIME,'HH24'),1,2),'23',1,0))) d_23
from
        gv$log_history where first_time> sysdate-60
group by
        substr(to_char(FIRST_TIME,'YYYY/MM/DD,DY'),1,15)
order by
        substr(to_char(FIRST_TIME,'YYYY/MM/DD,DY'),1,15) desc;
        
-- 运行结果如下:
Day	00  01	02  03	04  05	06  07	08  09	10  11	12  13	14  15	16  17	18  19	20  21	22  23
------- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- --- ---
2025/01/02,THU	-   -	-   -	-   -	1   -	-   -	-   -	-   -	5   -	-   -	-   -	-   -	1   -
2025/01/01,WED	-   -	-   -	1   -	-   -	-   -	-   -	-   -	-   -	-   2	-   1	1   1	-   -
2024/12/31,TUE	-   -	-   -	-   -	-   -	-   -	-   -	-   -	-   -	1   -	-   -	-   -	-   -
2024/12/30,MON	-   -	-   -	-   -	-   -	-   -	-   -	-   -	-   -	-   -	-   -	-   4	2   -

经过分析日志的切换频率,拟把日志文件大小扩容为1024MB,操作步骤如下:

二、 确认 DG 同步是否正常

1、检查数据库角色
--主库
SQL> select db_unique_name, open_mode, switchover_status, database_role from v$database;

DB_UNIQUE_NAME		       OPEN_MODE	    SWITCHOVER_STATUS   DATABASE_ROLE
---------------------------------------------- -------------------- --------------------
HISDB			       READ WRITE	    SESSIONS ACTIVE          PRIMARY

--备库
SQL> select db_unique_name, open_mode, switchover_status, database_role from v$database;

DB_UNIQUE_NAME		       OPEN_MODE	    SWITCHOVER_STATUS   DATABASE_ROLE
---------------------------------------------- -------------------- --------------------
DGHISDB 		       READ ONLY WITH APPLY NOT ALLOWED   PHYSICAL STANDBY
2、查看进程信息

(1)在主库查看LNS进程,此进程负责将主数据库的重做日志条目传输到备用数据库。

SQL> select process, status, sequence# from v$managed_standby;

PROCESS   STATUS	SEQUENCE#
--------- ------------ ----------
ARCH	  CLOSING	   324114
ARCH	  CLOSING	   317879
ARCH	  CLOSING	   324115
ARCH	  CLOSING	   324116
LNS	  WRITING	   324117

(2)在备库查看MRP0进程,此进程负责将接收到的归档日志应用到备用数据库上,以维持与主数据库的同步。MRP进程是DG中的关键组件,它确保备用数据库的数据与主数据库保持一致。

SQL> select process, status, sequence# from v$managed_standby;

PROCESS   STATUS	SEQUENCE#
--------- ------------ ----------
ARCH	  CLOSING	   324117
ARCH	  CLOSING	   114458
ARCH	  CONNECTED		0
ARCH	  CLOSING	   324116
RFS	  IDLE		   324118
RFS	  IDLE			0
RFS	  IDLE			0
RFS	  IDLE			0
MRP0	  APPLYING_LOG	   324118
RFS	  IDLE			0
RFS	  IDLE			0
RFS	  IDLE		   114459
RFS	  IDLE			0

13 rows selected.
3、检查归档是否一致
-- 主库
SQL> select max(sequence#),thread# from v$archived_log where RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE# FROM V$DATABASE_INCARNATION WHERE STATUS = 'CURRENT') GROUP BY THREAD#;

MAX(SEQUENCE#)	  THREAD#
-------------- ----------
	324117		1
	114458		2
	
-- 备库
SQL> select max(sequence#),thread# from v$archived_log where RESETLOGS_CHANGE# = (SELECT RESETLOGS_CHANGE# FROM V$DATABASE_INCARNATION WHERE STATUS = 'CURRENT') GROUP BY THREAD#;

MAX(SEQUENCE#)	  THREAD#
-------------- ----------
	324117		1
	114458		2
4、查看 GAP 是否有延迟

GAP产生的原因是,一般是备库已经长时间未与主库同步,等发现的时候,主库的归档日志已经删除,备库无法再次与主库同步,这时候GAP就产生了。

-- 主库
SQL> select * from v$archive_gap;

no rows selected

SQL> select STATUS, GAP_STATUS from V$ARCHIVE_DEST_STATUS where DEST_ID = 2;

STATUS	  GAP_STATUS
--------- ------------------------
VALID	  NO GAP


-- 备库
SQL> select * from v$archive_gap;

no rows selected

SQL> select STATUS, GAP_STATUS from V$ARCHIVE_DEST_STATUS where DEST_ID = 2;

STATUS	  GAP_STATUS
--------- ------------------------
VALID	  RESOLVABLE GAP

三、在主库上重建 redo log file

1、查看 redo 日志组及大小

(1)查看日志文件

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE MEMBER   IS_
-----------------------------------------------------------------------------------
	 1	   ONLINE  +DATA/hisdb/onlinelog/redo01.log  NO
	 2	   ONLINE  +DATA/hisdb/onlinelog/redo02.log  NO
	 4	   ONLINE  +DATA/hisdb/onlinelog/redo04.log  NO
	 5	   ONLINE  +DATA/hisdb/onlinelog/redo05.log  NO
	 6	   ONLINE  +DATA/hisdb/onlinelog/redo06.log  NO
	 3	   ONLINE  +DATA/hisdb/onlinelog/redo03.log  NO
	 7	   STANDBY  +DATA/hisdb/onlinelog/group_7.446.1121009477   NO
	 8	   STANDBY  +DATA/hisdb/onlinelog/group_8.447.1121009483   NO
	 9	   STANDBY  +DATA/hisdb/onlinelog/group_9.448.1121009489   NO
	10	   STANDBY  +DATA/hisdb/onlinelog/group_10.449.1121009493  NO
	11	   STANDBY  +DATA/hisdb/onlinelog/group_11.450.1121009499  NO
	12	   STANDBY  +DATA/hisdb/onlinelog/group_12.451.1121009507  NO
	13	   STANDBY  +DATA/hisdb/onlinelog/group_13.452.1121009507  NO
	14	   STANDBY  +DATA/hisdb/onlinelog/group_14.453.1121009507  NO
14 rows selected.

(2)查看redo log信息

SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS  FIRST_CHANGE# FIRST_TIME
------------- ---------------------- ---------- ---------- ---------- ---------- --- ----------
	 1	    2	  114460	100	     1 YES ACTIVE    9057709636 03-JAN-25
	 2	    2	  114461	100	     1 YES ACTIVE    9057751045 03-JAN-25
	 3	    2	  114462	100	     1 NO  CURRENT   9057800557 03-JAN-25
	 4	    1	  324121	100	     1 YES ACTIVE    9057794541 03-JAN-25
	 5	    1	  324122	100	     1 NO  CURRENT   9057807196 03-JAN-25
	 6	    1	  324120	100	     1 YES ACTIVE   9057790272 03-JAN-25
6 rows selected.

(3)查看standby log信息

SQL> select group#,thread#,round(bytes/1024/1024,2) size_mb,status from v$standby_log;

    GROUP#    THREAD#	 SIZE_MB STATUS
---------- ---------- ---------- ----------
	 7	    1	     100 UNASSIGNED
	 8	    1	     100 UNASSIGNED
	 9	    1	     100 UNASSIGNED
	10	    1	     100 UNASSIGNED
	11	    2	     100 UNASSIGNED
	12	    2	     100 UNASSIGNED
	13	    2	     100 UNASSIGNED
	14	    2	     100 UNASSIGNED
8 rows selected.
2、在主库删除 standby log

删除旧的 standby loggroup: 7-14):

alter database drop logfile group 7;
alter database drop logfile group 8;
alter database drop logfile group 9;
alter database drop logfile group 10;
alter database drop logfile group 11;
alter database drop logfile group 12;
alter database drop logfile group 13;
alter database drop logfile group 14;
3、在主库替换 redo log

步骤1:添加两组临时日志文件:

节点1alter database add logfile thread 1 group 14 '+DATA' size 1024M;
alter database add logfile thread 1 group 15 '+DATA' size 1024M;

节点2alter database add logfile thread 2 group 16 '+DATA' size 1024M;
alter database add logfile thread 2 group 17 '+DATA' size 1024M;


SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

    GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS	    FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------
	 1	    2	  114484	100	     1 YES ACTIVE	       9058578050 03-JAN-25
	 2	    2	  114485	100	     1 YES ACTIVE	       9058584300 03-JAN-25
	 3	    2	  114483	100	     1 YES ACTIVE	       9058554867 03-JAN-25
	 4	    1	  324142	100	     1 YES ACTIVE	       9058579106 03-JAN-25
	 5	    1	  324140	100	     1 YES INACTIVE	       9058515833 03-JAN-25
	 6	    1	  324141	100	     1 YES ACTIVE	       9058538032 03-JAN-25
	14	    1	  324143       1024	     1 NO  CURRENT	       9058623959 03-JAN-25
	15	    1	       0       1024	     1 YES UNUSED			0
	16	    2	  114486       1024	     1 NO  CURRENT	       9058621526 03-JAN-25
	17	    2	       0       1024	     1 YES UNUSED			0

10 rows selected.

步骤2:切日志,让旧的日志文件(group: 1-6)组为INACTIVE

alter system switch logfile;
alter system checkpoint;

select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

    GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS	    FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------
	 1	    2	  114484	100	     1 YES INACTIVE	       9058578050 03-JAN-25
	 2	    2	  114485	100	     1 YES INACTIVE	       9058584300 03-JAN-25
	 3	    2	  114483	100	     1 YES INACTIVE	       9058554867 03-JAN-25
	 4	    1	  324142	100	     1 YES INACTIVE	       9058579106 03-JAN-25
	 5	    1	  324140	100	     1 YES INACTIVE	       9058515833 03-JAN-25
	 6	    1	  324141	100	     1 YES INACTIVE	       9058538032 03-JAN-25
	14	    1	  324143       1024	     1 YES INACTIVE	       9058623959 03-JAN-25
	15	    1	  324144       1024	     1 NO  CURRENT	       9058634615 03-JAN-25
	16	    2	  114486       1024	     1 NO  CURRENT	       9058621526 03-JAN-25
	17	    2	       0       1024	     1 YES UNUSED			0

10 rows selected.

步骤3:删除1-6组日志文件:

alter database drop logfile group 1;
alter database drop logfile group 2;
alter database drop logfile group 3;
alter database drop logfile group 4;
alter database drop logfile group 5;
alter database drop logfile group 6;

SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

    GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS	    FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------
	14	    1	  324143       1024	     1 YES INACTIVE	       9058623959 03-JAN-25
	15	    1	  324144       1024	     1 NO  CURRENT	       9058634615 03-JAN-25
	16	    2	  114486       1024	     1 NO  CURRENT	       9058621526 03-JAN-25
	17	    2	       0       1024	     1 YES UNUSED			0

步骤4:添加新的日志文件:

/*
SQL> select * from v$logfile;

    GROUP# STATUS  TYPE MEMBER   IS_
-----------------------------------------------------------------------------------
	 1	   ONLINE   +DATA/hisdb/onlinelog/redo01.log  NO
	 2	   ONLINE   +DATA/hisdb/onlinelog/redo02.log  NO
	 4	   ONLINE   +DATA/hisdb/onlinelog/redo04.log  NO
	 5	   ONLINE   +DATA/hisdb/onlinelog/redo05.log  NO
	 6	   ONLINE   +DATA/hisdb/onlinelog/redo06.log  NO
	 3	   ONLINE   +DATA/hisdb/onlinelog/redo03.log  NO
	 7	   STANDBY  +DATA/hisdb/onlinelog/group_7.446.1121009477   NO
	 8	   STANDBY  +DATA/hisdb/onlinelog/group_8.447.1121009483   NO
	 9	   STANDBY  +DATA/hisdb/onlinelog/group_9.448.1121009489   NO
	10	   STANDBY  +DATA/hisdb/onlinelog/group_10.449.1121009493  NO
	11	   STANDBY  +DATA/hisdb/onlinelog/group_11.450.1121009499  NO
	12	   STANDBY  +DATA/hisdb/onlinelog/group_12.451.1121009507  NO
	13	   STANDBY  +DATA/hisdb/onlinelog/group_13.452.1121009507  NO
	14	   STANDBY  +DATA/hisdb/onlinelog/group_14.453.1121009507  NO
14 rows selected.
*/

alter database add logfile thread 2 group 1 '+DATA/hisdb/onlinelog/redo1.log' size 1024M;
alter database add logfile thread 2 group 2 '+DATA/hisdb/onlinelog/redo2.log' size 1024M;
alter database add logfile thread 2 group 3 '+DATA/hisdb/onlinelog/redo3.log' size 1024M;
alter database add logfile thread 1 group 4 '+DATA/hisdb/onlinelog/redo4.log' size 1024M;
alter database add logfile thread 1 group 5 '+DATA/hisdb/onlinelog/redo5.log' size 1024M;
alter database add logfile thread 1 group 6 '+DATA/hisdb/onlinelog/redo6.log' size 1024M;


SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

    GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS	    FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------
	 1	    2	       0       1024	     1 YES UNUSED			0
	 2	    2	       0       1024	     1 YES UNUSED			0
	 3	    2	       0       1024	     1 YES UNUSED			0
	 4	    1	       0       1024	     1 YES UNUSED			0
	 5	    1	       0       1024	     1 YES UNUSED			0
	 6	    1	       0       1024	     1 YES UNUSED			0
	14	    1	  324143       1024	     1 YES INACTIVE	       9058623959 03-JAN-25
	15	    1	  324144       1024	     1 NO  CURRENT	       9058634615 03-JAN-25
	16	    2	  114486       1024	     1 NO  CURRENT	       9058621526 03-JAN-25
	17	    2	       0       1024	     1 YES UNUSED			0

10 rows selected.

步骤5:切日志,删除临时添加的日志文件:

alter system switch logfile;
alter system checkpoint;

SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

    GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS	    FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------
	 1	    2	  114487       1024	     1 NO  CURRENT	       9058754188 03-JAN-25
	 2	    2	       0       1024	     1 YES UNUSED			0
	 3	    2	       0       1024	     1 YES UNUSED			0
	 4	    1	  324145       1024	     1 YES INACTIVE	       9058753823 03-JAN-25
	 5	    1	  324146       1024	     1 NO  CURRENT	       9058759093 03-JAN-25
	 6	    1	       0       1024	     1 YES UNUSED			0
	14	    1	  324143       1024	     1 YES INACTIVE	       9058623959 03-JAN-25
	15	    1	  324144       1024	     1 YES INACTIVE	       9058634615 03-JAN-25
	16	    2	  114486       1024	     1 YES INACTIVE	       9058621526 03-JAN-25
	17	    2	       0       1024	     1 YES UNUSED			0

10 rows selected.


alter database drop logfile group 14;
alter database drop logfile group 15;
alter database drop logfile group 16;
alter database drop logfile group 17;

SQL> select group#,thread#,sequence#,round(bytes/1024/1024,2) size_mb,members,archived,status,first_change#,first_time from v$log;

    GROUP#    THREAD#  SEQUENCE#    SIZE_MB    MEMBERS ARC STATUS	    FIRST_CHANGE# FIRST_TIME
---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- ------------
	 1	    2	  114487       1024	     1 NO  CURRENT	       9058754188 03-JAN-25
	 2	    2	       0       1024	     1 YES UNUSED			0
	 3	    2	       0       1024	     1 YES UNUSED			0
	 4	    1	  324145       1024	     1 YES INACTIVE	       9058753823 03-JAN-25
	 5	    1	  324146       1024	     1 NO  CURRENT	       9058759093 03-JAN-25
	 6	    1	       0       1024	     1 YES UNUSED			0

6 rows selected.
4、主库添加 standby log
Alter database add standby logfile thread 1 group 7 '+DATA/hisdb/onlinelog/standby07.log' size 1024m;
Alter database add standby logfile thread 1 group 8 '+DATA/hisdb/onlinelog/standby08.log' size 1024m;
Alter database add standby logfile thread 1 group 9 '+DATA/hisdb/onlinelog/standby09.log' size 1024m;
Alter database add standby logfile thread 1 group 10 '+DATA/hisdb/onlinelog/standby10.log' size 1024m;
Alter database add standby logfile thread 2 group 11 '+DATA/hisdb/onlinelog/standby11.log' size 1024m;
Alter database add standby logfile thread 2 group 12 '+DATA/hisdb/onlinelog/standby12.log' size 1024m;
Alter database add standby logfile thread 2 group 13 '+DATA/hisdb/onlinelog/standby13.log' size 1024m;
Alter database add standby logfile thread 2 group 14 '+DATA/hisdb/onlinelog/standby14.log' size 1024m;

四、在备库上重建 standby log

步骤1:查看 redo 日志组及大小

查看日志文件信息

SQL> select * from v$logfile;

    GROUP# STATUS  TYPE   MEMBER   IS_
------------------------------------------------------------------------
	 1	   ONLINE  /oradata/dghisdb/onlinelog/redo01.log  NO
	 2	   ONLINE  /oradata/dghisdb/onlinelog/redo02.log  NO
	 4	   ONLINE  /oradata/dghisdb/onlinelog/redo04.log  NO
	 5	   ONLINE  /oradata/dghisdb/onlinelog/redo05.log  NO
	 6	   ONLINE  /oradata/dghisdb/onlinelog/redo06.log  NO
	 3	   ONLINE  /oradata/dghisdb/onlinelog/redo03.log  NO
	 7	   STANDBY /oradata/dghisdb/onlinelog/group_7.446.1121009477 NO
	 8	   STANDBY /oradata/dghisdb/onlinelog/group_8.447.1121009483 NO
	 9	   STANDBY /oradata/dghisdb/onlinelog/group_9.448.1121009489 NO
	10	   STANDBY /oradata/dghisdb/onlinelog/group_10.449.1121009493 NO
	11	   STANDBY /oradata/dghisdb/onlinelog/group_11.450.1121009499 NO
	12	   STANDBY /oradata/dghisdb/onlinelog/group_12.451.1121009507 NO
	13	   STANDBY /oradata/dghisdb/onlinelog/group_13.452.1121009507 NO
	14	   STANDBY /oradata/dghisdb/onlinelog/group_14.453.1121009507 NO

14 rows selected.


SQL> select group#,thread#,round(bytes/1024/1024,2) size_mb,status from v$standby_log;

    GROUP#    THREAD#	 SIZE_MB STATUS
---------- ---------- ---------- ----------
	 7	    1	     100 UNASSIGNED
	 8	    1	     100 UNASSIGNED
	 9	    1	     100 UNASSIGNED
	10	    1	     100 UNASSIGNED
	11	    2	     100 UNASSIGNED
	12	    2	     100 UNASSIGNED
	13	    2	     100 UNASSIGNED
	14	    2	     100 UNASSIGNED

8 rows selected.
步骤2:备库取消日志应用
alter database recover managed standby database cancel;
步骤3:修改日志管理模式为手动
SQL> alter system set standby_file_management='manual';

SQL> show parameter standby_file_management

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
standby_file_management              string      manual
步骤4:删除备库 standby log

(1)添加两组临时standby log file

alter database add standby logfile group 15 '/oradata/dghisdb/onlinelog/stlog15.log' size 1024m reuse;
alter database add standby logfile group 16 '/oradata/dghisdb/onlinelog/stlog16.log' size 1024m reuse;

(2)在主库切日志,将active状态切到临时文件上,将所有旧的standby logstatus刷到UNASSIGNED

SQL> alter system switch logfile;
--备库查看
SQL> select group#,thread#,round(bytes/1024/1024,2) size_mb,status from v$standby_log;

(3)删除旧的standby log file

alter database drop logfile group 7;
alter database drop logfile group 8;
alter database drop logfile group 9;
alter database drop logfile group 10;
alter database drop logfile group 11;
alter database drop logfile group 12;
alter database drop logfile group 13;
alter database drop logfile group 14;
步骤5:备库新建 standby log

重新添加standby log,大小为1024mgroup: 7-14

alter database add standby logfile group 7 '/oradata/dghisdb/onlinelog/standby07.log' size 1024m reuse;
alter database add standby logfile group 8 '/oradata/dghisdb/onlinelog/standby08.log' size 1024m reuse;
alter database add standby logfile group 9 '/oradata/dghisdb/onlinelog/standby09.log' size 1024m reuse;
alter database add standby logfile group 10 '/oradata/dghisdb/onlinelog/standby10.log' size 1024m reuse;
alter database add standby logfile group 11 '/oradata/dghisdb/onlinelog/standby11.log' size 1024m reuse;
alter database add standby logfile group 12 '/oradata/dghisdb/onlinelog/standby12.log' size 1024m reuse;
alter database add standby logfile group 13 '/oradata/dghisdb/onlinelog/standby13.log' size 1024m reuse;
alter database add standby logfile group 14 '/oradata/dghisdb/onlinelog/standby14.log' size 1024m reuse;
步骤6:主库切日志,将临时standby logfile切到UNASSIGNED状态,然后删除:
alter database drop logfile group 15;
alter database drop logfile group 16;  

说明:关于备库的 redo log 处理

通常情况下,备库为只读模式,不对数据库进行修改,不会启用redo log files

另外,由于 DG 备库处于只读模式,因此,不对备库的 redo log 做任何操作。

步骤7:打开实时应用日志和自动日志管理

完成以上操作后,dg 环境的redo logfilestandby logfile就算更新完成了,接下来只需要恢复数据同步即可。

alter database recover managed standby database using current logfile disconnect;

alter system set standby_file_management='AUTO';
步骤8:重新启动备库,查看数据同步情况
SQL> select process ,status , sequence# from v$managed_standby;

PROCESS   STATUS	SEQUENCE#
--------- ------------ ----------
ARCH	  CLOSING	   324152
ARCH	  CONNECTED		0
ARCH	  CONNECTED		0
ARCH	  CLOSING	   114489
RFS	  IDLE			0
RFS	  IDLE			0
RFS	  IDLE		   114490
RFS	  IDLE			0
RFS	  IDLE		   324153
RFS	  IDLE			0
MRP0	  APPLYING_LOG	   324153

11 rows selected.

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

    GROUP#    THREAD#  SEQUENCE# ARC STATUS
---------- ---------- ---------- --- ----------
	 7	    2	  114490 YES ACTIVE
	 8	    2	       0 NO  UNASSIGNED
	 9	    1	  324153 YES ACTIVE
	10	    1	       0 NO  UNASSIGNED
	11	    0	       0 YES UNASSIGNED
	12	    0	       0 YES UNASSIGNED
	13	    0	       0 YES UNASSIGNED
	14	    0	       0 YES UNASSIGNED

8 rows selected.

本文来自互联网用户投稿,该文观点仅代表作者本人,不代表本站立场。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如若转载,请注明出处:http://www.coloradmin.cn/o/2274116.html

如若内容造成侵权/违法违规/事实不符,请联系多彩编程网进行投诉反馈,一经查实,立即删除!

相关文章

JVM vs JDK vs JRE

JVM是Java虚拟机的缩写, 用于实现Java的一次编译,处处运行。 Java代码写成.class后,由本地的虚拟机运行。 JDK(Java Development Kit)是一个功能齐全的 Java 开发工具包,供开发者使用。 JDK包含了JRE。…

【网页自动化】篡改猴入门教程

安装篡改猴 打开浏览器扩展商店(Edge、Chrome、Firefox 等)。搜索 Tampermonkey 并安装。 如图安装后,浏览器右上角会显示一个带有猴子图标的按钮。 创建用户脚本 已进入篡改猴管理面板点击创建 脚本注释说明 name:脚本名称。…

微信小程序用的SSL证书有什么要求吗?

微信小程序主要建立在手机端使用,然而手机又涉及到各种系统及版本,所以对SSL证书也有要求,如果要小程序可以安全有效的访问需要满足以下要求: 1、原厂SSL证书(原厂封)。 2、DV单域名或者DV通配符。 3、兼…

【电子通识】PWM驱动让有刷直流电机恒流工作

电机的典型驱动方法包括电压驱动、电流驱动以及PWM驱动。本文将介绍采用PWM驱动方式的恒流工作。 首先介绍的是什么是PWM驱动的电机恒流工作,其次是PWM驱动电机恒流工作时电路的工作原理。 PWM驱动 当以恒定的电流驱动电机时,电机会怎样工作呢&#xff1…

Unity学习之UGUI进阶

一、事件监听接口 1、作用 用于实现类型长按、双击、拖拽等基础控件无法实现的功能 所有控件都能够添加更多的事件监听来处理对应的逻辑 2、事件监听接口类型 (1)常用事件接口 (2)不常用事件接口 3、使用事件监听接口 &#…

电脑硬盘系统迁移及问题处理

一、系统迁移准备 1、确认你的电脑主板是否支持安装两块硬盘,如电脑主板有多个M2硬盘接口,我们将新硬盘安装到主板上,原来的老硬盘安装在第二个接口上,主板只有一个M2接口的话可以使用移动硬盘盒。 2、新硬盘安装好后,我们进入原来的系统,在 此电脑–右键–管理–磁盘管…

【NLP高频面题 - Transformer篇】Transformer的输入中为什么要添加位置编码?

Transformer的输入中为什么要添加位置编码? 重要性:★★★ Transformer 将句子中的所有词并行地输入到神经网络中。并行输入有助于缩短训练时间,同时有利于学习长期依赖。不过,并行地将词送入 Transformer,却不保留词…

http range 下载大文件分片

摘自:https://www.jianshu.com/p/32c16103715a 上传分片下载也能分 HTTP 协议范围请求允许服务器只发送 HTTP 消息的一部分到客户端。范围请求在传送大的媒体文件,或者与文件下载的断点续传功能搭配使用时非常有用。 检测服务器端是否支持范围请求 假…

Improving Language Understanding by Generative Pre-Training GPT-1详细讲解

Improving Language Understanding by Generative Pre-Training 2018.06 GPT-1 0.有监督、半监督、无监督 CV:ImageNet pre-trained model NLP:pre-trained model? 在计算机视觉中任务包含分类、检测、分割,任务类别数少,对应…

onLoad 生命周期函数是否执行取决于跳转的方式和小程序的页面栈管理机制

文章目录 1. 页面跳转方式2. 你的场景分析3. 页面生命周期4. 总结5. 建议 在微信小程序中,页面跳转时, onLoad 生命周期函数是否执行取决于跳转的方式和小程序的页面栈管理机制。以下是详细说明: 1. 页面跳转方式 微信小程序提供了多种页面…

后台管理系统引导功能的实现

引导是软件中经常见到的一个功能,无论是在后台项目还是前台或者是移动端项目中。 那么对于引导页而言,它是如何实现的呢?通常情况下引导页是通过 聚焦 的方式,高亮一块视图,然后通过文字解释的形式来告知用户该功能的作…

vue js实现时钟以及刻度效果

2025.01.08今天我学习如何用js实现时钟样式&#xff0c;效果如下&#xff1a; 一、html代码如下&#xff1a; <template><!--圆圈--><div class"notice_border"><div class"notice_position notice_name_class" v-for"item in …

CSS Grid 布局全攻略:从基础到进阶

文章目录 一.Grid 是什么二.示例代码1. 基础使用 - 固定宽高2.百分百宽高3.重复设置-repeat4.单位-fr5.自适应6.间距定义其他 一.Grid 是什么 CSS 中 Grid 是一种强大的布局方式&#xff0c;它可以同时处理行和列 Grid 和Flex有一些类似&#xff0c;都是由父元素包裹子元素使用…

【adb】5分钟入门adb操作安卓设备

ADB&#xff08;Android Debug Bridge&#xff09; 是一个多功能的命令行工具&#xff0c;用于与 Android 设备进行交互、调试和管理。它提供了对设备的直接控制&#xff0c;能够帮助开发者进行调试、安装应用、传输文件等。 目录 将设备和电脑连接 adb shell 文件的基本操…

Jenkins-持续集成、交付、构建、部署、测试

Jenkins-持续集成、交付、构建、部署、测试 一: Jenkins 介绍1> Jenkins 概念2> Jenkins 目的3> Jenkins 特性4> Jenkins 作用 二&#xff1a;Jenkins 版本三&#xff1a;DevOps流程简述1> 持续集成&#xff08;Continuous Integration&#xff0c;CI&#xff0…

Golang笔记:使用net包进行TCP监听回环测试

文章目录 前言TCP监听回环代码演示 附&#xff1a;UDP监听回环 前言 TCP是比较基础常用的网络通讯方式&#xff0c;这篇文章将使用Go语言实现TCP监听回环测试。 本文中使用 Packet Sender 工具进行测试&#xff0c;其官网地址如下&#xff1a; https://packetsender.com/ TC…

SSL 证书格式和证书文件扩展名:完整指南

SSL 证书是什么以及它如何工作相当容易理解。但当涉及到在服务器上安装它时&#xff0c;有时&#xff0c;你可能觉得这是在处理火箭科学。 由于有如此多的SSL 证书格式与特定服务器要求相关&#xff0c;您更有可能感到困惑和沮丧&#xff0c;而不是从一开始就正确配置证书。但…

【源码+文档+调试讲解】项目申报小程序

摘 要 随着信息技术和网络技术的飞速发展&#xff0c;人类已进入全新信息化时代&#xff0c;传统管理技术已无法高效&#xff0c;便捷地管理信息。为了迎合时代需求&#xff0c;优化管理效率&#xff0c;各种各样的管理系统应运而生&#xff0c;各行各业相继进入信息管理时代…

echarts横向柱状图胶囊

echarts配置项 tooltip: {trigger: axis, // 触发tooltip提示类型 axis:坐标轴触发axisPointer: {type: cross, // 指示器类型 cross: 十字准星指示器crossStyle: {color: #999 // 线颜色}} }, grid: { left: 0%, //离容器左侧的距离top:5%,bottom: 3%,containLabel: true…

人工智能的发展领域之GPU加速计算的应用概述、架构介绍与教学过程

文章目录 一、架构介绍GPU算力平台概述优势与特点 二、注册与登录账号注册流程GPU服务器类型配置选择指南内存和存储容量网络带宽CPU配置 三、创建实例实例创建步骤镜像选择与设置 四、连接实例SSH连接方法远程桌面配置 一、架构介绍 GPU算力平台概述 一个专注于GPU加速计算的…