实验目的:在ASM存储环境下,要删除一个磁盘组,从而将磁盘组中的数据文件移动到另外一个磁盘组中。
查看数据文件存放的位置:
SQL> select file#,name from v$datafile;
FILE# NAME
----- ----------------------------------------
1 +ASM/orcl/datafile/system.271.847398023
2 +ASM/orcl/datafile/undotbs1.273.84739817
1
3 +ASM/orcl/datafile/sysaux.272.847398127
4 +ASM/orcl/datafile/users.276.847398185
5 +KEL/orcl/datafile/kel.259.850521765
6 +ASM/orcl/datafile/kelly.275.847398181
6 rows selected.
在rman中将数据文件offline:
RMAN> sql "alter database datafile 5 offline";
using target database control file instead of recovery catalog
sql statement: alter database datafile 5 offline
将数据文件进行拷贝另外的ASM磁盘组中:
RMAN> run
2> {
3> copy datafile 5 to '+ASM';
4> }
Starting backup at 18-JUN-14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=143 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=+KEL/orcl/datafile/kel.259.850521765
output filename=+ASM/orcl/datafile/kel.274.850522625 tag=TAG20140618T001659 recid=41 stamp=850522627
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:11
Finished backup at 18-JUN-14
Starting Control File and SPFILE Autobackup at 18-JUN-14
piece handle=+ASM/orcl/autobackup/2014_06_18/s_850522631.268.850522635 comment=NONE
Finished Control File and SPFILE Autobackup at 18-JUN-14
在asmcmd中查看新生成的数据文件名称:
ASMCMD> ls
KEL.274.850522625
KELLY.275.847398181
SYSAUX.272.847398127
SYSTEM.271.847398023
UNDOTBS1.273.847398171
USERS.276.847398185
通知控制文件,路径修改:
RMAN> run
2> {
3> switch datafile 5 to datafilecopy '+asm/orcl/datafile/KEL.274.850522625';
4> }
datafile 5 switched to datafile copy
input datafile copy recid=41 stamp=850522627 filename=+ASM/orcl/datafile/kel.274.850522625
恢复数据文件:
RMAN> recover datafile 5;
Starting recover at 18-JUN-14
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 18-JUN-14
将数据文件online:
RMAN> sql "alter database datafile 5 online";
sql statement: alter database datafile 5 online
再次查看数据文件位置:
SQL> select file#,name from v$datafile;
FILE# NAME
----- ----------------------------------------
1 +ASM/orcl/datafile/system.271.847398023
2 +ASM/orcl/datafile/undotbs1.273.84739817
1
3 +ASM/orcl/datafile/sysaux.272.847398127
4 +ASM/orcl/datafile/users.276.847398185
5 +ASM/orcl/datafile/kel.274.850522625
6 +ASM/orcl/datafile/kelly.275.847398181
6 rows selected.
删除磁盘组:
SQL> drop diskgroup kel including contents;
Diskgroup dropped.
重新创建磁盘组:
SQL> create diskgroup KEL external redundancy disk 'ORCL:KEL1','ORCL:KEL2','ORCL:KEL3';
Diskgroup created.
创建磁盘组的时候很奇怪,每次这个路径需要用不同的方式来进行尝试:以下面的路径为准:
SQL> select path from v$asm_disk;
PATH
--------------------------------------------------------------------------------
ORCL:KEL1
ORCL:KEL2
ORCL:KEL3
ORCL:DATA
ORCL:OCR_VOTE