Oracle Redo Log file expansion

A database has 3 Log Groups, and the size of the Redo Log file in each group is 200MB, which needs to be enlarged to 1GB. That is, the final need to become as follows:

SQL> select bytes from v$log;

     BYTES
----------
1073741824
1073741824
1073741824

In fact, there is no such thing as an expansion command. Just delete the old Log Group, then add a new Log Group and specify a size of 1GB.

Assuming that the current status is Log Group 1, we can rebuild Log Group 2 and 3 first:

-- 操作必须在CDB$ROOT中进行
connect / as sysdba
ALTER DATABASE DROP LOGFILE GROUP 3;
ALTER DATABASE ADD LOGFILE GROUP 3 ('+DATAC1') SIZE 1G;
ALTER DATABASE DROP LOGFILE GROUP 2;
ALTER DATABASE ADD LOGFILE GROUP 2 ('+DATAC1') SIZE 1G;

Then do Log Switch:

ALTER SYSTEM SWITCH LOGFILE;
ALTER SYSTEM CHECKPOINT;
ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE ADD LOGFILE GROUP 1 ('+DATAC1') SIZE 1G;

If you do not switch logfile, the following error will be reported:

SQL> ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE DROP LOGFILE GROUP 
*
ERROR at line 1:
ORA-01623: log 1 is current log for instance orcl (thread 1) - cannot drop
ORA-00312: online log 1 thread 1:
'+RECO/DB0410_NRT12N/ONLINELOG/group_1.551.1136542627'

If checkpoint is not performed, the following error may be reported:

SYS@orcl>ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE DROP LOGFILE GROUP 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance orcl (thread 1)
ORA-00312: online log 1 thread 1:
'+DATAC1/ORCL/ONLINELOG/group_1.551.1136542627'

At 6pm on May 22, 2023, I did it again, changing from 1G to 2G:

SYS@orcl>select group#, bytes, status from v$log;

    GROUP#      BYTES STATUS
---------- ---------- ----------------
         1 1073741824 CURRENT
         2 1073741824 INACTIVE
         3 1073741824 INACTIVE

ALTER DATABASE DROP LOGFILE GROUP 3;
ALTER DATABASE ADD LOGFILE GROUP 3 ('+DATAC1') SIZE 2G;
ALTER DATABASE DROP LOGFILE GROUP 2;
ALTER DATABASE ADD LOGFILE GROUP 2 ('+DATAC1') SIZE 2G;

SYS@orcl>select group#, bytes, status from v$log;

    GROUP#      BYTES STATUS
---------- ---------- ----------------
         1 1073741824 CURRENT
         2 2147483648 UNUSED
         3 2147483648 UNUSED

SYS@orcl>ALTER SYSTEM SWITCH LOGFILE;

System altered.

SYS@orcl>select group#, bytes, status from v$log;

    GROUP#      BYTES STATUS
---------- ---------- ----------------
         1 1073741824 ACTIVE
         2 2147483648 CURRENT
         3 2147483648 UNUSED

SYS@orcl>ALTER DATABASE DROP LOGFILE GROUP 1;
ALTER DATABASE DROP LOGFILE GROUP 1
*
ERROR at line 1:
ORA-01624: log 1 needed for crash recovery of instance orcl (thread 1)
ORA-00312: online log 1 thread 1:
'+DATAC1/ORCL/ONLINELOG/group_1.551.1137263455'


SYS@orcl>ALTER SYSTEM CHECKPOINT;

System altered.

SYS@orcl>ALTER DATABASE DROP LOGFILE GROUP 1;

Database altered.

SYS@orcl>ALTER DATABASE ADD LOGFILE GROUP 1 ('+DATAC1') SIZE 2G;

Database altered.

SYS@orcl>select group#, bytes, status from v$log;

    GROUP#      BYTES STATUS
---------- ---------- ----------------
         1 2147483648 UNUSED
         2 2147483648 CURRENT
         3 2147483648 UNUSED

Guess you like

Origin blog.csdn.net/stevensxiao/article/details/130773591