首先在虚拟机中加入两个虚拟磁盘再创建额外的Diskgroup,然后模拟将一数据文件从一个ASM Diskgroup移动到另一个ASM Diskgroup上。
过程如下:
加入两个虚拟磁盘,各512M。
[root@Ora10gASM ~]# fdisk -l
Disk /dev/sda: 8589 MB, 8589934592 bytes
255 heads, 63 sectors/track, 1044 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sda1 * 1 13 104391 83 Linux
/dev/sda2 14 1044 8281507+ 8e Linux LVM
Disk /dev/sdb: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdb1 1 522 4192933+ 83 Linux
Disk /dev/sdc: 4294 MB, 4294967296 bytes
255 heads, 63 sectors/track, 522 cylinders
Units = cylinders of 16065 * 512 = 8225280 bytes
Device Boot Start End Blocks Id System
/dev/sdc1 1 522 4192933+ 83 Linux
Disk /dev/sdd: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk /dev/sdd doesn't contain a valid partition table
Disk /dev/sde: 536 MB, 536870912 bytes
64 heads, 32 sectors/track, 512 cylinders
Units = cylinders of 2048 * 512 = 1048576 bytes
Disk /dev/sde doesn't contain a valid partition table
创建磁盘分区
[root@Ora10gASM ~]# fdisk /dev/sdd
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): 1
First cylinder (1-512, default 1):
Using default value 1
Last cylinder or +size or +sizeM or +sizeK (1-512, default 512):
Using default value 512
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
[root@Ora10gASM ~]# fdisk /dev/sde
Device contains neither a valid DOS partition table, nor Sun, SGI or OSF disklabel
Building a new DOS disklabel. Changes will remain in memory only,
until you decide to write them. After that, of course, the previous
content won't be recoverable.
Warning: invalid flag 0x0000 of partition table 4 will be corrected by w(rite)
Command (m for help): n
Command action
e extended
p primary partition (1-4)
p
Partition number (1-4): q
Partition number (1-4): 1
First cylinder (1-512, default 1): 1
Last cylinder or +size or +sizeM or +sizeK (1-512, default 512): 512
Command (m for help): w
The partition table has been altered!
Calling ioctl() to re-read partition table.
Syncing disks.
创建ASM磁盘
[root@Ora10gASM ~]# /etc/init.d/oracleasm scandisk
Usage:
/etc/init.d/oracleasm
{start|stop|restart|enable|disable|configure|createdisk|deletedisk|querydisk|listdisks|scandisks|status}
[root@Ora10gASM ~]# /etc/init.d/oracleasm scandisks
Scanning system for ASM disks: [ OK ]
[root@Ora10gASM ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
[root@Ora10gASM ~]# /etc/init.d/oracleasm createdisk VOL3 /dev/sdd1
Marking disk "/dev/sdd1" as an ASM disk: [ OK ]
[root@Ora10gASM ~]# /etc/init.d/oracleasm createdisk VOL4 /dev/sde1
Marking disk "/dev/sde1" as an ASM disk: [ OK ]
[root@Ora10gASM ~]# /etc/init.d/oracleasm listdisks
VOL1
VOL2
VOL3
VOL4
创建额外的磁盘组DATA2
Ora10gASM-> export ORACLE_SID=+ASM
Ora10gASM-> sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 28 19:30:15 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ASM instance started
Total System Global Area 83886080 bytes
Fixed Size 1217836 bytes
Variable Size 57502420 bytes
ASM Cache 25165824 bytes
ASM diskgroups mounted
SQL> col name format a15
SQL> col failgroup format a20
SQL> col path format a30
SQL> select name,failgroup,path from v$asm_disk;
NAME FAILGROUP PATH
--------------- -------------------- ------------------------------
ORCL:VOL3
ORCL:VOL4
VOL1 VOL1 ORCL:VOL1
VOL2 VOL2 ORCL:VOL2
SQL> select name from v$asm_diskgroup;
NAME
---------------
DATA
FRA
SQL> create diskgroup DATA2 external redundancy disk 'ORCL:VOL3';
Diskgroup created.
SQL> select name,failgroup,path from v$asm_disk;
NAME FAILGROUP PATH
--------------- -------------------- ------------------------------
ORCL:VOL4
VOL1 VOL1 ORCL:VOL1
VOL2 VOL2 ORCL:VOL2
VOL3 VOL3 ORCL:VOL3
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
创建额外的数据文件在DATA上,将被移动DATA2上
Ora10gASM-> export ORACLE_SID=benbo
Ora10gASM-> sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 28 19:44:46 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startup
ORACLE instance started.
Total System Global Area 205520896 bytes
Fixed Size 1218532 bytes
Variable Size 67110940 bytes
Database Buffers 134217728 bytes
Redo Buffers 2973696 bytes
Database mounted.
Database opened.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/benbo/datafile/system.268.655859413
+DATA/benbo/datafile/undotbs1.270.655859475
+DATA/benbo/datafile/sysaux.269.655859449
+DATA/benbo/datafile/users.271.655859485
SQL> create tablespace benbo datafile '+DATA' size 100m autoextend off;
Tablespace created.
SQL> create table t1 tablespace benbo as select * from dba_extents;
Table created.
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/benbo/datafile/system.268.655859413
+DATA/benbo/datafile/undotbs1.270.655859475
+DATA/benbo/datafile/sysaux.269.655859449
+DATA/benbo/datafile/users.271.655859485
+DATA/benbo/datafile/benbo.281.655933629
SQL> alter database datafile '+DATA/benbo/datafile/benbo.281.655933629' offline;
Database altered.
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
Ora10gASM-> rman target /
Recovery Manager: Release 10.2.0.1.0 - Production on Wed May 28 19:49:14 2008
Copyright (c) 1982, 2005, Oracle. All rights reserved.
connected to target database: BENBO (DBID=2376804766)
RMAN> copy datafile '+DATA/benbo/datafile/benbo.281.655933629' to '+DATA2';
Starting backup at 28-MAY-08
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=158 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=+DATA/benbo/datafile/benbo.281.655933629
output filename=+DATA2/benbo/datafile/benbo.256.655933781 tag=TAG20080528T194940 recid=12 stamp=655933788
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15
Finished backup at 28-MAY-08
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** +DATA/benbo/datafile/system.268.655859413
2 25 UNDOTBS1 *** +DATA/benbo/datafile/undotbs1.270.655859475
3 240 SYSAUX *** +DATA/benbo/datafile/sysaux.269.655859449
4 5 USERS *** +DATA/benbo/datafile/users.271.655859485
5 100 BENBO *** +DATA/benbo/datafile/benbo.281.655933629
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
2 100 TEMP 100 +DATA/benbo/tempfile/temp.274.655859687
RMAN> switch datafile 5 to copy;
datafile 5 switched to datafile copy "+DATA2/benbo/datafile/benbo.256.655933781"
RMAN> sql "alter database datafile 5 online";
sql statement: alter database datafile 5 online
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03009: failure of sql command on default channel at 05/28/2008 19:52:16
RMAN-11003: failure during parse/execution of SQL statement: alter database datafile 5 online
ORA-01113: file 5 needs media recovery
ORA-01110: data file 5: '+DATA2/benbo/datafile/benbo.256.655933781'
RMAN> recover datafile 5;
Starting recover at 28-MAY-08
using channel ORA_DISK_1
starting media recovery
media recovery complete, elapsed time: 00:00:03
Finished recover at 28-MAY-08
RMAN> sql "alter database datafile 5 online";
sql statement: alter database datafile 5 online
RMAN> report schema;
Report of database schema
List of Permanent Datafiles
===========================
File Size(MB) Tablespace RB segs Datafile Name
---- -------- -------------------- ------- ------------------------
1 480 SYSTEM *** +DATA/benbo/datafile/system.268.655859413
2 25 UNDOTBS1 *** +DATA/benbo/datafile/undotbs1.270.655859475
3 240 SYSAUX *** +DATA/benbo/datafile/sysaux.269.655859449
4 5 USERS *** +DATA/benbo/datafile/users.271.655859485
5 100 BENBO *** +DATA2/benbo/datafile/benbo.256.655933781
List of Temporary Files
=======================
File Size(MB) Tablespace Maxsize(MB) Tempfile Name
---- -------- -------------------- ----------- --------------------
2 100 TEMP 100 +DATA/benbo/tempfile/temp.274.655859687
RMAN> exit
Recovery Manager complete.
Ora10gASM-> sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 28 19:53:16 2008
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 file_id,status from dba_data_files;
FILE_ID STATUS
---------- ---------
5 AVAILABLE
4 AVAILABLE
3 AVAILABLE
2 AVAILABLE
1 AVAILABLE
SQL> select name from v$datafile;
NAME
--------------------------------------------------------------------------------
+DATA/benbo/datafile/system.268.655859413
+DATA/benbo/datafile/undotbs1.270.655859475
+DATA/benbo/datafile/sysaux.269.655859449
+DATA/benbo/datafile/users.271.655859485
+DATA2/benbo/datafile/benbo.256.655933781
SQL> exit
Disconnected from Oracle Database 10g Enterprise Edition Release 10.2.0.1.0 - Production
With the Partitioning, OLAP and Data Mining options
删除旧的DATA上的数据文件BENBO.281.655933629
Ora10gASM-> asmcmd
ASMCMD> ls DATA/BENBO/DATAFILE
BENBO.281.655933629
SYSAUX.269.655859449
SYSTEM.268.655859413
UNDOTBS1.270.655859475
USERS.266.655858163
USERS.271.655859485ASMCMD> exit
Ora10gASM-> sqlplus "/ as sysdba"
SQL*Plus: Release 10.2.0.1.0 - Production on Wed May 28 19:55:03 2008
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> alter diskgroup DATA drop file '+DATA/benbo/datafile/BENBO.281.655933629';
Diskgroup altered.
来自 “ ITPUB博客 ” ,链接:https://blog.itpub.net/90618/viewspace-692426/ ,如需转载,请注明出处,否则将追究法律责任。