第一步:啟動ASM實例(+ASM)
[oracle@oracle ~]$ export ORACLE_SID=+ASM
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Jan 18 13:25:46 2011
Copyright (c) 1982, 2010, Oracle.? All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select instance_name,status from v$instance; ASM實例已經啟動
INSTANCE_NAME? STATUS
---------------- ------------
+ASM?? STARTED
SQL> select instance_name,db_name,status from v$asm_client;?ASM實例上沒有數據庫連接
no rows selected
SQL> select name,state from v$asm_diskgroup;?ASM磁盤組已經掛載
NAME????????? STATE
------------------------------ -----------
DG????????? MOUNTED
第二步,修改目標數據庫(WM)的參數文件(spfile)
[oracle@oracle ~]$ echo $ORACLE_SID
WM
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Jan 18 13:33:59 2011
Copyright (c) 1982, 2010, Oracle.? All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> show parameter control_files;
NAME???????? TYPE? VALUE
------------------------------------ ----------- ------------------------------
control_files??????? string? /u01/app/oracle/oradata/WM/con
trol01.ctl, /u01/app/oracle/or
adata/WM/control02.ctl, /u01/a
pp/oracle/oradata/WM/control03
.ctl
SQL> show parameter db_create_file_dest;
NAME???????? TYPE? VALUE
------------------------------------ ----------- ------------------------------
db_create_file_dest?????? string
SQL> create pfile from spfile;
File created.
SQL> alter system set control_files='+DG' scope=spfile;在spfile中把控制文件的路徑修改為ASM磁盤組
System altered.
SQL> alter system set db_create_file_dest='+DG' scope=spfile;同上,修改數據文件的創建路徑
System altered.
SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.
第三步,利用RMAN遷移目標數據庫(WM)的控制文件和數據文件
[oracle@oracle ~]$ rman target /
Recovery Manager: Release 10.2.0.5.0 - Production on Tue Jan 18 13:38:22 2011
Copyright (c) 1982, 2007, Oracle.? All rights reserved.
connected to target database (not started)
RMAN> startup nomount;
Oracle instance started
Total System Global Area???? 285212672 bytes
Fixed Size???????????????????? 1273276 bytes
Variable Size???????????????? 92275268 bytes
Database Buffers???????????? 188743680 bytes
Redo Buffers?????????????????? 2920448 bytes
RMAN> restore controlfile from '/u01/app/oracle/oradata/WM/control01.ctl';利用文件系統上的控制文件重建控制文件到ASM磁盤組DG上
Starting restore at 18-JAN-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=+DG/wm/controlfile/current.256.740756507
Finished restore at 18-JAN-11
RMAN> alter database mount;
database mounted
released channel: ORA_DISK_1
RMAN> run{
2> allocate channel c1 device type disk;
3> allocate channel c2 device type disk;
4> backup as copy database format '+DG';
5> }??利用RMAN復制數據文件到ASM磁盤組DG上
allocated channel: c1
channel c1: sid=156 devtype=DISK
allocated channel: c2
channel c2: sid=152 devtype=DISK
Starting backup at 18-JAN-11
channel c1: starting datafile copy
input datafile fno=00001 name=/u01/app/oracle/oradata/WM/system01.dbf
channel c2: starting datafile copy
input datafile fno=00003 name=/u01/app/oracle/oradata/WM/sysaux01.dbf
output filename=+DG/wm/datafile/sysaux.258.740756731 tag=TAG20110118T134523 recid=2 stamp=740757197
channel c2: datafile copy complete, elapsed time: 00:07:58
channel c2: starting datafile copy
input datafile fno=00005 name=/u01/app/oracle/oradata/WM/example01.dbf
output filename=+DG/wm/datafile/system.257.740756727 tag=TAG20110118T134523 recid=3 stamp=740757268
channel c1: datafile copy complete, elapsed time: 00:09:09
channel c1: starting datafile copy
input datafile fno=00002 name=/u01/app/oracle/oradata/WM/undotbs01.dbf
output filename=+DG/wm/datafile/example.259.740757205 tag=TAG20110118T134523 recid=4 stamp=740757287
channel c2: datafile copy complete, elapsed time: 00:01:30
channel c2: starting datafile copy
input datafile fno=00004 name=/u01/app/oracle/oradata/WM/users01.dbf
output filename=+DG/wm/datafile/undotbs1.260.740757277 tag=TAG20110118T134523 recid=6 stamp=740757304
channel c1: datafile copy complete, elapsed time: 00:00:32
output filename=+DG/wm/datafile/users.261.740757299 tag=TAG20110118T134523 recid=5 stamp=740757303
channel c2: datafile copy complete, elapsed time: 00:00:12
Finished backup at 18-JAN-11
Starting Control File and SPFILE Autobackup at 18-JAN-11
piece handle=/u01/app/oracle/flash_recovery_area/WM/autobackup/2011_01_18/o1_mf_s_737250559_6mbbsvw6_.bkp comment=NONE
Finished Control File and SPFILE Autobackup at 18-JAN-11
released channel: c1
released channel: c2
RMAN> switch database to copy; 利用RMAN的SWITCH 命令修改控制文件內數據文件的指針,使其指向新位置
datafile 1 switched to datafile copy "+DG/wm/datafile/system.257.740756727"
datafile 2 switched to datafile copy "+DG/wm/datafile/undotbs1.260.740757277"
datafile 3 switched to datafile copy "+DG/wm/datafile/sysaux.258.740756731"
datafile 4 switched to datafile copy "+DG/wm/datafile/users.261.740757299"
datafile 5 switched to datafile copy "+DG/wm/datafile/example.259.740757205"
RMAN> recover database;
Starting recover at 18-JAN-11
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
starting media recovery
media recovery complete, elapsed time: 00:00:01
Finished recover at 18-JAN-11
RMAN> alter database open;
database opened
第四步,遷移tempfile到ASM磁盤組DG上
[oracle@oracle ~]$ sqlplus / as sysdba
SQL*Plus: Release 10.2.0.5.0 - Production on Tue Jan 18 14:01:09 2011
Copyright (c) 1982, 2010, Oracle.? All Rights Reserved.
Connected to:
Oracle Database 10g Enterprise Edition Release 10.2.0.5.0 - Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options
SQL> select instance_name,status from v$instance;
INSTANCE_NAME? STATUS
---------------- ------------
WM?? OPEN
SQL> select name,status,enabled from v$tempfile;
NAME????? STATUS? ENABLED
---------------------------------------- ------- ----------
/u01/app/oracle/oradata/WM/temp01.dbf? ONLINE? READ WRITE
SQL> alter tablespace temp add tempfile '+DG';
Tablespace altered.
SQL> alter tablespace temp drop tempfile '/u01/app/oracle/oradata/WM/temp01.dbf';
Tablespace altered.
SQL> select name,status,enabled from v$tempfile;
NAME????? STATUS? ENABLED
---------------------------------------- ------- ----------
+DG/wm/tempfile/temp.262.740757907? ONLINE? READ WRITE
第五步,遷移redo logfile到ASM磁盤組DG上
SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;
GROUP#? SEQUENCE# NAME?????????? STATUS??ARC
---------- ---------- ---------------------------------------- ---------------- ---
3???? 6 /u01/app/oracle/oradata/WM/redo03.log??? CURRENT??NO
2???? 5 /u01/app/oracle/oradata/WM/redo02.log??? INACTIVE ?YES
1???? 4 /u01/app/oracle/oradata/WM/redo01.log??? INACTIVE ?YES
SQL> alter database add logfile '+DG' size 10M;
Database altered.
SQL> alter database add logfile '+DG' size 10M;
Database altered.
SQL> alter database add logfile '+DG' size 10M;?添加三個redolog組到ASM磁盤組DG上
Database altered.
SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;
GROUP#? SEQUENCE# NAME?????????? STATUS??ARC
---------- ---------- ---------------------------------------- ---------------- ---
3???? 6 /u01/app/oracle/oradata/WM/redo03.log??? CURRENT??NO
2???? 5 /u01/app/oracle/oradata/WM/redo02.log??? INACTIVE ?YES
1???? 4 /u01/app/oracle/oradata/WM/redo01.log??? INACTIVE ?YES
4???? 0 +DG/wm/onlinelog/group_4.263.740758405?? UNUSED??YES
5???? 0 +DG/wm/onlinelog/group_5.264.740758423?? UNUSED??YES
6???? 0 +DG/wm/onlinelog/group_6.265.740758425?? UNUSED??YES
6 rows selected.
SQL> alter database drop logfile '/u01/app/oracle/oradata/WM/redo02.log';
Database altered.
SQL> alter database drop logfile '/u01/app/oracle/oradata/WM/redo01.log';刪除文件系統上的redolog組
Database altered.
SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;
GROUP#? SEQUENCE# NAME?????????? STATUS??ARC
---------- ---------- ---------------------------------------- ---------------- ---
3???? 6 /u01/app/oracle/oradata/WM/redo03.log??? CURRENT??NO
4???? 0 +DG/wm/onlinelog/group_4.263.740758405?? UNUSED??YES
5???? 0 +DG/wm/onlinelog/group_5.264.740758423?? UNUSED??YES
6???? 0 +DG/wm/onlinelog/group_6.265.740758425?? UNUSED??YES
SQL> alter system switch logfile;
System altered.
SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;
GROUP#? SEQUENCE# NAME?????????? STATUS??ARC
---------- ---------- ---------------------------------------- ---------------- ---
3???? 6 /u01/app/oracle/oradata/WM/redo03.log??? ACTIVE??NO
4???? 7 +DG/wm/onlinelog/group_4.263.740758405?? CURRENT??NO
5???? 0 +DG/wm/onlinelog/group_5.264.740758423?? UNUSED??YES
6???? 0 +DG/wm/onlinelog/group_6.265.740758425?? UNUSED??YES
SQL> alter system checkpoint;
System altered.
SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;
GROUP#? SEQUENCE# NAME?????????? STATUS??ARC
---------- ---------- ---------------------------------------- ---------------- ---
3???? 6 /u01/app/oracle/oradata/WM/redo03.log??? INACTIVE ?NO
4???? 7 +DG/wm/onlinelog/group_4.263.740758405?? CURRENT??NO
5???? 0 +DG/wm/onlinelog/group_5.264.740758423?? UNUSED??YES
6???? 0 +DG/wm/onlinelog/group_6.265.740758425?? UNUSED??YES
SQL> alter database drop logfile group 3;
Database altered.
SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;
GROUP#? SEQUENCE# NAME?????????? STATUS??ARC
---------- ---------- ---------------------------------------- ---------------- ---
4???? 7 +DG/wm/onlinelog/group_4.263.740758405?? CURRENT??NO
5???? 0 +DG/wm/onlinelog/group_5.264.740758423?? UNUSED??YES
6???? 0 +DG/wm/onlinelog/group_6.265.740758425?? UNUSED??YES
SQL> alter system switch logfile;
System altered.
SQL> alter system switch logfile;
System altered.
SQL> select l.group#,l.sequence#,f.member as name,l.status,l.archived from v$log l,v$logfile f where f.group#=l.group#;
GROUP#? SEQUENCE# NAME?????????? STATUS??ARC
---------- ---------- ---------------------------------------- ---------------- ---
4???? 7 +DG/wm/onlinelog/group_4.263.740758405?? ACTIVE??NO
5???? 8 +DG/wm/onlinelog/group_5.264.740758423?? ACTIVE??NO
6???? 9 +DG/wm/onlinelog/group_6.265.740758425?? CURRENT??NO
第六步,刪除文件系統上的數據文件
[oracle@oracle oradata]$ cd $ORACLE_BASE/oradata
[oracle@oracle oradata]$ ls
WM
[oracle@oracle oradata]$ rm -rf WM/
[oracle@oracle oradata]$ ls