Oracle Redo Log 文件扩容

某数据库有3个Log Group,每个Group中的Redo Log文件大小为200MB,需要扩大到1GB。也就是最终需要变成如下:

SQL> select bytes from v$log;

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

实际上,没有所谓的扩容命令。只需把老的Log Group删除,然后添加新Log Group并指定大小为1GB。

假设status为current的为Log Group 1,我们可以先重建Log Group 2和3:

-- 操作必须在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;

然后做Log Swicth:

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

如果不switch logfile,则会报如下错:

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'

如果不做checkpoint,则可能报如下错:

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'

2023年5月22日下午6点,又做了一次,从1G改为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
评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值