1> asm实例环境
[oracle@liuxiong ~]$ export ORACLE_SID=+ASM                     //设置ASM实例环境变量
[oracle@liuxiong ~]$ sqlplus / as sysdba
[uniread] Loaded history (0 lines)
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 16 17:43:30 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
SQL> select instance_name,status from v$instance;

INSTANCE_NAME  STATUS
---------------- ------------
+ASM   STARTED

SQL> select name,state,total_mb,free_mb from v$asm_diskgroup;    //查看ASM磁盘组信息

NAME          STATE      TOTAL_MB  FREE_MB
------------------------------ ----------- ---------- ----------
DATA1          MOUNTED   3922     3820

SQL> col path format a12
SQL> select state,total_mb,free_mb,name,path from v$asm_disk;    //查看ASM磁盘信息

STATE    TOTAL_MB    FREE_MB NAME         PATH
-------- ---------- ---------- ------------------------------ ------------
NORMAL        1961   1910 VOL1         ORCL:VOL1
NORMAL        1961   1910 VOL2         ORCL:VOL2

2> 迁移在线重做日志文件
[oracle@liuxiong ~]$ export ORACLE_SID=oradb
[oracle@liuxiong ~]$ sqlplus / as sysdba
[uniread] Loaded history (0 lines)
SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 16 17:43:30 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.

SQL> select instance_name,status from v$instance;

INSTANCE_NAME  STATUS
---------------- ------------
oradb   OPEN

SQL> select group#,status,type,member from v$logfile;         //查看当前使用的日志文件

GROUP# STATUS  TYPE    MEMBER
------ ------- ------- ---------------------------------------------
     3        ONLINE  /u01/oracle/product/oradata/oradb/redo03.log
     2        ONLINE  /u01/oracle/product/oradata/oradb/redo02.log
     1 STALE   ONLINE  /u01/oracle/product/oradata/oradb/redo01.log

SQL> show parameter create_online                             //查看日志文件存储参数设置

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
db_create_online_log_dest_1      string
db_create_online_log_dest_2      string
db_create_online_log_dest_3      string
db_create_online_log_dest_4      string
db_create_online_log_dest_5      string

SQL> alter system set db_create_online_log_dest_1='+DATA1';  //修改连接重做日志文件创建路径到ASM磁盘组
System altered.
SQL> alter system set db_create_file_dest='+DATA1';          //修改数据文件的创建路径
System altered.
SQL> alter system set db_recovery_file_dest='+DATA1';        //修改回滚数据文件存储路径
System altered.

SQL> show parameter db_create                                //查看设置后的结果

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest       string  +DATA1
db_create_online_log_dest_1      string  +DATA1
db_create_online_log_dest_2      string
db_create_online_log_dest_3      string
db_create_online_log_dest_4      string
db_create_online_log_dest_5      string

SQL> show parameter db_recovery                               //查看设置后的结果

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
db_recovery_file_dest       string  +DATA1
db_recovery_file_dest_size      big integer 2G

SQL> alter database add logfile group 4 size 30M;      //添加连机重做日志文件4,并指定大小为30M
Database altered.
SQL> alter database add logfile group 5 size 30M;      //添加连机重做日志文件5,并指定大小为30M
Database altered.
SQL> alter database add logfile group 6 size 30M;      //添加连机重做日志文件6,并指定大小为30M
Database altered.
SQL> select group#,status from v$log;                  //查看添加后的日志文件,及当前使用日志文件

GROUP# STATUS
------ ----------------
     1 INACTIVE
     2 CURRENT                                         //组2为当前连机日志文件
     3 INACTIVE
     4 UNUSED
     5 UNUSED
     6 UNUSED

6 rows selected.

SQL> select group#,status,type,member from v$logfile;  //查看新添加的重做日志文件存放路径

GROUP# STATUS  TYPE    MEMBER
------ ------- ------- ---------------------------------------------
     3        ONLINE  /u01/oracle/product/oradata/oradb/redo03.log
     2        ONLINE  /u01/oracle/product/oradata/oradb/redo02.log
     1 STALE   ONLINE  /u01/oracle/product/oradata/oradb/redo01.log
     4        ONLINE  +DATA1/oradb/onlinelog/group_4.256.762028249
     5        ONLINE  +DATA1/oradb/onlinelog/group_5.257.762028271
     6        ONLINE  +DATA1/oradb/onlinelog/group_6.258.762028305

