修改备库日志(redo、standby redo)

2024年 5月 21日 79.9k 0

备库也是一样的情况,redo调整主库不会同步到备库的所以记得要自己操作

1、redo挪位置

2、调整redo大小

3、调整redo每组个数

注意点:按照文档操作你需要更换路径,和大小根据实际情况调整。路径就不解释了,大小是根据业务量来的,如果业务量大redo小了会造成频繁切换归档造成不必要的资源消耗,如果太大了也会对性能、管理复杂度、恢复时间有影响。

备库删除redo步骤

1、关闭DG应用
2、开启手动管理文件
3、确认不是CURRENT状态(如果是就在主库切换归档)
4、清理redo
5、删除redo
6、开启自动管理文件
7、开启DG应用

备库重建redo

set linesize 200
set pagesize 200
col MEMBER format a100
alter database recover managed standby database cancel;
alter system set standby_file_management='MANUAL' scope=both;
select * from v$log;
select * from v$logfile order by GROUP#,MEMBER;
alter database add logfile group 1 ('/u01/app/oracle/oradata/branch/redo01a.log', '/u01/app/oracle/oradata/branch/redo01b.log') size 500m reuse;
alter database add logfile group 2 ('/u01/app/oracle/oradata/branch/redo02a.log', '/u01/app/oracle/oradata/branch/redo02b.log') size 500m reuse;
alter database add logfile group 3 ('/u01/app/oracle/oradata/branch/redo03a.log', '/u01/app/oracle/oradata/branch/redo03b.log') size 500m reuse;
alter database clear logfile group 5;
alter database drop logfile group 5;
alter database clear logfile group 6;
alter database drop logfile group 6;
alter database clear logfile group 7;
alter database drop logfile group 7;
主库 alter system switch logfile;
select * from v$log;
alter database clear logfile group 4;
alter database drop logfile group 4;
alter database add logfile group 4 ('/u01/app/oracle/oradata/branch/redo04a.log', '/u01/app/oracle/oradata/branch/redo04b.log') size 500m reuse;
alter system set standby_file_management='AUTO' scope=both;
alter database recover managed standby database using current logfile disconnect from session;

备库重建redo操作日志记录

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter system set standby_file_management='MANUAL' scope=both;

System altered.

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
4 1 850528 524288000 512 1 YES CLEARING 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
7 1 850242 524288000 512 1 YES CLEARING 1.7316E+13 05-JAN-22 1.7316E+13 05-JAN-22
6 1 850241 524288000 512 1 YES CLEARING 1.7316E+13 05-JAN-22 1.7316E+13 05-JAN-22
5 1 850244 524288000 512 1 YES CLEARING 1.7316E+13 05-JAN-22 1.7316E+13 05-JAN-22

SQL> select * from v$logfile;

GROUP# STATUS TYPE MEMBER IS_RECOVERY_DEST_FILE
---------- ------- ------- -------------------------------------------------------------------- ---------------------
4 ONLINE /data/oradata/branch/redo4.log NO
5 ONLINE /data/oradata/branch/redo5.LOG NO
6 ONLINE /data/oradata/branch/redo6.LOG NO
7 ONLINE /data/oradata/branch/redo7.LOG NO
10 STANDBY /data/oradata/branch/STAN10.LOG NO
11 STANDBY /data/oradata/branch/STAN11.LOG NO
12 STANDBY /data/oradata/branch/STAN12.LOG NO
13 STANDBY /data/oradata/branch/STAN13.LOG NO

8 rows selected

SQL> alter database add logfile group 1 ('/u01/app/oracle/oradata/branch/redo01a.log', '/u01/app/oracle/oradata/branch/redo01b.log') size 500m reuse;

Database altered

SQL> alter database add logfile group 2 ('/u01/app/oracle/oradata/branch/redo02a.log', '/u01/app/oracle/oradata/branch/redo02b.log') size 500m reuse;

Database altered

SQL> alter database add logfile group 3 ('/u01/app/oracle/oradata/branch/redo03a.log', '/u01/app/oracle/oradata/branch/redo03b.log') size 500m reuse;

Database altered

SQL> alter database clear logfile group 7;

Database altered.

SQL> alter database drop logfile group 7;

Database altered.

SQL> alter database clear logfile group 6;

Database altered.

SQL> alter database drop logfile group 6;

Database altered.

SQL> alter database clear logfile group 5;

Database altered.

SQL> alter database drop logfile group 5;

Database altered.

主库去切换日志让4的状态为CLEARING
SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1 1 850561 524288000 512 2 YES CURRENT 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
2 1 850562 524288000 512 2 YES CLEARING 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
3 1 850563 524288000 512 2 YES CLEARING 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
4 1 850528 524288000 512 1 YES CLEARING 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22

