ASM QUICK REF‎ > ‎

Moving ASM Database Files from one Diskgroup to Another

posted Mar 16, 2011, 6:17 AM by Sachchida Ojha
1. Identify the data files to move.

$sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Mar 16 13:19:38 2011

Copyright (c) 1982, 2009, Oracle.  All rights reserved.


Connected to:
Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning and Automatic Storage Management options

SQL> select file_name FROM dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
+DEV_DATA/stgrptdb/datafile/undotbs1.574.680483117
+DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909
+DEV_DATA/stgrptdb/datafile/ts_utils_index.441.680445857
+DEV_DATA/stgrptdb/datafile/ts_utils_data.440.680445851
+DEV_DATA/stgrptdb/datafile/ts_summ_index.439.680445801
+DEV_DATA/stgrptdb/datafile/ts_summ_data.438.680445655
+DEV_DATA/stgrptdb/datafile/ts_scpcdr_index.437.680445317
+DEV_DATA/stgrptdb/datafile/ts_scpcdr_data.436.680444999
+DEV_DATA/stgrptdb/datafile/ts_scpcdragg_index.435.680444851
+DEV_DATA/stgrptdb/datafile/ts_scpcdragg_data.434.680444507
+DEV_DATA/stgrptdb/datafile/ts_nolog_index.433.680444475

FILE_NAME
--------------------------------------------------------------------------------
+DEV_DATA/stgrptdb/datafile/ts_nolog_data.432.680444409
+DEV_DATA/stgrptdb/datafile/ts_cdr_view_index.431.680444241
+DEV_DATA/stgrptdb/datafile/ts_cdr_view_data.430.680443955
+DEV_DATA/stgrptdb/datafile/ts_voipdm_index.429.680443911
+DEV_DATA/stgrptdb/datafile/users.422.680442635
+DEV_DATA/stgrptdb/datafile/sysaux.420.680442633
+DEV_DATA/stgrptdb/datafile/undotbs1.421.680442635
+DEV_DATA/stgrptdb/datafile/system.419.680442633
+DEV_DATA/ts_scpcdragg_hourly_data01.dbf
+DEV_DATA/stgrptdb/datafile/ts_huntcdr_data_01

21 rows selected.


2. Identify the diskgroup where you need to move the data file.

SQL>  SELECT name FROM v$asm_diskgroup;

NAME
------------------------------
DEV_DATA
QA_FLASH


Let's move  +DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909 from DEV_DATA to QA_FLASH.

3. Take the file to be moved OFFLINE:

SQL> ALTER DATABASE DATAFILE '+DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909' OFFLINE;

Database altered.

4. Copy the data file from source diskgroup to destination diskgroup using RMAN

$ rman target /

connected to target database: STGRPTDB (DBID=2370649665)

RMAN> COPY DATAFILE '+DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909' TO '+QA_FLASH';
For non-OMF files, you will need to include the directory and file name when declaring the destination in the COPY DATAFILE statement. For example:

RMAN> COPY DATAFILE '+DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909' TO '+QA_FLASH/stgrptdb/datafile/ts_voipdm_data.442.680445909';

5. Now that the file has been copied, we can update the Oracle data dictionary with the location of the new ASM database file to use:

SQL> ALTER DATABASE RENAME FILE '+DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909' TO '+QA_FLASH/stgrptdb/datafile/ts_voipdm_data.442.680445909';

Database altered.

Note: After Oracle successfully renames the ASM database file in the data dictionary, it will remove the original ASM database file '+DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909'

# Use RMAN to rename the ASM database file copy

RMAN> SWITCH DATAFILE '+QA_FLASH/stgrptdb/datafile/ts_voipdm_data.442.680445909' TO COPY;

datafile 8 switched to datafile copy '+QA_FLASH/stgrptdb/datafile/ts_voipdm_data.442.680445909'

# Recovery the new ASM database file

SQL> RECOVER DATAFILE '+QA_FLASH/stgrptdb/datafile/ts_voipdm_data.442.680445909';

Media recovery complete.

# Bring the new ASM database file ONLINE

SQL> ALTER DATABASE DATAFILE '+QA_FLASH/stgrptdb/datafile/ts_voipdm_data.442.680445909' ONLINE;

Database altered.

# Verify the new ASM data file location

SQL> SELECT file_name FROM dba_data_files;

# Delete the old ASM database file from its original location

NOTE: This step was not required for the example I provided in this article. I believe (however not certain) that is related to the fact I am using Oracle Oracle10g R2. This may be a step that is required with Oracleg R1; however, I did not have a spare Oracleg R1 install sitting around to test this. I saw this step documented by Oracle; however, I believe it is not required. If you followed the steps in this article, you will remember that the original ASM database file gets removed during the ALTER DATABASE RENAME FILE statement.

Please note that if this step needs to be performed, it will need to be executed from the actual ASM instance itself:

$ ORACLE_SID=+ASM; export ORACLE_SID

$ sqlplus "/ as sysdba"

SQL> ALTER DISKGROUP TESTDB_DATA2 DROP FILE '+DEV_DATA/stgrptdb/datafile/ts_voipdm_data.442.680445909';



Comments