SQL> alter database drop logfile group 1;              //删除未使用的重做日志文件1
Database altered.
SQL> alter database drop logfile group 3;              //删除未使用的重做日志文件2
Database altered.
SQL> alter system switch logfile;                      //手动进行日志切换
System altered.
SQL> alter system checkpoint;                          //手动触发检查点,将日志数据文件写入磁盘
System altered.
SQL> select group#,status from v$log;                  //查看当前使用日志文件

GROUP# STATUS
------ ----------------
     2 INACTIVE
     4 CURRENT
     5 UNUSED
     6 UNUSED

SQL> alter database drop logfile group 2;              //删除重做日志文件2
Database altered.

SQL> select group#,status,type,member from v$logfile;  //检验重做日志文件的迁移结果

GROUP# STATUS  TYPE    MEMBER
------ ------- ------- ---------------------------------------------
     4        ONLINE  +DATA1/oradb/onlinelog/group_4.256.762028249
     5        ONLINE  +DATA1/oradb/onlinelog/group_5.257.762028271
     6        ONLINE  +DATA1/oradb/onlinelog/group_6.258.762028305


SQL> show parameter control                             //查看当前控制文件

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time      integer  7
control_files        string  /u01/oracle/product/oradata/or
       adb/control01.ctl, /u01/oracle
       /product/oradata/oradb/control
       02.ctl, /u01/oracle/product/or
       adata/oradb/control03.ctl

SQL> alter system set control_files='+DATA1' scope=spfile;     //修改控制文件 存储到ASMD磁盘组

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
3> 迁移数据文件与控制文件到ASM磁盘组
[oracle@liuxiong /]$ rman target/

Recovery Manager: Release 10.2.0.1.0 - Production on Fri Sep 16 19:12:44 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
connected to target database (not started)

RMAN> startup nomount;
RMAN> restore controlfile from '/u01/oracle/product/oradata/oradb/control01.ctl';  //利用文件系统上的控制文件重建控制文件到ASM磁盘组
Starting restore at 16-SEP-11
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=/u01/oracle/product/10g/dbs/DATA1
Finished restore at 16-SEP-11

RMAN> alter database mount;

RMAN> run{                                                                        //备份数据文件到ASM磁盘组
2> allocate channel c1 device type disk;
3> allocate channel c2 device type disk;
4> backup as copy database format '+DATA1';
5> }

using target database control file instead of recovery catalog
allocated channel: c1
channel c1: sid=155 devtype=DISK
allocated channel: c2
channel c2: sid=156 devtype=DISK
Starting backup at 16-SEP-11
channel c1: starting datafile copy
input datafile fno=00001 name=/u01/oracle/product/oradata/oradb/system01.dbf
channel c2: starting datafile copy
output filename=+DATA1/oradb/datafile/sysaux.266.762031105 tag=TAG20110916T191816 recid=8 stamp=762031163
channel c2: datafile copy complete, elapsed time: 00:01:16
channel c2: starting datafile copy
input datafile fno=00005 name=/u01/oracle/product/oradata/oradb/example01.dbf
output filename=+DATA1/oradb/datafile/system.265.762031103 tag=TAG20110916T191816 recid=9 stamp=762031173
channel c1: datafile copy complete, elapsed time: 00:01:19
channel c1: starting datafile copy
input datafile fno=00002 name=/u01/oracle/product/oradata/oradb/undotbs01.dbf
output filename=+DATA1/oradb/datafile/undotbs1.268.762031177 tag=TAG20110916T191816 recid=10 stamp=762031183
channel c1: datafile copy complete, elapsed time: 00:00:15
channel c1: starting datafile copy
input datafile fno=00004 name=/u01/oracle/product/oradata/oradb/users01.dbf
output filename=+DATA1/oradb/datafile/example.267.762031177 tag=TAG20110916T191816 recid=11 stamp=762031189
channel c2: datafile copy complete, elapsed time: 00:00:18
channel c2: starting datafile copy
copying current control file
output filename=+DATA1/oradb/datafile/users.269.762031193 tag=TAG20110916T191816 recid=13 stamp=762031194
channel c1: datafile copy complete, elapsed time: 00:00:03
channel c1: starting full datafile backupset
channel c1: specifying datafile(s) in backupset
output filename=+DATA1/oradb/controlfile/backup.270.762031193 tag=TAG20110916T191816 recid=12 stamp=762031194
channel c2: datafile copy complete, elapsed time: 00:00:04
including current SPFILE in backupset
channel c1: starting piece 1 at 16-SEP-11
channel c1: finished piece 1 at 16-SEP-11
piece handle=+DATA1/oradb/backupset/2011_09_16/nnsnf0_tag20110916t191816_0.271.762031197 tag=TAG20110916T191816 comment=NONE
channel c1: backup set complete, elapsed time: 00:00:02
Finished backup at 16-SEP-11
released channel: c1
released channel: c2

