迁移redo log到不同的存储路径
实际运维过程中,我们也经常需要迁移redo log到不同的存储路径,或者修改redo log的大小等等,下面整理了两种迁移redo log的方式。
1) 方案1:停止数据库实例迁移redo log
a、 查询数据redo log
SQL> select group#,type,member from v$logfile;
GROUP# TYPE MEMBER
--------- ------- ---------------------------
3 ONLINE /u01/oradata/tydb/redo03.log
2 ONLINE /u01/oradata/tydb/redo02.log
1 ONLINE /u01/oradata/tydb/redo01.log
b、 关闭数据库
$ sqlplus / as sysdba
SQL> shutdown immediate
Database closed.
Database dismounted.
ORACLE instance shut down.
c、 拷贝redo log到新的存储路径
$ cp /u01/oradata/tydb/redo03.log /u01/oradata/redo03.log
$ cp /u01/oradata/tydb/redo02.log /u01/oradata/redo02.log
$ cp /u01/oradata/tydb/redo01.log /u01/oradata/redo01.log
d、 将数据库启动到mount状态
$ sqlplus / as sysdba
SQL> startup mount
ORACLE instance started.
Total System Global Area 599785472 bytes
Fixed Size 2022632 bytes
Variable Size 171967256 bytes
Database Buffers 423624704 bytes
Redo Buffers 2170880 bytes
Database mounted.
e、 重命名redo log成员
SQL> alter database rename file '/u01/oradata/tydb/redo03.log','/u01/oradata/tydb/redo02.log','/u01/oradata/tydb/redo01.log' to '/u01/oradata/redo03.log','/u01/oradata/redo02.log','/u01/oradata/redo01.log';
Database altered.
f、 打开数据库
SQL> alter database open;
Database altered.
SQL> select open_mode from v$database;
OPEN_MODE
----------
READ WRITE
g、 检查确认日志迁移成功
SQL> select group#,type,member from v$logfile;
GROUP# TYPE MEMBER
---------- ------- ----------------------------------------
3 ONLINE /u01/oradata/redo03.log
2 ONLINE /u01/oradata/redo02.log
1 ONLINE /u01/oradata/redo01.log
由于这种方式需要停止数据库进行操作,很多核心业务系统是很难接受的,而且在redo log使用ASM存储的情况下,或者需要将文件系统或者裸设备迁移到ASM中都会变得非常不便,特别是在10g版本中,ASM和文件系统不能直接copy,需要借助Oracle提供的程序包进行拷贝;所以在大多数的情况下,都是不会采用以上迁移方案的,更多的会选择下面的在线迁移方案。
2) 方案2:在线迁移redo log
a、 查询当前redo log组
SQL> select group#,type,member from v$logfile;
GROUP# TYPE MEMBER
---------- ------- ----------------------------------------
3 ONLINE /u01/oradata/redo03.log
2 ONLINE /u01/oradata/redo02.log
1 ONLINE /u01/oradata/redo01.log
b、 添加新的redo log组
SQL> alter database add logfile group 4('/u01/oradata/tydb/redo04_1.log','/u01/oradata/tydb/redo04_2.log') size 100M;
Database altered.
SQL> alter database add logfile group 5('/u01/oradata/tydb/redo05.log') size 100m;
Database altered.
SQL> alter database add logfile group 6('/u01/oradata/tydb/redo06.log') size 100m;
Database altered.
这里顺便操作了一个redo log组中添加两个日志成员的情况;如果是RAC环境,只需在group前加上thread关键字即可(如:alter database add logfile thread 2 group 5('/u01/oradata/tydb/redo05.log') size 100m;)。
c、 查看添加新日志组后的日志情况
SQL> select group#,type,member from v$logfile;
GROUP# TYPE MEMBER
---------- ------- ----------------------------------------
3 ONLINE /u01/oradata/redo03.log
2 ONLINE /u01/oradata/redo02.log
1 ONLINE /u01/oradata/redo01.log
4 ONLINE /u01/oradata/tydb/redo04_1.log
4 ONLINE /u01/oradata/tydb/redo04_2.log
54 ONLINE /u01/oradata/tydb/redo05.log
6 ONLINE /u01/oradata/tydb/redo06.log
7 rows selected.
SQL> select group#,archived,status from v$log;
GROUP# ARC STATUS
---------- --- ----------------
1 NO CURRENT
2 YES UNUSED
3 NO INACTIVE
4 YES UNUSED
6 YES UNUSED
54 YES UNUSED
6 rows selected.
d、 删除旧的日志组
SQL> alter database drop logfile group 3;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter system switch logfile;
System altered.
SQL> alter system checkpoint;
System altered.
SQL> alter database drop logfile group 2;
Database altered.
e、 检查迁移后的redo log
SQL> select group#,type,member from v$logfile;
GROUP# TYPE MEMBER
---------- ------- ----------------------------------------
4 ONLINE /u01/oradata/tydb/redo04_1.log
4 ONLINE /u01/oradata/tydb/redo04_2.log
5 ONLINE /u01/oradata/tydb/redo05.log
6 ONLINE /u01/oradata/tydb/redo06.log
SQL> select group#,archived,status from v$log;
GROUP# ARC STATUS
---------- --- ----------------
4 NO CURRENT
6 YES INACTIVE
5 YES INACTIVE
至此,redo log 已经迁移成功。
f、 检查之前的redo log文件是否已经成功删除,没有删除可以手动删除
$ ls -l /u01/oradata/redo*
-rw-r----- 1 oracle oinstall 52429312 Jan 22 00:20 /u01/oradata/redo01.log
-rw-r----- 1 oracle oinstall 52429312 Jan 22 00:21 /u01/oradata/redo02.log
-rw-r----- 1 oracle oinstall 52429312 Jan 21 23:59 /u01/oradata/redo03.log
$ rm redo*
Created by Tony.Tang[TangYun]2015.02
------------------------End---------------------------
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/24930246/viewspace-1430838/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/24930246/viewspace-1430838/