SQL> alter database clear logfile group 4;

Database altered.

SQL> alter database drop logfile group 4;

Database altered.

SQL> alter database add logfile group 4 ('/u01/app/oracle/oradata/branch/redo04a.log', '/u01/app/oracle/oradata/branch/redo04b.log') size 500m reuse;

Database altered

SQL> alter system set standby_file_management='AUTO' scope=both;

System altered.

SQL> select * from v$log;

GROUP# THREAD# SEQUENCE# BYTES BLOCKSIZE MEMBERS ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME
---------- ---------- ---------- ---------- ---------- ---------- --- ---------------- ------------- --------- ------------ ---------
1 1 850565 524288000 512 2 YES CLEARING 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
2 1 850566 524288000 512 2 YES CURRENT 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
3 1 850563 524288000 512 2 YES CLEARING 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
4 1 850564 524288000 512 2 YES CLEARING 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22

SQL> select * from v$logfile order by GROUP#,MEMBER;

GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
1 ONLINE /u01/app/oracle/oradata/branch/redo01a.log NO
1 ONLINE /u01/app/oracle/oradata/branch/redo01b.log NO
2 ONLINE /u01/app/oracle/oradata/branch/redo02a.log NO
2 ONLINE /u01/app/oracle/oradata/branch/redo02b.log NO
3 ONLINE /u01/app/oracle/oradata/branch/redo03a.log NO
3 ONLINE /u01/app/oracle/oradata/branch/redo03b.log NO
4 ONLINE /u01/app/oracle/oradata/branch/redo04a.log NO
4 ONLINE /u01/app/oracle/oradata/branch/redo04b.log NO
10 STANDBY /data/oradata/branch/STAN10.LOG NO
11 STANDBY /data/oradata/branch/STAN11.LOG NO
12 STANDBY /data/oradata/branch/STAN12.LOG NO
13 STANDBY /data/oradata/branch/STAN13.LOG NO

16 rows selected.

SQL> alter database open read only;

Database altered.

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

Database altered.

备库重建 standby redo

select * from v$standby_log;
alter database drop logfile group 10;
alter database add standby logfile group 10 ('/u01/app/oracle/oradata/branch/STAN010A.LOG','/u01/app/oracle/oradata/branch/STAN010B.LOG') size 500m;
select * from v$standby_log;
alter database drop logfile group 11;
alter database drop logfile group 12;
alter database drop logfile group 13;
select * from v$standby_log;
alter database add standby logfile group 11 ('/u01/app/oracle/oradata/branch/STAN011A.LOG','/u01/app/oracle/oradata/branch/STAN011B.LOG') size 500m;
alter database add standby logfile group 12 ('/u01/app/oracle/oradata/branch/STAN012A.LOG','/u01/app/oracle/oradata/branch/STAN012B.LOG') size 500m;
alter database add standby logfile group 13 ('/u01/app/oracle/oradata/branch/STAN013A.LOG','/u01/app/oracle/oradata/branch/STAN013B.LOG') size 500m;
select * from v$standby_log;
select * from v$logfile order by GROUP#,MEMBER;
alter system set standby_file_management='AUTO' scope=both;
alter database recover managed standby database using current logfile disconnect from session;

备库重建 standby redo操作日志记录

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter system set standby_file_management='MANUAL' scope=both;

System altered.

主库去切换日志让10的状态为UNASSIGNED
SQL> select * from v$standby_log;

GROUP# DBID THREAD# SEQUENCE# BYTES BLOCKSIZE USED ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME
---------- ---------------------------------------- ---------- ---------- ---------- ---------- ---------- --- ---------- ------------- --------- ------------ --------- ------------ ---------
10 UNASSIGNED 1 0 524288000 512 0 NO UNASSIGNED
11 3160428602 1 850554 524288000 512 6283264 YES ACTIVE 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
12 UNASSIGNED 1 0 524288000 512 0 NO UNASSIGNED
13 UNASSIGNED 0 0 524288000 512 0 YES UNASSIGNED

SQL> alter database drop logfile group 10;

Database altered.

SQL> alter database add standby logfile group 10 ('/u01/app/oracle/oradata/branch/STAN010A.LOG','/u01/app/oracle/oradata/branch/STAN010B.LOG') size 500m;

Database altered.

主库去切换日志让10的状态为active
SQL> select * from v$standby_log;

GROUP# DBID THREAD# SEQUENCE# BYTES BLOCKSIZE USED ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME
---------- ---------------------------------------- ---------- ---------- ---------- ---------- ---------- --- ---------- ------------- --------- ------------ --------- ------------ ---------
10 3160428602 1 850555 524288000 512 4889600 YES ACTIVE 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
11 UNASSIGNED 1 0 524288000 512 0 NO UNASSIGNED
12 UNASSIGNED 1 0 524288000 512 0 NO UNASSIGNED
13 UNASSIGNED 0 0 524288000 512 0 YES UNASSIGNED