RMAN> switch database to copy;                   //利用RMAN的SWITCH 命令修改控制文件内数据文件的指针,使其指向新位置.

datafile 1 switched to datafile copy "+DATA1/oradb/datafile/system.265.762031103"
datafile 2 switched to datafile copy "+DATA1/oradb/datafile/undotbs1.268.762031177"
datafile 3 switched to datafile copy "+DATA1/oradb/datafile/sysaux.266.762031105"
datafile 4 switched to datafile copy "+DATA1/oradb/datafile/users.269.762031193"
datafile 5 switched to datafile copy "+DATA1/oradb/datafile/example.267.762031177"

RMAN> recover database;                          //恢复当前数据库文件

Starting recover at 16-SEP-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=155 devtype=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:00
Finished recover at 16-SEP-11

RMAN> alter database open;                        //打开数据库
database opened
RMAN>exit

oracle@liuxiong ~]$ sqlplus / as sysdba
SQL> col file_name format a42
SQL> col tablespace_name format a14
SQL> select file_name,tablespace_name from dba_data_files;         //验证数据文件的迁移

FILE_NAME       TABLESPACE_NAM
------------------------------------------ --------------
+DATA/oradb/datafile/users.264.762003057   USERS
+DATA/oradb/datafile/sysaux.261.762002983  SYSAUX
+DATA/oradb/datafile/undotbs1.263.76200305 UNDOTBS17
+DATA/oradb/datafile/system.260.762002983  SYSTEM
+DATA/oradb/datafile/example.262.762003035 EXAMPLE
SQL> show parameter control;                                       //验证控制文件的迁移

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time      integer  7
control_files        string  +DATA/oradb/controlfile/backup
       .259.762002877
4> 迁移参数文件
SQL> create pfile from spfile;
File created.
SQL> show parameter spfile

NAME               TYPE         VALUE
------------------ ----------- --------------------------------------------
spfile             string      /u01/oracle/product/10g/dbs/spfileoradb.ora

SQL> create spfile='+DATA' from pfile;                                    //创建ASM磁盘上参数文件(spfile.268.762004477)
File created.
[oracle@cent4 dbs]$ rm -rf /u01/oracle/product/10g/dbs/spfileoradb.ora    //删除SP参数文件。
[root@liuxiong dbs]# vi initoradb.ora                                     //将参数文件修改成以下内容:
spfile=+data/oradb/parameterfile/spfile.268.762004477                     //注:此spfile.268.762004477 参数文件通过以下方式查看得到

[oracle@liuxiong /]$ export ORACLE_SID=+ASM
[oracle@liuxiong /]$ asmcmd
ASMCMD> cd +data/oradb/parameterfile
ASMCMD> ls
spfile.268.762004477

SQL> show parameter spfile;                                                //数据库重启后,验证参数文件迁移.

NAME         TYPE  VALUE
------------------------------------ ----------- ------------------------------
spfile         string  +DATA/oradb/parameterfile/spfile.268.762004477

5> 迁移TEMFPILE到ASM磁盘组DATA.
[oracle@liuxiong ~]$ sqlplus / as sysdba

SQL*Plus: Release 10.2.0.1.0 - Production on Fri Sep 16 11:35:33 2011
Copyright (c) 1982, 2005, Oracle.  All rights reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options

SQL> select name,status,enabled from v$tempfile;

   NAME         STATUS                 ENABLED
  -------       ----------              -----------

/u01/oracle/product/oradata/oradb/temp01.dbf   ONLINE READ WRITE

SQL> alter tablespace temp add tempfile '+DATA';
Tablespace altered.

SQL> ALTER tablespace temp drop tempfile '/u01/oracle/product/oradata/oradb/temp01.dbf';
Tablespace altered.

SQL> select name,status,enabled from v$tempfile;             //验证临时表空间文件迁移

NAME                                      STATUS ENABLED
---------------------- ---------------    -------       ----------
+DATA/oradb/tempfile/temp.267.762003421   ONLINE READ WRITE