目的:将重做日志(redo log)文件从当前磁盘位置迁移到新的位置
解决方法:
A:可以停掉数据库的情况
1.关闭数据库
SQL>shutdown immediate
Databaseclosed.
Databasedismounted.
ORACLEinstance shut down.
2.将重做日志文件拷贝到新的位置上
[oracle@radiusradius]$ mv redo0*.log /ora/newlocation/
[oracle@radiusoradata]$ cd /ora/newlocation/
[oracle@radiusnewlocation]$ ls
redo01.log redo02.log redo03.log redo04.log redo05.log
3.启动数据库到mount状态,切记不要打开数据库。
[oracle@radiusnewlocation]$ sqlplus / as sysdba
SQL*Plus:Release 10.2.0.4.0 - Production on Thu Jul 10 14:34:15 2014
Copyright(c) 1982, 2007, Oracle. All RightsReserved.
Connectedto an idle instance.
SQL>startup mount
ORACLEinstance started.
TotalSystem Global Area 599785472 bytes
FixedSize 2085776 bytes
VariableSize 205524080 bytes
DatabaseBuffers 385875968 bytes
RedoBuffers 6299648 bytes
Databasemounted.
4.重新命名日志成员
SQL>alterdatabase rename file
'/ora/oradata/radius/redo03.log','/ora/oradata/radius/redo02.log','/ora/oradata/radius/redo01.log','/ora/oradata/radius/redo04.log','/ora/oradata/radius/redo05.log'
to
'/ora/newlocation/redo03.log','/ora/newlocation/redo02.log','/ora/newlocation/redo01.log','/ora/newlocation/redo04.log','/ora/newlocation/redo05.log';
Databasealtered.
5.打开数据库
SQL>alter database open;
Databasealtered.
6.查看日志文件成员的位置信息
SQL>select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/ora/newlocation/redo03.log
/ora/newlocation/redo02.log
/ora/newlocation/redo01.log
/ora/newlocation/redo04.log
/ora/newlocation/redo05.log
/home/oracle/flash_recovery_area/RADIUS/onlinelog/o1_mf_5_9vw9blxk_.log
/home/oracle/flash_recovery_area/RADIUS/onlinelog/o1_mf_6_9vw9bt19_.log
7rows selected.
B. 如果数据库不能停机,就不能够直接修改重做日志文件的名字,因此需要首先增加日志组,然后删除不需要的日志组,最终达到修改重做日志文件位置的目的。
1. 需要修改几组日志文件,就新增加几个日志组
SQL>alter database add logfile group 7 '/ora/oradata/radius/redo07.log' size 50M;
Databasealtered.
SQL>alter database add logfile group 8 '/ora/oradata/radius/redo08.log' size 50M;
Databasealtered.
2. 删除不在需要的日志组,但是必须要有alter database的系统权限
在删除一个在线日志组之前,应该注意以下的限制条件:
2.1 每个实例至少要有2个日志组,不需要考虑日志组中的日志成员的数量(一个日志组中有1个或1个以上的日志成员)
2.2 只有在日志成员组的状态是INACTIVE的状态下,才可以对其进行删除,如果需要删除当前正在使用的日志组,首先需要进行一次日志切换,使其变成非当前日志组,如果数据库已经开启了归档模式,那么在删除日志组之前确保日志组已经完全归档完成了,然后在对其进行删除。
查看日志组的状态:
日志组:1 2 3 的状态是INACTIVE,可以对其进行删除操作。
对1 2执行删除操作,删除这两个日志组:
SQL>alter database drop logfile group 1;
Databasealtered.
SQL>alter database drop logfile group 2;
Databasealtered.
3. 查看日志成员信息
SQL>select group#,archived,status from v$log;
GROUP# ARC STATUS
------------- ----------------
3 YES INACTIVE
4 NO CURRENT
5 YES UNUSED
6 YES UNUSED
7 YES UNUSED
8 YES UNUSED
SQL>select member from v$logfile;
MEMBER
--------------------------------------------------------------------------------
/ora/newlocation/redo03.log
/ora/newlocation/redo04.log
/home/oracle/flash_recovery_area/RADIUS/onlinelog/o1_mf_5_9vw9blxk_.log
/home/oracle/flash_recovery_area/RADIUS/onlinelog/o1_mf_6_9vw9bt19_.log
/ora/oradata/radius/redo07.log
/ora/oradata/radius/redo08.log
4. 通过以上的步骤确认,在线日志组已经成功删除之后,通过操作系统命令,将删除的日志组的系统文件进行删除。
[oracle@radiusnewlocation]$ pwd
/ora/newlocation
[oracle@radiusnewlocation]$ ls
redo01.log redo02.log redo03.log redo04.log redo05.log
[oracle@radiusnewlocation]$ rm -f redo01.logredo02.log redo03.log
[oracle@radiusnewlocation]$ ls
redo04.log redo05.log
[oracle@radiusnewlocation]$
--END--