将数据库从文件系统迁移到ASM存储里(单实例)http://space.itpub.net/22779291
建立ASM实例可以用DBCA进行创建。ASM磁盘组里面的文件不能通过普通操作系统命令访问,因此在移动数据文件的时候需要通过RMAN来实现。
在迁移之前,关闭闪回数据库功能。
基本步骤:
1。修改参数:db_create_file_dest,db_create_online_log_dest_n,db_recovery_file_dest(确保两个OMF参数指向了ASM磁盘组,这样可以使用基于OMF的文件系统)
2。备份控制文件
3。用RMAN复原控制文件
4。将数据文件移动到ASM磁盘组
5。更改日志路径
6。打开数据库
操作记录:
1。修改参数
SQL> alter system set db_create_file_dest='+DATA' scope=spfile;
System altered.
SQL> alter system set control_files='+DATA' scope=spfile;
System altered.
SQL> alter system set db_recovery_file_dest='+FLASH' scope=both;
System altered.。
2。备份控制文件
SQL> alter database backup controlfile to '/opt/oracle/coolback/control.ctl';
oracle@linux-rpu7:~/coolback> cd /opt/oracle/product/10.2/db_1/bin/
oracle@linux-rpu7:~/product/10.2/db_1/bin> ./rman target /
Recovery Manager: Release 10.2.0.4.0 - Production on Fri May 28 17:01:52 2010
Copyright (c) 1982, 2007, Oracle. All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
Oracle instance started
Total System Global Area 167772160 bytes
Fixed Size 1266392 bytes
Variable Size 109055272 bytes
Database Buffers 54525952 bytes
Redo Buffers 2924544 bytes
3。复原控制文件
RMAN> restore controlfile from '/opt/oracle/coolback/control.ctl';
Starting restore at 28-MAY-10
using target database control file instead of recovery catalog
alloc。 ated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: copied control file copy
output filename=+DATA/tmorcl/controlfile/current.256.720205379
Finished restore at 28-MAY-10
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
4。移动数据文件
RMAN> backup as copy database format '+DATA';
Starting backup at 28-MAY-10
Starting implicit crosscheck backup at 28-MAY-10
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
Crosschecked 10 objects
Finished implicit crosscheck backup at 28-MAY-10
Starting implicit crosscheck copy at 28-MAY-10
using channel ORA_DISK_1
Finished implicit crosscheck copy at 28-MAY-10
searching for all files in the recovery area
cataloging files...
no files cataloged
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/opt/oracle/oradata/tmorcl/system01.dbf
output filename=+DATA/tmorcl/datafile/system.257.720205483 tag=TAG20100528T170442 recid=36 stamp=720205514
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/opt/oracle/oradata/tmorcl/users01.dbf
output filename=+DATA/tmorcl/datafile/users.258.720205521 tag=TAG20100528T170442 recid=37 stamp=720205537
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/opt/oracle/oradata/tmorcl/sysaux01.dbf
output filename=+DATA/tmorcl/datafile/sysaux.259.720205545 tag=TAG20100528T170442 recid=38 stamp=720205565
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/opt/oracle/oradata/tmorcl/undotbs01.dbf
output filename=+DATA/tmorcl/datafile/undotbs1.260.720205569 tag=TAG20100528T170442 recid=39 stamp=720205588
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00007 name=/opt/oracle/oradata/tmorcl/low.dbf
output filename=+DATA/tmorcl/datafile/low.261.720205595 tag=TAG20100528T170442 recid=40 stamp=720205595
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
Finished backup at 28-MAY-10
RMAN-06497: WARNING: control file is not current, control file autobackup skipped
RMAN> recover database;
Starting recover at 28-MAY-10
using channel ORA_DISK_1
starting media recovery
archive log thread 1 sequence 5 is already on disk as file /opt/oracle/oradata/tmorcl/redo02.log
archive log filename=/opt/oracle/oradata/tmorcl/redo02.log thread=1 sequence=5
media recovery complete, elapsed time: 00:00:03
Finished recover at 28-MAY-10
移动临时文件
RMAN> run{
2> switch tempfile 1 to '+DATA';
3> }
using target database control file instead of recovery catalog
renamed temporary file 1 to +DATA in control file
将所有的数据文件转换到ASM磁盘组中
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/tmorcl/datafile/system.257.720205483"
datafile 2 switched to datafile copy "+DATA/tmorcl/datafile/undotbs1.260.720205569"
datafile 3 switched to datafile copy "+DATA/tmorcl/datafile/sysaux.259.720205545"
datafile 4 switched to datafile copy "+DATA/tmorcl/datafile/users.258.720205521"
datafile 7 switched to datafile copy "+DATA/tmorcl/datafile/low.261.720205595"
5。更改日志文件
SQL> conn / as sysdba
Connected.
SQL> alter database rename file '/opt/oracle/oradata/tmorcl/redo01.log' to '+DATA';
Database altered.
SQL> alter database rename file '/opt/oracle/oradata/tmorcl/redo02.log' to '+DATA';
Database altered.
SQL> alter database rename file '/opt/oracle/oradata/tmorcl/redo03.log' to '+DATA';
Database altered.
6 开启数据库
SQL> alter database open resetlogs;
Database altered.
SQL> select name from v$datafile union
2 select name from v$controlfile union
3 select member from v$logfile;
NAME
---------------。-----------------------------------------------------------------
+DATA/tmorcl/controlfile/current.256.720205379
+DATA/tmorcl/datafile/low.261.720205595
+DATA/tmorcl/datafile/sysaux.259.720205545
+DATA/tmorcl/datafile/system.257.720205483
+DATA/tmorcl/datafile/undotbs1.260.720205569
+DATA/tmorcl/datafile/users.258.720205521
+DATA/tmorcl/onlinelog/group_1.262.720206647
+DATA/tmorcl/onlinelog/group_2.263.720206655
+DATA/tmorcl/onlinelog/group_3.264.720206661
+FLASH/tmorcl/onlinelog/group_1.256.720206651
+FLASH/tmorcl/onlinelog/group_2.257.720206659
NAME
--------------------------------------------------------------------------------
+FLASH/tmorcl/onlinelog/group_3.258.720206665
12 rows selected.
SQL>
来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/22779291/viewspace-663897/,如需转载,请注明出处,否则将追究法律责任。
转载于:http://blog.itpub.net/22779291/viewspace-663897/