SQL> alter database drop logfile group 11;

Database altered.

SQL> alter database drop logfile group 12;

Database altered.

SQL> alter database drop logfile group 13;

Database altered.

SQL> alter database add standby logfile group 11 ('/u01/app/oracle/oradata/branch/STAN011A.LOG','/u01/app/oracle/oradata/branch/STAN011B.LOG') size 500m;

Database altered.

SQL> alter database add standby logfile group 12 ('/u01/app/oracle/oradata/branch/STAN012A.LOG','/u01/app/oracle/oradata/branch/STAN012B.LOG') size 500m;

Database altered.

SQL> alter database add standby logfile group 13 ('/u01/app/oracle/oradata/branch/STAN013A.LOG','/u01/app/oracle/oradata/branch/STAN013B.LOG') size 500m;

Database altered.

SQL> select * from v$standby_log;

GROUP# DBID THREAD# SEQUENCE# BYTES BLOCKSIZE USED ARC STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE# NEXT_TIME LAST_CHANGE# LAST_TIME
---------- ---------------------------------------- ---------- ---------- ---------- ---------- ---------- --- ---------- ------------- --------- ------------ --------- ------------ ---------
10 3160428602 1 850555 524288000 512 19894272 YES ACTIVE 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22 1.7316E+13 06-JAN-22
11 UNASSIGNED 0 0 524288000 512 0 YES UNASSIGNED
12 UNASSIGNED 0 0 524288000 512 0 YES UNASSIGNED
13 UNASSIGNED 0 0 524288000 512 0 YES UNASSIGNED

SQL> select * from v$logfile order by GROUP#,MEMBER;

GROUP# STATUS TYPE MEMBER IS_
---------- ------- ------- -------------------------------------------------- ---
1 ONLINE /u01/app/oracle/oradata/branch/redo01a.log NO
1 ONLINE /u01/app/oracle/oradata/branch/redo01b.log NO
2 ONLINE /u01/app/oracle/oradata/branch/redo02a.log NO
2 ONLINE /u01/app/oracle/oradata/branch/redo02b.log NO
3 ONLINE /u01/app/oracle/oradata/branch/redo03a.log NO
3 ONLINE /u01/app/oracle/oradata/branch/redo03b.log NO
4 ONLINE /u01/app/oracle/oradata/branch/redo04a.log NO
4 ONLINE /u01/app/oracle/oradata/branch/redo04b.log NO
10 STANDBY /u01/app/oracle/oradata/branch/STAN010A.LOG NO
10 STANDBY /u01/app/oracle/oradata/branch/STAN010B.LOG NO
11 STANDBY /u01/app/oracle/oradata/branch/STAN011A.LOG NO
11 STANDBY /u01/app/oracle/oradata/branch/STAN011B.LOG NO
12 STANDBY /u01/app/oracle/oradata/branch/STAN012A.LOG NO
12 STANDBY /u01/app/oracle/oradata/branch/STAN012B.LOG NO
13 STANDBY /u01/app/oracle/oradata/branch/STAN013A.LOG NO
13 STANDBY /u01/app/oracle/oradata/branch/STAN013B.LOG NO

16 rows selected.

SQL> alter system set standby_file_management='AUTO' scope=both;

System altered.

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

Database altered.

报错记录

redo报错

应用途中删除


SQL> alter database drop logfile group 7;
alter database drop logfile group 7
*
ERROR at line 1:
ORA-01156: recovery or flashback in progress may need access to files

取消应用在删

SQL> alter database recover managed standby database cancel;

Database altered.

SQL> alter database drop logfile group 7;
alter database drop logfile group 7
*
ERROR at line 1:
ORA-01275: Operation DROP LOGFILE is not allowed if standby file management is automatic.

取消应用开启手动管理删除

SQL> alter system set standby_file_management='MANUAL' scope=both;

System altered.

SQL> alter database drop logfile group 7;
alter database drop logfile group 7
*
ERROR at line 1:
ORA-01624: log 7 needed for crash recovery of instance branch (thread 1)
ORA-00312: online log 7 thread 1: '/data/oradata/branch/redo7.LOG'

相关文章

Oracle如何使用授予和撤销权限的语法和示例
Awesome Project: 探索 MatrixOrigin 云原生分布式数据库
下载丨66页PDF,云和恩墨技术通讯(2024年7月刊)
社区版oceanbase安装
Oracle 导出CSV工具-sqluldr2
ETL数据集成丨快速将MySQL数据迁移至Doris数据库

发布评论