Migrating Databases from non-ASM to ASM and Vice-Versa

by Jeff Hunter, Sr. Database Administrator

Contents 1. 2. 3. 4. Overview Current Configuration Migrating Oracle Database from Local File System to ASM Migrating Oracle Database from ASM to Local File System

Overview Automatic Storage Management (ASM) was introduced in Oracle10g Release 1 and is used to alleviate the DBA from having to manage individual files and drives. ASM is built into the Oracle kernel and provides the DBA with a way to manage thousands of disk drives 24x7 for both single and clustered instances of Oracle. Essentially, ASM is a file system / volume manager for all Oracle physical database files (datafiles, online redo logs, controlfiles, archived redo logs, RMAN backupsets, and SPFILEs). All of the database files (and directories) to be used for Oracle will be contained in a disk group. ASM automatically performs load balancing in parallel across all available disk drives to prevent hot spots and maximize performance, even with rapidly changing data usage patterns. Configuring an ASM environment (an ASM instance) is a straightforward process and can be done through the Database Configuration Assistant (DBCA) or manually (see Manually Creating an ASM Instance). Once the ASM instance is configured on a node and an ASM Disk Group is created, any database that resides on that node can start taking advantage of it. For example, consider an ASM instance named +ASM with an ASM disk group named TESTDB_DATA1. Creating a tablespace where the datafile will reside in ASM is as easy as:
SQL> CREATE TABLESPACE users2 DATAFILE '+TESTDB_DATA1' SIZE 100M; Tablespace created. SQL> SELECT tablespace_name, file_name FROM dba_data_files WHERE tablespace_name = 'USERS2'; TABLESPACE_NAME FILE_NAME --------------- -------------------------------------------------USERS2 +TESTDB_DATA1/testdb/datafile/users2.268.598475429

Given the SQL statement above, a new datafile will be created using Oracle Managed Files (OMF) in an ASM disk group named TESTDB_DATA1. But, what if you already have an existing Oracle database which stores its database files using the local file system on the node you just configured ASM on and now want to relocate the entire database to be stored in ASM? Well, as with most file management tasks that involve ASM, it's RMAN to the rescue!

In this article, I will explain the steps necessary to migrate an existing Oracle database stored on the local file system to ASM. This will include all datafiles, tempfiles, online redo logfiles, controlfiles, and all flash recovery area files. I will then, within a follow-up section, explain how the process works in reverse - migrating a database stored in ASM to a local file system.

Current Configuration The testing environment that I will be using for this article is best described in the following illustration and table of values:

Oracle ASM Configuration
Machine Name: Oracle SID: Database Name: Available ASM Disk Groups: linux3.idevelopment.info TESTDB TESTDB +TESTDB_DATA1 +TESTDB_DATA2 +FLASH_RECOVERY_AREA

Available File System for DB Files: /u02/oradata Available File System for Flash Recovery Area: /u02/flash_recovery_area Operating System: Oracle Release: Red Hat Linux 3 - (CentOS 3.4) Oracle10g Release 2 - (10.2.0.2.0)

Please note that although I have two Oracle ASM disk groups defined for database files (+TESTDB_DATA1 and +TESTDB_DATA2), I will only be using +TESTDB_DATA1.

This article assumes the database is open and in ARCHIVELOG mode:
SQL> archive log list Database log mode Automatic archival Archive destination Oldest online log sequence Next log sequence to archive Current log sequence Archive Mode Enabled USE_DB_RECOVERY_FILE_DEST 34 36 36

Migrating Oracle Database from Local File System to ASM The following query lists database files as they exist on the local file system for the TESTDB database. All of the files listed in this query will be relocated from the local file system to ASM:
$ ORACLE_SID=TESTDB; export ORACLE_SID $ sqlplus "/ as sysdba" SQL> @dba_files_all Tablespace Name / File Class Filename File Size Auto Next Max ----------------------------------------------------------------------------------- ------------------ ----------- -------------APEX22 /u02/oradata/TESTDB/datafile/o1_mf_apex22_2ft4eswu_.dbf 104,857,600 NO 0 0 EXAMPLE /u02/oradata/TESTDB/datafile/o1_mf_example_2fb4ccw2_.dbf 157,286,400 YES 655,360 34,359,721,984 FLOW_1 /u02/oradata/TESTDB/datafile/o1_mf_flow_1_2fb4cegw_.dbf 52,494,336 NO 0 0 SYSAUX /u02/oradata/TESTDB/datafile/o1_mf_sysaux_2fb4cb7z_.dbf 419,430,400 YES 10,485,760 34,359,721,984 SYSTEM /u02/oradata/TESTDB/datafile/o1_mf_system_2fb4b8s2_.dbf 608,174,080 YES 10,485,760 34,359,721,984 TEMP /u02/oradata/TESTDB/datafile/o1_mf_temp_2g17lvcq_.tmp 536,870,912 YES 262,144,000 34,359,721,984 UNDOTBS1 /u02/oradata/TESTDB/datafile/o1_mf_undotbs1_2fb4c2wf_.dbf 209,715,200 YES 5,242,880 34,359,721,984 USERS /u02/oradata/TESTDB/datafile/o1_mf_users_2fb4cqf4_.dbf 2,382,888,960 YES 1,310,720 34,359,721,984 [ CONTROL FILE ] /u02/oradata/TESTDB/controlfile/o1_mf_8du3s3er_.ctl [ CONTROL FILE ] /u02/oradata/TESTDB/controlfile/o1_mf_y2is93je_.ctl [ ONLINE REDO LOG ] /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_1_2g1g6bq0_.log 262,144,000 [ ONLINE REDO LOG ] /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_2_2g1gdgn1_.log 262,144,000 [ ONLINE REDO LOG ] /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_3_2g1ghz8z_.log 262,144,000 [ ONLINE REDO LOG ] /u02/oradata/TESTDB/onlinelog/o1_mf_1_2g1g61bm_.log 262,144,000 [ ONLINE REDO LOG ] /u02/oradata/TESTDB/onlinelog/o1_mf_2_2g1gd4pr_.log 262,144,000 [ ONLINE REDO LOG ] /u02/oradata/TESTDB/onlinelog/o1_mf_3_2g1ghs0t_.log 262,144,000

--------------sum 6,044,581,888 16 rows selected.

Also note that the target database uses an SPFILE on the local file system:
$ORACLE_HOME/dbs/spfileTESTDB.ora

Use the following steps to fully migrate an existing Oracle database from a local file system to ASM: 1. With the target database open, edit the initialization parameter control_files and db_create_file_dest to point to the ASM disk group +TESTDB_DATA1. Also configure db_recovery_file_dest to point to the ASM disk group +FLASH_RECOVERY_AREA: 2. SQL> ALTER SYSTEM SET control_files='+TESTDB_DATA1' SCOPE=spfile;

3. 4. System altered. 5. 6. SQL> ALTER SYSTEM SET db_create_file_dest='+TESTDB_DATA1' SCOPE=spfile; 7. 8. System altered. 9. 10. SQL> ALTER SYSTEM SET db_recovery_file_dest='+FLASH_RECOVERY_AREA' SCOPE=spfile; 11. System altered.

12. Startup the target database in NOMOUNT mode: 13. SQL> SHUTDOWN IMMEDIATE
14.Database closed. 15.Database dismounted. 16.ORACLE instance shut down. 17. 18. SQL> STARTUP NOMOUNT 19.ORACLE instance started. 20. 21.Total System Global Area 285212672 bytes 22.Fixed Size 1260420 bytes 23.Variable Size 171967612 bytes 24.Database Buffers 109051904 bytes Redo Buffers 2932736 bytes

25. From an RMAN session, copy one of your controlfiles from the local file system to its new location in ASM. The new controlfile will be copied to the value specified in the initialization parameter control_files: 26. RMAN> RESTORE CONTROLFILE FROM
'/u02/oradata/TESTDB/controlfile/o1_mf_8du3s3er_.ctl'; 27. 28.Starting restore at 14-AUG-06 29.using channel ORA_DISK_1 30. 31.channel ORA_DISK_1: copied control file copy 32. output filename=+TESTDB_DATA1/testdb/controlfile/backup.268.598481391 Finished restore at 14-AUG-06

33. From an RMAN or SQL*Plus session, mount the database. This will mount the database using the controlfile stored in ASM:

34. RMAN> ALTER DATABASE MOUNT;
35. 36.database mounted released channel: ORA_DISK_1

37. From an RMAN session, copy the database files from the local file system to ASM: 38. RMAN> BACKUP AS COPY DATABASE FORMAT '+TESTDB_DATA1';

39. 40.Starting backup at 14-AUG-06 41.using target database control file instead of recovery catalog 42.allocated channel: ORA_DISK_1 43.channel ORA_DISK_1: sid=158 devtype=DISK 44.channel ORA_DISK_1: starting datafile copy 45.input datafile fno=00005 name=/u02/oradata/TESTDB/datafile/o1_mf_users_2fb4cqf4_.dbf 46. output filename=+TESTDB_DATA1/testdb/datafile/users.270.598481673 tag=TAG20060814T205432 recid=36 stamp=598482095 47.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:07:06 48.channel ORA_DISK_1: starting datafile copy 49.input datafile fno=00001 name=/u02/oradata/TESTDB/datafile/o1_mf_system_2fb4b8s2_.dbf 50. output filename=+TESTDB_DATA1/testdb/datafile/system.269.598482099 tag=TAG20060814T205432 recid=37 stamp=598482206 51.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:55 52.channel ORA_DISK_1: starting datafile copy 53.input datafile fno=00003 name=/u02/oradata/TESTDB/datafile/o1_mf_sysaux_2fb4cb7z_.dbf 54. output filename=+TESTDB_DATA1/testdb/datafile/sysaux.267.598482213 tag=TAG20060814T205432 recid=38 stamp=598482292 55.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:25 56.channel ORA_DISK_1: starting datafile copy 57.input datafile fno=00002 name=/u02/oradata/TESTDB/datafile/o1_mf_undotbs1_2fb4c2wf_.dbf 58. output filename=+TESTDB_DATA1/testdb/datafile/undotbs1.256.598482299 tag=TAG20060814T205432 recid=39 stamp=598482340 59.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45 60.channel ORA_DISK_1: starting datafile copy 61.input datafile fno=00004 name=/u02/oradata/TESTDB/datafile/o1_mf_example_2fb4ccw2_.dbf 62. output filename=+TESTDB_DATA1/testdb/datafile/example.264.598482345 tag=TAG20060814T205432 recid=40 stamp=598482374 63.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35 64.channel ORA_DISK_1: starting datafile copy 65.input datafile fno=00006 name=/u02/oradata/TESTDB/datafile/o1_mf_apex22_2ft4eswu_.dbf 66. output filename=+TESTDB_DATA1/testdb/datafile/apex22.263.598482381 tag=TAG20060814T205432 recid=41 stamp=598482399 67.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 68.channel ORA_DISK_1: starting datafile copy 69.input datafile fno=00007 name=/u02/oradata/TESTDB/datafile/o1_mf_flow_1_2fb4cegw_.dbf 70. output filename=+TESTDB_DATA1/testdb/datafile/flow_1.262.598482405 tag=TAG20060814T205432 recid=42 stamp=598482415 71.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:15 72.channel ORA_DISK_1: starting datafile copy 73.copying current control file 74. output filename=+TESTDB_DATA1/testdb/controlfile/backup.261.598482421 tag=TAG20060814T205432 recid=43 stamp=598482423

75.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03 76.channel ORA_DISK_1: starting full datafile backupset 77.channel ORA_DISK_1: specifying datafile(s) in backupset 78.including current SPFILE in backupset 79.channel ORA_DISK_1: starting piece 1 at 14-AUG-06 80.channel ORA_DISK_1: finished piece 1 at 14-AUG-06 81.piece handle=+TESTDB_DATA1/testdb/backupset/2006_08_14/nnsnf0_tag20060814t205432_0.26 0.598482425 tag=TAG20060814T205432 comment=NONE 82.channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 14-AUG-06

83. From an RMAN session, update the control file / data dictionary so that all database files point to the RMAN copy made in ASM: 84. RMAN> SWITCH DATABASE TO COPY;
85. 86.datafile 1 switched to datafile copy "+TESTDB_DATA1/testdb/datafile/system.269.598482099" 87.datafile 2 switched to datafile copy "+TESTDB_DATA1/testdb/datafile/undotbs1.256.598482299" 88.datafile 3 switched to datafile copy "+TESTDB_DATA1/testdb/datafile/sysaux.267.598482213" 89.datafile 4 switched to datafile copy "+TESTDB_DATA1/testdb/datafile/example.264.598482345" 90.datafile 5 switched to datafile copy "+TESTDB_DATA1/testdb/datafile/users.270.598481673" 91.datafile 6 switched to datafile copy "+TESTDB_DATA1/testdb/datafile/apex22.263.598482381" datafile 7 switched to datafile copy "+TESTDB_DATA1/testdb/datafile/flow_1.262.598482405"

92. From a SQL*Plus session, perform incomplete recovery and open the database using the RESETLOGS option: 93. SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
94. 95.ORA-00279: change 7937583 generated at 08/14/2006 20:33:55 needed for thread 1 96.ORA-00289: suggestion : +FLASH_RECOVERY_AREA 97.ORA-00280: change 7937583 for thread 1 is in sequence #36 98. 99. 100.Specify log: {<RET>=suggested | filename | AUTO | CANCEL} 101.CANCEL 102.Media recovery cancelled. 103. 104.SQL> ALTER DATABASE OPEN RESETLOGS; 105. Database altered.

106.From a SQL*Plus session, re-create any tempfiles that are still currently on the local file system to ASM. This is done by simply dropping the tempfiles from the local file system and re-creating them in ASM. This example relies on the initialization parameter db_create_file_dest=+TESTDB_DATA1: 107.SQL> select tablespace_name, file_name, bytes from dba_temp_files;
108. 109.TABLESPACE_NAME FILE_NAME BYTES 110.--------------- -------------------------------------------------------------

111.TEMP /u02/oradata/TESTDB/datafile/o1_mf_temp_2g17lvcq_.tmp 536870912 112. 113.SQL> alter database tempfile 114. 2 '/u02/oradata/TESTDB/datafile/o1_mf_temp_2g17lvcq_.tmp' 115. 3 drop including datafiles; 116. 117.Database altered. 118. 119.SQL> alter tablespace temp add tempfile size 512m 120. 2 autoextend on next 250m maxsize unlimited; 121. 122.Tablespace altered. 123. 124.SQL> select tablespace_name, file_name, bytes from dba_temp_files; 125. 126.TABLESPACE_NAME FILE_NAME BYTES 127.--------------- ------------------------------------------------ --------TEMP +TESTDB_DATA1/testdb/tempfile/temp.261.598485663 536870912

If users are currently accessing the tempfile(s) you are attempting to drop, you may receive the f error:
SQL> alter database tempfile 2 '/u02/oradata/TESTDB/datafile/o1_mf_temp_2g17lvcq_.tmp' 3 drop including datafiles; ERROR at line 1: ORA-25152: TEMPFILE cannot be dropped at this time

As for the poor users who were using the tempfile, their transaction will end and will be greeted following error message:

SQL> @testTemp.sql join dba_extents c on (b.segment_name = c.segment_name) * ERROR at line 4: ORA-00372: file 601 cannot be modified at this time ORA-01110: data file 601: '/u02/oradata/TESTDB/datafile/o1_mf_temp_2g17lvcq_. ORA-00372: file 601 cannot be modified at this time ORA-01110: data file 601: '/u02/oradata/TESTDB/datafile/o1_mf_temp_2g17lvcq_.

If this happens, you should attempt to drop the tempfile again so the operation is successful:
SQL> alter database tempfile 2 '/u02/oradata/TESTDB/datafile/o1_mf_temp_2g17lvcq_.tmp' 3 drop including datafiles; Database altered.

128.From a SQL*Plus session, re-create any online redo logfiles that are still currently on the local file system to ASM. This is done by simply dropping the logfiles from the local file system and recreating them in ASM. This example relies on the initialization parameters db_create_file_dest=+TESTDB_DATA1 and db_recovery_file_dest=+FLASH_RECOVERY_AREA: o Determine the current online redo logfiles to move to ASM by examining the file names (and sizes) from V$LOGFILE:
o o o o SQL> select a.group#, a.member, b.bytes 2 from v$logfile a, v$log b where a.group# = b.group#; GROUP# MEMBER BYTES

o o o o o o o

------ ----------------------------------------------------------------------1 /u02/oradata/TESTDB/onlinelog/o1_mf_1_2g1g61bm_.log 262144000 2 /u02/oradata/TESTDB/onlinelog/o1_mf_2_2g1gd4pr_.log 262144000 3 /u02/oradata/TESTDB/onlinelog/o1_mf_3_2g1ghs0t_.log 262144000 1 /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_1_2g1g6bq0_.log 262144000 2 /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_2_2g1gdgn1_.log 262144000 3 /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_3_2g1ghz8z_.log 262144000

o 6 rows selected. o

Force a log switch until the last redo log is marked "CURRENT" by issuing the following command:

o SQL> select group#, status from v$log; o o GROUP# STATUS o ---------- ---------------o 1 CURRENT o 2 INACTIVE o 3 INACTIVE o o SQL> alter system switch logfile; o o SQL> alter system switch logfile; o o SQL> select group#, status from v$log; o o GROUP# STATUS o ---------- ---------------o 1 INACTIVE o 2 INACTIVE o 3 CURRENT o After making the last online redo log file the CURRENT one, o SQL> alter database drop logfile group 1; o Database altered.

drop the first online redo log:

As a DBA, you should already be aware that if you are going to drop a logfile group, it cannot be the current logfile group. I have run into instances; however, where attempting to drop the logfile group resulted in the following error as a result of the logfile group having an active status:

SQL> ALTER DATABASE DROP LOGFILE GROUP 1; ALTER DATABASE DROP LOGFILE GROUP 1 * ERROR at line 1: ORA-01624: log 1 needed for crash recovery of instance TESTDB (thread 1) ORA-00312: online log 1 thread 1: '<file_name>'

Easy problem to resolve. Simply perform a checkpoint on the database:
SQL> ALTER SYSTEM CHECKPOINT GLOBAL; System altered.

SQL> ALTER DATABASE DROP LOGFILE GROUP 1; Database altered.

o Re-create the dropped redo log group in ASM (and a different size o SQL> alter database add logfile group 1 size 250m; o Database altered. o o o o o o o o o o o o o o o o o

if desired):

After re-creating the online redo log group, force a log switch. The online redo log group just created should become the CURRENT one:
SQL> select group#, status from v$log; GROUP# ---------1 2 3 STATUS ---------------UNUSED INACTIVE CURRENT

SQL> alter system switch logfile; SQL> select group#, status from v$log; GROUP# STATUS ---------- ---------------1 CURRENT 2 INACTIVE 3 ACTIVE

o

o o SQL> select a.group#, a.member, b.bytes o 2 from v$logfile a, v$log b where a.group# = b.group#; o o GROUP# MEMBER o ------ ----------------------------------------------------------o 1 +TESTDB_DATA1/testdb/onlinelog/group_1.259.598486831 o 2 +TESTDB_DATA1/testdb/onlinelog/group_2.260.598487179 o 3 +TESTDB_DATA1/testdb/onlinelog/group_3.258.598487365 o 1 +FLASH_RECOVERY_AREA/testdb/onlinelog/group_1.259.598486879 o 2 +FLASH_RECOVERY_AREA/testdb/onlinelog/group_2.257.598487225 o 3 +FLASH_RECOVERY_AREA/testdb/onlinelog/group_3.260.598487411 o 6 rows selected.

After re-creating the first online redo log group, loop back to drop / re-create the next online redo logfile until all logs are rebuilt in ASM. Verify all online redo logfiles have been created in ASM:

BYTES --------262144000 262144000 262144000 262144000 262144000 262144000

129.Perform the following steps to relocate the SPFILE from the local file system to an ASM disk group. o Create a text-based initialization parameter file from the current binary SPFILE located on the local file system:
o SQL> CREATE PFILE='$ORACLE_HOME/dbs/initTESTDB.ora' o 2 FROM SPFILE='$ORACLE_HOME/dbs/spfileTESTDB.ora'; o File created. o

Create new SPFILE in an ASM disk group:

o SQL> CREATE SPFILE='+TESTDB_DATA1/TESTDB/spfileTESTDB.ora' o 2 FROM PFILE='$ORACLE_HOME/dbs/initTESTDB.ora'; o File created. o Shutdown the Oracle database: o SQL> SHUTDOWN IMMEDIATE o Database closed. o Database dismounted. ORACLE instance shut down. o

Update the text-based init<SID>.ora file with the new location of the SPFILE in ASM:

$ echo "SPFILE='+TESTDB_DATA1/TESTDB/spfileTESTDB.ora'" > $ORACLE_HOME/dbs/initTESTDB.ora o

Remove (actually rename) the old SPFILE on the local file system so that the new text-based init<SID>.ora will be used:

$ mv $ORACLE_HOME/dbs/spfileTESTDB.ora $ORACLE_HOME/dbs/BACKUP_ASM.spfileTESTDB.ora o

Open the Oracle database using the new SPFILE:

SQL> STARTUP

130.Verify that all database files have been created in ASM: 131.$ sqlplus "/ as sysdba"

132. 133.SQL> @dba_files_all 134. 135.Tablespace Name / 136.File Class Filename File Size Auto Next Max 137.------------------------------------------------------------------------------- ------------------ ----------- --------------138.APEX22 +TESTDB_DATA1/testdb/datafile/apex22.263.598482381 104,857,600 NO 0 0 139.EXAMPLE +TESTDB_DATA1/testdb/datafile/example.264.598482345 157,286,400 YES 655,360 34,359,721,984 140.FLOW_1 +TESTDB_DATA1/testdb/datafile/flow_1.262.598482405 52,494,336 NO 0 0 141.SYSAUX +TESTDB_DATA1/testdb/datafile/sysaux.267.598482213 419,430,400 YES 10,485,760 34,359,721,984 142.SYSTEM +TESTDB_DATA1/testdb/datafile/system.269.598482099 608,174,080 YES 10,485,760 34,359,721,984 143.TEMP +TESTDB_DATA1/testdb/tempfile/temp.261.598485663 536,870,912 YES 262,144,000 34,359,721,984 144.UNDOTBS1 +TESTDB_DATA1/testdb/datafile/undotbs1.256.598482299 209,715,200 YES 5,242,880 34,359,721,984 145.USERS +TESTDB_DATA1/testdb/datafile/users.270.598481673 2,382,888,960 YES 1,310,720 34,359,721,984 146.[ CONTROL FILE ] +TESTDB_DATA1/testdb/controlfile/backup.268.598481391 147.[ ONLINE REDO LOG ] +FLASH_RECOVERY_AREA/testdb/onlinelog/group_1.259.598486879 262,144,000

148.[ ONLINE REDO LOG ] +FLASH_RECOVERY_AREA/testdb/onlinelog/group_2.257.598487225 262,144,000 149.[ ONLINE REDO LOG ] +FLASH_RECOVERY_AREA/testdb/onlinelog/group_3.260.598487411 262,144,000 150.[ ONLINE REDO LOG ] +TESTDB_DATA1/testdb/onlinelog/group_1.259.598486831 262,144,000 151.[ ONLINE REDO LOG ] +TESTDB_DATA1/testdb/onlinelog/group_2.260.598487179 262,144,000 152.[ ONLINE REDO LOG ] +TESTDB_DATA1/testdb/onlinelog/group_3.258.598487365 262,144,000 153. --------------154.sum 6,044,581,888 155. 15 rows selected.

156.At this point, the target database is open with all of its datafiles, controlfiles, online redo logfiles, tempfiles, and SPFILE stored in ASM. If we wanted to remove the database files that were stored on the local file system (which are actually now RMAN copies), this could be done from an RMAN session. You could also then remove the old version of the controfile(s) that were stored on the local file system: If this is a production database, it would be best practice to first backup the database files on the local disk before removing them! 157.RMAN> DELETE NOPROMPT FORCE COPY;
158. 159.allocated channel: ORA_DISK_1 160.channel ORA_DISK_1: sid=139 devtype=DISK 161. 162.List of Datafile Copies 163.Key File S Completion Time Ckp SCN Ckp Time Name 164.------- ---- - --------------- ---------- --------------- ---165.44 1 A 14-AUG-06 7937583 14-AUG-06 /u02/oradata/TESTDB/datafile/o1_mf_system_2fb4b8s2_.dbf 166.45 2 A 14-AUG-06 7937583 14-AUG-06 /u02/oradata/TESTDB/datafile/o1_mf_undotbs1_2fb4c2wf_.dbf 167.46 3 A 14-AUG-06 7937583 14-AUG-06 /u02/oradata/TESTDB/datafile/o1_mf_sysaux_2fb4cb7z_.dbf 168.47 4 A 14-AUG-06 7937583 14-AUG-06 /u02/oradata/TESTDB/datafile/o1_mf_example_2fb4ccw2_.dbf 169.48 5 A 14-AUG-06 7937583 14-AUG-06 /u02/oradata/TESTDB/datafile/o1_mf_users_2fb4cqf4_.dbf 170.49 6 A 14-AUG-06 7937583 14-AUG-06 /u02/oradata/TESTDB/datafile/o1_mf_apex22_2ft4eswu_.dbf 171.50 7 A 14-AUG-06 7937583 14-AUG-06 /u02/oradata/TESTDB/datafile/o1_mf_flow_1_2fb4cegw_.dbf 172. 173.List of Control File Copies 174.Key S Completion Time Ckp SCN Ckp Time Name 175.------- - --------------- ---------- --------------- ---176.43 A 14-AUG-06 7937583 14-AUG-06 +TESTDB_DATA1/testdb/controlfile/backup.261.598482421 177. 178.List of Archived Log Copies 179.Key Thrd Seq S Low Time Name 180.------- ---- ------- - --------- ---181.48 1 34 A 14-AUG-06 +FLASH_RECOVERY_AREA/testdb/archivelog/2006_08_14/thread_1_seq_34.259.598482825

182.49 1 35 A 14-AUG-06 +FLASH_RECOVERY_AREA/testdb/archivelog/2006_08_14/thread_1_seq_35.258.598482825 183.47 1 36 A 14-AUG-06 +FLASH_RECOVERY_AREA/testdb/archivelog/2006_08_14/thread_1_seq_36.260.598482821 184.deleted datafile copy 185.datafile copy filename=/u02/oradata/TESTDB/datafile/o1_mf_system_2fb4b8s2_.dbf recid=44 stamp=598482495 186.deleted datafile copy 187.datafile copy filename=/u02/oradata/TESTDB/datafile/o1_mf_undotbs1_2fb4c2wf_.dbf recid=45 stamp=598482495 188.deleted datafile copy 189.datafile copy filename=/u02/oradata/TESTDB/datafile/o1_mf_sysaux_2fb4cb7z_.dbf recid=46 stamp=598482496 190.deleted datafile copy 191.datafile copy filename=/u02/oradata/TESTDB/datafile/o1_mf_example_2fb4ccw2_.dbf recid=47 stamp=598482496 192.deleted datafile copy 193.datafile copy filename=/u02/oradata/TESTDB/datafile/o1_mf_users_2fb4cqf4_.dbf recid=48 stamp=598482496 194.deleted datafile copy 195.datafile copy filename=/u02/oradata/TESTDB/datafile/o1_mf_apex22_2ft4eswu_.dbf recid=49 stamp=598482496 196.deleted datafile copy 197.datafile copy filename=/u02/oradata/TESTDB/datafile/o1_mf_flow_1_2fb4cegw_.dbf recid=50 stamp=598482496 198.deleted control file copy 199.control file copy filename=+TESTDB_DATA1/testdb/controlfile/backup.261.598482421 recid=43 stamp=598482423 200.deleted archive log 201.archive log filename=+FLASH_RECOVERY_AREA/testdb/archivelog/2006_08_14/thread_1_seq_34.259. 598482825 recid=48 stamp=598482824 202.deleted archive log 203.archive log filename=+FLASH_RECOVERY_AREA/testdb/archivelog/2006_08_14/thread_1_seq_35.258. 598482825 recid=49 stamp=598482824 204.deleted archive log 205.archive log filename=+FLASH_RECOVERY_AREA/testdb/archivelog/2006_08_14/thread_1_seq_36.260. 598482821 recid=47 stamp=598482824 206.Deleted 11 objects 207. 208.RMAN> exit 209. 210.$ rm /u02/oradata/TESTDB/controlfile/o1_mf_8du3s3er_.ctl 211.$ rm /u02/oradata/TESTDB/controlfile/o1_mf_y2is93je_.ctl

Migrating Oracle Database from ASM to Local File System The following query lists database files as they exist in ASM for the TESTDB database. All of the files listed in this query will be relocated from ASM to the local file system:
$ ORACLE_SID=TESTDB; export ORACLE_SID

$ sqlplus "/ as sysdba" SQL> @dba_files_all Tablespace Name / File Class Filename File Size Auto Next Max --------------------- ------------------------------------------------------------------------- ---- ----------- --------------APEX22 +TESTDB_DATA1/testdb/datafile/apex22.263.598482381 104,857,600 NO 0 0 EXAMPLE +TESTDB_DATA1/testdb/datafile/example.264.598482345 157,286,400 YES 655,360 34,359,721,984 FLOW_1 +TESTDB_DATA1/testdb/datafile/flow_1.262.598482405 52,494,336 NO 0 0 SYSAUX +TESTDB_DATA1/testdb/datafile/sysaux.267.598482213 419,430,400 YES 10,485,760 34,359,721,984 SYSTEM +TESTDB_DATA1/testdb/datafile/system.269.598482099 608,174,080 YES 10,485,760 34,359,721,984 TEMP +TESTDB_DATA1/testdb/tempfile/temp.261.598485663 536,870,912 YES 262,144,000 34,359,721,984 UNDOTBS1 +TESTDB_DATA1/testdb/datafile/undotbs1.256.598482299 209,715,200 YES 5,242,880 34,359,721,984 USERS +TESTDB_DATA1/testdb/datafile/users.270.598481673 2,382,888,960 YES 1,310,720 34,359,721,984 [ CONTROL FILE ] +TESTDB_DATA1/testdb/controlfile/backup.268.598481391 [ ONLINE REDO LOG ] +FLASH_RECOVERY_AREA/testdb/onlinelog/group_1.259.598486879 262,144,000 [ ONLINE REDO LOG ] +FLASH_RECOVERY_AREA/testdb/onlinelog/group_2.257.598487225 262,144,000 [ ONLINE REDO LOG ] +FLASH_RECOVERY_AREA/testdb/onlinelog/group_3.260.598487411 262,144,000 [ ONLINE REDO LOG ] +TESTDB_DATA1/testdb/onlinelog/group_1.259.598486831 262,144,000 [ ONLINE REDO LOG ] +TESTDB_DATA1/testdb/onlinelog/group_2.260.598487179 262,144,000 [ ONLINE REDO LOG ] +TESTDB_DATA1/testdb/onlinelog/group_3.258.598487365 262,144,000 --------------sum 6,044,581,888 15 rows selected.

Also note that the target database uses an SPFILE which is stored in ASM. The target database starts using a text-based init<SID>.ora ($ORACLE_HOME/dbs/initTESTDB.ora) which defines the location of the SPFILE in ASM:
SPFILE='+TESTDB_DATA1/TESTDB/spfileTESTDB.ora'

Use the following steps to fully migrate an existing Oracle database from ASM to a local file system: 1. With the target database open, edit the initialization parameter control_files and db_create_file_dest to point to locations on the local file system (/u02/oradata). Also configure db_recovery_file_dest to point to the Flash Recovery Area on the local file system (/u02/flash_recovery_area): 2. SQL> ALTER SYSTEM SET control_files='/u02/oradata/TESTDB/control01.ctl'
SCOPE=spfile; 3. 4. System altered. 5.

6. SQL> ALTER SYSTEM SET db_create_file_dest='/u02/oradata' SCOPE=spfile;
7. 8. System altered. 9. 10. SQL> ALTER SYSTEM SET db_recovery_file_dest='/u02/flash_recovery_area' SCOPE=spfile; 11. System altered.

12. Backup the current SPFILE (in ASM) to a text-based init<SID>.ora file on the local file system. Then convert the text-based init<SID>.ora file to a binary SPFILE on the local file system: 13. SQL> HOST mv $ORACLE_HOME/dbs/initTESTDB.ora
14. $ORACLE_HOME/dbs/BACKUP_ASM.initTESTDB.ora

15. SQL> CREATE PFILE='$ORACLE_HOME/dbs/initTESTDB.ora' FROM
SPFILE='+TESTDB_DATA1/TESTDB/spfileTESTDB.ora'; 16. 17.File created. 18. 19. SQL> CREATE SPFILE='$ORACLE_HOME/dbs/spfileTESTDB.ora' FROM PFILE='$ORACLE_HOME/dbs/initTESTDB.ora'; 20. File created.

21. Startup the target database in NOMOUNT mode: 22. SQL> shutdown immediate

23.Database closed. 24.Database dismounted. 25.ORACLE instance shut down. 26. 27. SQL> startup nomount 28.ORACLE instance started. 29. 30.Total System Global Area 285212672 bytes 31.Fixed Size 1260420 bytes 32.Variable Size 150996092 bytes 33.Database Buffers 130023424 bytes Redo Buffers 2932736 bytes

34. From an RMAN session, copy one of your controlfiles from ASM to its new location on the local file system. The new controlfile will be copied to the value specified in the initialization parameter control_files: 35. RMAN> RESTORE CONTROLFILE FROM
'+TESTDB_DATA1/TESTDB/CONTROLFILE/backup.268.598481391'; 36. 37.Starting restore at 15-AUG-06 38.using target database control file instead of recovery catalog 39.allocated channel: ORA_DISK_1 40.channel ORA_DISK_1: sid=156 devtype=DISK 41. 42.channel ORA_DISK_1: copied control file copy 43. output filename=/u02/oradata/TESTDB/control01.ctl Finished restore at 15-AUG-06

44. From an RMAN or SQL*Plus session, mount the database. This will mount the database using the controlfile stored on the local file system:

45. RMAN> ALTER DATABASE MOUNT;
46. 47.using target database control file instead of recovery catalog database mounted

48. From an RMAN session, copy the database files from ASM to the local file system: 49. RMAN> BACKUP AS COPY DATABASE FORMAT '/u02/oradata/TESTDB/%U';

50. 51.Starting backup at 15-AUG-06 52.allocated channel: ORA_DISK_1 53.channel ORA_DISK_1: sid=156 devtype=DISK 54.channel ORA_DISK_1: starting datafile copy 55.input datafile fno=00005 name=+TESTDB_DATA1/testdb/datafile/users.270.598481673 56. output filename=/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-USERS_FNO5_0vhqpltd tag=TAG20060815T101925 recid=51 stamp=598530181 57.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:03:36 58.channel ORA_DISK_1: starting datafile copy 59.input datafile fno=00001 name=+TESTDB_DATA1/testdb/datafile/system.269.598482099 60. output filename=/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-SYSTEM_FNO1_10hqpm45 tag=TAG20060815T101925 recid=52 stamp=598530235 61.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55 62.channel ORA_DISK_1: starting datafile copy 63.input datafile fno=00003 name=+TESTDB_DATA1/testdb/datafile/sysaux.267.598482213 64. output filename=/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-SYSAUX_FNO3_11hqpm5s tag=TAG20060815T101925 recid=53 stamp=598530274 65.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:46 66.channel ORA_DISK_1: starting datafile copy 67.input datafile fno=00002 name=+TESTDB_DATA1/testdb/datafile/undotbs1.256.598482299 68. output filename=/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-UNDOTBS1_FNO2_12hqpm7a tag=TAG20060815T101925 recid=54 stamp=598530304 69.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 70.channel ORA_DISK_1: starting datafile copy 71.input datafile fno=00004 name=+TESTDB_DATA1/testdb/datafile/example.264.598482345 72. output filename=/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-EXAMPLE_FNO4_13hqpm83 tag=TAG20060815T101925 recid=55 stamp=598530323 73.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25 74.channel ORA_DISK_1: starting datafile copy 75.input datafile fno=00006 name=+TESTDB_DATA1/testdb/datafile/apex22.263.598482381 76. output filename=/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-APEX22_FNO6_14hqpm8s tag=TAG20060815T101925 recid=56 stamp=598530343 77.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:16 78.channel ORA_DISK_1: starting datafile copy 79.input datafile fno=00007 name=+TESTDB_DATA1/testdb/datafile/flow_1.262.598482405 80. output filename=/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-FLOW_1_FNO7_15hqpm9c tag=TAG20060815T101925 recid=57 stamp=598530353 81.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07 82.channel ORA_DISK_1: starting datafile copy 83.copying current control file 84. output filename=/u02/oradata/TESTDB/cf_D-TESTDB_id-2370649665_16hqpm9j tag=TAG20060815T101925 recid=58 stamp=598530356 85.channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01 86.channel ORA_DISK_1: starting full datafile backupset

87.channel ORA_DISK_1: specifying datafile(s) in backupset 88.including current SPFILE in backupset 89.channel ORA_DISK_1: starting piece 1 at 15-AUG-06 90.channel ORA_DISK_1: finished piece 1 at 15-AUG-06 91.piece handle=/u02/oradata/TESTDB/17hqpm9k_1_1 tag=TAG20060815T101925 comment=NONE 92.channel ORA_DISK_1: backup set complete, elapsed time: 00:00:02 Finished backup at 15-AUG-06

93. From an RMAN session, update the control file / data dictionary so that all database files point to the RMAN copy made on the local file system: 94. RMAN> SWITCH DATABASE TO COPY;
95. 96.datafile 1 switched to datafile copy "/u02/oradata/TESTDB/data_D-TESTDB_I2370649665_TS-SYSTEM_FNO-1_10hqpm45" 97.datafile 2 switched to datafile copy "/u02/oradata/TESTDB/data_D-TESTDB_I2370649665_TS-UNDOTBS1_FNO-2_12hqpm7a" 98.datafile 3 switched to datafile copy "/u02/oradata/TESTDB/data_D-TESTDB_I2370649665_TS-SYSAUX_FNO-3_11hqpm5s" 99.datafile 4 switched to datafile copy "/u02/oradata/TESTDB/data_D-TESTDB_I2370649665_TS-EXAMPLE_FNO-4_13hqpm83" 100.datafile 5 switched to datafile copy "/u02/oradata/TESTDB/data_D-TESTDB_I2370649665_TS-USERS_FNO-5_0vhqpltd" 101.datafile 6 switched to datafile copy "/u02/oradata/TESTDB/data_D-TESTDB_I2370649665_TS-APEX22_FNO-6_14hqpm8s" datafile 7 switched to datafile copy "/u02/oradata/TESTDB/data_D-TESTDB_I2370649665_TS-FLOW_1_FNO-7_15hqpm9c"

102.From a SQL*Plus session, perform incomplete recovery and open the database using the RESETLOGS option: 103.SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;

104. 105.ORA-00279: change 7970332 generated at 08/15/2006 10:12:34 needed for thread 1 106.ORA-00289: suggestion : 107./u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_5_%u_.arc 108.ORA-00280: change 7970332 for thread 1 is in sequence #5 109. 110. 111.Specify log: {=suggested | filename | AUTO | CANCEL} 112.CANCEL 113.Media recovery cancelled. 114. 115.SQL> ALTER DATABASE OPEN RESETLOGS; 116. Database altered.

117.From a SQL*Plus session, re-create any tempfiles that are still currently using ASM to the local file system. This is done by simply dropping the tempfiles from ASM and re-creating them in the local file system. This example relies on the initialization parameter db_create_file_dest=/u02/oradata: 118.SQL> select tablespace_name, file_name, bytes from dba_temp_files;
119. 120.TABLESPACE_NAME FILE_NAME BYTES 121.--------------- ------------------------------------------------------------122.TEMP +TESTDB_DATA1/testdb/tempfile/temp.261.598485663 536870912

123. 124.SQL> alter database tempfile 125. 2 '+TESTDB_DATA1/testdb/tempfile/temp.261.598485663' 126. 3 drop including datafiles; 127. 128.Database altered. 129. 130.SQL> alter tablespace temp add tempfile size 512m 131. 2 autoextend on next 250m maxsize unlimited; 132. 133.Tablespace altered. 134. 135.SQL> select tablespace_name, file_name, bytes from dba_temp_files; 136. 137.TABLESPACE_NAME FILE_NAME BYTES 138.--------------- ------------------------------------------------------------TEMP /u02/oradata/TESTDB/datafile/o1_mf_temp_2g3spvq5_.tmp 536870912

If users are currently accessing the tempfile(s) you are attempting to drop, you may receive the f error:
SQL> alter database tempfile 2 '+TESTDB_DATA1/testdb/tempfile/temp.261.598485663' 3 drop including datafiles; ERROR at line 1: ORA-25152: TEMPFILE cannot be dropped at this time

As for the poor users who were using the tempfile, their transaction will end and will be greeted following error message:
SQL> @testTemp.sql join dba_extents c on (b.segment_name = c.segment_name) * ERROR at line 4: ORA-00372: file 601 cannot be modified at this time ORA-01110: data file 601: '+TESTDB_DATA1/testdb/tempfile/temp.261.598485663' ORA-00372: file 601 cannot be modified at this time ORA-01110: data file 601: '+TESTDB_DATA1/testdb/tempfile/temp.261.598485663'

If this happens, you should attempt to drop the tempfile again so the operation is successful:
SQL> alter database tempfile 2 '+TESTDB_DATA1/testdb/tempfile/temp.261.598485663' 3 drop including datafiles; Database altered.

139.From a SQL*Plus session, re-create any online redo logfiles that are still currently using ASM to the local file system. This is done by simply dropping the logfiles from ASM and re-creating them on the local file system. This example relies on the initialization parameters db_create_file_dest=/u02/oradata and db_recovery_file_dest=/u02/flash_recovery_area: o Determine the current online redo logfiles to move to the local file system by examining the file names (and sizes) from V$LOGFILE:
o o o o o SQL> select a.group#, a.member, b.bytes 2 from v$logfile a, v$log b where a.group# = b.group#; GROUP# MEMBER BYTES ------ ----------------------------------------------------------- ----------

o 1 +TESTDB_DATA1/testdb/onlinelog/group_1.259.598486831 o 2 +TESTDB_DATA1/testdb/onlinelog/group_2.260.598487179 o 3 +TESTDB_DATA1/testdb/onlinelog/group_3.258.598487365 o 1 +FLASH_RECOVERY_AREA/testdb/onlinelog/group_1.259.598486879 o 2 +FLASH_RECOVERY_AREA/testdb/onlinelog/group_2.257.598487225 o 3 +FLASH_RECOVERY_AREA/testdb/onlinelog/group_3.260.598487411 o 6 rows selected. o

262144000 262144000 262144000 262144000 262144000 262144000

Force a log switch until the last redo log is marked "CURRENT" by issuing the following command:

o SQL> select group#, status from v$log; o o GROUP# STATUS o ---------- ---------------o 1 CURRENT o 2 INACTIVE o 3 INACTIVE o o SQL> alter system switch logfile; o o SQL> alter system switch logfile; o o SQL> select group#, status from v$log; o o GROUP# STATUS o ---------- ---------------o 1 INACTIVE o 2 INACTIVE o 3 CURRENT o After making the last online redo log file the CURRENT one, o SQL> alter database drop logfile group 1; o Database altered.

drop the first online redo log:

As a DBA, you should already be aware that if you are going to drop a logfile group, it c the current logfile group. I have run into instances; however, where attempting to drop th group resulted in the following error as a result of the logfile group having an active

SQL> ALTER DATABASE DROP LOGFILE GROUP 1; ALTER DATABASE DROP LOGFILE GROUP 1 * ERROR at line 1: ORA-01624: log 1 needed for crash recovery of instance TESTDB (thread 1 ORA-00312: online log 1 thread 1: '<file_name>'

Easy problem to resolve. Simply perform a checkpoint on the database:
SQL> ALTER SYSTEM CHECKPOINT GLOBAL; System altered. SQL> ALTER DATABASE DROP LOGFILE GROUP 1; Database altered. o Re-create the dropped redo log group in the local file system (and o SQL> alter database add logfile group 1 size 250m; o Database altered.

a different size if desired):

o o o o o o o o o o o o o o o o o

After re-creating the online redo log group, force a log switch. The online redo log group just created should become the CURRENT one:
SQL> select group#, status from v$log; GROUP# ---------1 2 3 STATUS ---------------UNUSED INACTIVE CURRENT

SQL> alter system switch logfile; SQL> select group#, status from v$log; GROUP# STATUS ---------- ---------------1 CURRENT 2 INACTIVE 3 ACTIVE

o o o o o o o o o o o o o

After re-creating the first online redo log group, loop back to drop / re-create the next online redo logfile until all logs are rebuilt in the local file system. Verify all online redo logfiles have been created in the local file system:
SQL> select a.group#, a.member, b.bytes 2 from v$logfile a, v$log b where a.group# = b.group#; GROUP# MEMBER BYTES ------ -----------------------------------------------------------------------------1 /u02/oradata/TESTDB/onlinelog/o1_mf_1_2g3tc008_.log 262144000 2 /u02/oradata/TESTDB/onlinelog/o1_mf_2_2g3tkbwn_.log 262144000 3 /u02/oradata/TESTDB/onlinelog/o1_mf_3_2g3tmwno_.log 262144000 1 /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_1_2g3tc763_.log 262144000 2 /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_2_2g3tkmr6_.log 262144000 3 /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_3_2g3tn2g5_.log 262144000

o 6 rows selected.

140.Verify that all database files have been created in the local file system: 141.$ sqlplus "/ as sysdba"
142. 143.SQL> @dba_files_all 144. 145.Tablespace Name / 146.File Class Filename File Size Auto Next Max 147.---------------------------------------------------------------------------------------------------------- ---- ----------- --------------148.APEX22 /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TSAPEX22_FNO-6_14hqpm8s 104,857,600 NO 0 0

149.EXAMPLE /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TSEXAMPLE_FNO-4_13hqpm83 157,286,400 YES 655,360 34,359,721,984 150.FLOW_1 /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TSFLOW_1_FNO-7_15hqpm9c 52,494,336 NO 0 0 151.SYSAUX /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TSSYSAUX_FNO-3_11hqpm5s 419,430,400 YES 10,485,760 34,359,721,984 152.SYSTEM /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TSSYSTEM_FNO-1_10hqpm45 608,174,080 YES 10,485,760 34,359,721,984 153.TEMP /u02/oradata/TESTDB/datafile/o1_mf_temp_2g3spvq5_.tmp 536,870,912 YES 262,144,000 34,359,721,984 154.UNDOTBS1 /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TSUNDOTBS1_FNO-2_12hqpm7a 209,715,200 YES 5,242,880 34,359,721,984 155.USERS /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TSUSERS_FNO-5_0vhqpltd 2,382,888,960 YES 1,310,720 34,359,721,984 156.[ CONTROL FILE ] /u02/oradata/TESTDB/control01.ctl 157.[ ONLINE REDO LOG ] /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_1_2g3tc763_.log 262,144,000 158.[ ONLINE REDO LOG ] /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_2_2g3tkmr6_.log 262,144,000 159.[ ONLINE REDO LOG ] /u02/flash_recovery_area/TESTDB/onlinelog/o1_mf_3_2g3tn2g5_.log 262,144,000 160.[ ONLINE REDO LOG ] /u02/oradata/TESTDB/onlinelog/o1_mf_1_2g3tc008_.log 262,144,000 161.[ ONLINE REDO LOG ] /u02/oradata/TESTDB/onlinelog/o1_mf_2_2g3tkbwn_.log 262,144,000 162.[ ONLINE REDO LOG ] /u02/oradata/TESTDB/onlinelog/o1_mf_3_2g3tmwno_.log 262,144,000 163. --------------164.sum 6,044,581,888 165. 15 rows selected.

166.At this point, the target database is open with all of its datafiles, controlfiles, online redo logfiles, tempfiles, and SPFILE stored in the local file system. If we wanted to remove the database files that were stored using ASM (which are actually now RMAN copies), this could be done from an RMAN session. You could also then remove the old version of the controfile(s) and SPFILE that were stored using ASM using a SQL*Plus session logged in to the ASM instance: If this is a production database, it would be best practice to first backup the database files on the local disk before removing the copies stored using ASM! 167.RMAN> DELETE NOPROMPT FORCE COPY;
168. 169.using target database control file instead of recovery catalog 170.allocated channel: ORA_DISK_1 171.channel ORA_DISK_1: sid=155 devtype=DISK 172. 173.List of Datafile Copies 174.Key File S Completion Time Ckp SCN Ckp Time Name 175.------- ---- - --------------- ---------- --------------- ---176.59 1 A 15-AUG-06 7970332 15-AUG-06 +TESTDB_DATA1/testdb/datafile/system.269.598482099 177.60 2 A 15-AUG-06 7970332 15-AUG-06 +TESTDB_DATA1/testdb/datafile/undotbs1.256.598482299

178.61 3 A 15-AUG-06 7970332 15-AUG-06 +TESTDB_DATA1/testdb/datafile/sysaux.267.598482213 179.62 4 A 15-AUG-06 7970332 15-AUG-06 +TESTDB_DATA1/testdb/datafile/example.264.598482345 180.63 5 A 15-AUG-06 7970332 15-AUG-06 +TESTDB_DATA1/testdb/datafile/users.270.598481673 181.64 6 A 15-AUG-06 7970332 15-AUG-06 +TESTDB_DATA1/testdb/datafile/apex22.263.598482381 182.65 7 A 15-AUG-06 7970332 15-AUG-06 +TESTDB_DATA1/testdb/datafile/flow_1.262.598482405 183. 184.List of Control File Copies 185.Key S Completion Time Ckp SCN Ckp Time Name 186.------- - --------------- ---------- --------------- ---187.58 A 15-AUG-06 7970332 15-AUG-06 /u02/oradata/TESTDB/cf_DTESTDB_id-2370649665_16hqpm9j 188. 189.List of Archived Log Copies 190.Key Thrd Seq S Low Time Name 191.------- ---- ------- - --------- ---192.54 1 4 A 14-AUG-06 /u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_4_2g3qxnxt_.arc 193.55 1 5 A 14-AUG-06 /u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_5_2g3qxo2c_.arc 194.56 1 1 A 15-AUG-06 /u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_1_2g3t3v8b_.arc 195.57 1 2 A 15-AUG-06 /u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_2_2g3t4q1g_.arc 196.58 1 3 A 15-AUG-06 /u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_3_2g3tdm2s_.arc 197.59 1 4 A 15-AUG-06 /u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_4_2g3tlkfk_.arc 198.60 1 5 A 15-AUG-06 /u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_5_2g3tqb1h_.arc 199.deleted datafile copy 200.datafile copy filename=+TESTDB_DATA1/testdb/datafile/system.269.598482099 recid=59 stamp=598531780 201.deleted datafile copy 202.datafile copy filename=+TESTDB_DATA1/testdb/datafile/undotbs1.256.598482299 recid=60 stamp=598531780 203.deleted datafile copy 204.datafile copy filename=+TESTDB_DATA1/testdb/datafile/sysaux.267.598482213 recid=61 stamp=598531780 205.deleted datafile copy 206.datafile copy filename=+TESTDB_DATA1/testdb/datafile/example.264.598482345 recid=62 stamp=598531780 207.deleted datafile copy 208.datafile copy filename=+TESTDB_DATA1/testdb/datafile/users.270.598481673 recid=63 stamp=598531780 209.deleted datafile copy 210.datafile copy filename=+TESTDB_DATA1/testdb/datafile/apex22.263.598482381 recid=64 stamp=598531780 211.deleted datafile copy 212.datafile copy filename=+TESTDB_DATA1/testdb/datafile/flow_1.262.598482405 recid=65 stamp=598531780 213.deleted control file copy 214.control file copy filename=/u02/oradata/TESTDB/cf_D-TESTDB_id2370649665_16hqpm9j recid=58 stamp=598530356 215.deleted archive log

216.archive log filename=/u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_4_2g3qxn xt_.arc recid=54 stamp=598531956 217.deleted archive log 218.archive log filename=/u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_5_2g3qxo 2c_.arc recid=55 stamp=598531962 219.deleted archive log 220.archive log filename=/u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_1_2g3t3v 8b_.arc recid=56 stamp=598534203 221.deleted archive log 222.archive log filename=/u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_2_2g3t4q 1g_.arc recid=57 stamp=598534231 223.deleted archive log 224.archive log filename=/u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_3_2g3tdm 2s_.arc recid=58 stamp=598534483 225.deleted archive log 226.archive log filename=/u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_4_2g3tlk fk_.arc recid=59 stamp=598534673 227.deleted archive log 228.archive log filename=/u02/flash_recovery_area/TESTDB/archivelog/2006_08_15/o1_mf_1_5_2g3tqb 1h_.arc recid=60 stamp=598534826 229.Deleted 15 objects 230. 231.RMAN> exit 232. 233.$ ORACLE_SID=+ASM; export ORACLE_SID 234.$ sqlplus "/ as sysdba" 235. 236.SQL> ALTER DISKGROUP TESTDB_DATA1 DROP FILE '+TESTDB_DATA1/TESTDB/CONTROLFILE/backup.268.598481391'; 237. 238.Diskgroup altered. 239. 240.SQL> ALTER DISKGROUP TESTDB_DATA1 DROP FILE '+TESTDB_DATA1/TESTDB/spfileTESTDB.ora'; 241. 242.Diskgroup altered.

243.One final note. Throughout this article, you will have noticed that I relied on using Oracle Managed Files (OMF) whenever possible. However, you can see that after relocating the database files from ASM to the local file system that our datafiles and controlfile(s) are not OMF. In this final task, I will convert the current datafiles and controlfile(s) to OMF: o First, determine the non-OMF controlfiles (to be renamed) currently in use:
o SQL> select name from v$controlfile; o o NAME o --------------------------------/u02/oradata/TESTDB/control01.ctl o o o o

Next, determine the non-OMF datafiles (to be renamed) by examining the view DBA_DATA_FILES:
SQL> SELECT tablespace_name, file_name 2 FROM dba_data_files;

o o o o o o o o o

o 7 rows selected.

TABLESPACE_NAME FILE_NAME --------------------------------------------------------------------------------------SYSTEM /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-SYSTEM_FNO1_10hqpm45 UNDOTBS1 /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-UNDOTBS1_FNO2_12hqpm7a SYSAUX /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-SYSAUX_FNO3_11hqpm5s EXAMPLE /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-EXAMPLE_FNO4_13hqpm83 USERS /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-USERS_FNO5_0vhqpltd APEX22 /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-APEX22_FNO6_14hqpm8s FLOW_1 /u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-FLOW_1_FNO7_15hqpm9c

o Shutdown the database: o SQL> shutdown immediate o Database closed. o Database dismounted. ORACLE instance shut down. o Rename the non-OMF controlfile(s) in the file system to the newest o $ cd /u02/oradata/TESTDB o $ mkdir -p controlfile o $ cp control01.ctl controlfile/o1_mf_8du3s3er_ o .ctl o $ cp control01.ctl controlfile/o1_mf_y2is93je_.ctl $ rm control01.ctl o

OMF file name format:

o SQL> startup nomount o ORACLE instance started. o o Total System Global Area 285212672 bytes o Fixed Size 1260420 bytes o Variable Size 150996092 bytes o Database Buffers 130023424 bytes o Redo Buffers 2932736 bytes o o SQL> alter system set o 2 control_files='/u02/oradata/TESTDB/controlfile/o1_mf_8du3s3er_.ctl', o 3 '/u02/oradata/TESTDB/controlfile/o1_mf_y2is93je_.ctl' o 4 scope=spfile; o o System altered. o o SQL> shutdown immediate o ORA-01507: database not mounted o o ORACLE instance shut down. o

Modify the control_files initialization parameter in your init.ora or SPFILE to reference the new name(s):

Rename the non-OMF datafiles in the file system to the newest OMF file name format:

o o o

$ cd /u02/oradata/TESTDB $ mkdir -p datafile $ mv data_D-TESTDB_I-2370649665_TS-SYSTEM_FNO-1_10hqpm45 datafile/o1_mf_system_2fb4b8s2_.dbf o $ mv data_D-TESTDB_I-2370649665_TS-UNDOTBS1_FNO-2_12hqpm7a datafile/o1_mf_undotbs1_2fb4c2wf_.dbf o $ mv data_D-TESTDB_I-2370649665_TS-SYSAUX_FNO-3_11hqpm5s datafile/o1_mf_sysaux_2fb4cb7z_.dbf o $ mv data_D-TESTDB_I-2370649665_TS-EXAMPLE_FNO-4_13hqpm83 datafile/o1_mf_example_2fb4ccw2_.dbf o $ mv data_D-TESTDB_I-2370649665_TS-USERS_FNO-5_0vhqpltd datafile/o1_mf_users_2fb4cqf4_.dbf o $ mv data_D-TESTDB_I-2370649665_TS-APEX22_FNO-6_14hqpm8s datafile/o1_mf_apex22_2ft4eswu_.dbf $ mv data_D-TESTDB_I-2370649665_TS-FLOW_1_FNO-7_15hqpm9c datafile/o1_mf_flow_1_2fb4cegw_.dbf o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o o

Rename the files in the controlfile:
SQL> startup mount ORACLE instance started. Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers Database mounted. 285212672 1260420 150996092 130023424 2932736 bytes bytes bytes bytes bytes

SQL> alter database rename file 2 '/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-SYSTEM_FNO-1_10hqpm45' 3 to '/u02/oradata/TESTDB/datafile/o1_mf_system_2fb4b8s2_.dbf'; Database altered. SQL> alter database rename file 2 '/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-UNDOTBS1_FNO2_12hqpm7a' 3 to '/u02/oradata/TESTDB/datafile/o1_mf_undotbs1_2fb4c2wf_.dbf'; Database altered. SQL> alter database rename file 2 '/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-SYSAUX_FNO-3_11hqpm5s' 3 to '/u02/oradata/TESTDB/datafile/o1_mf_sysaux_2fb4cb7z_.dbf'; Database altered. SQL> alter database rename file 2 '/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-EXAMPLE_FNO-4_13hqpm83' 3 to '/u02/oradata/TESTDB/datafile/o1_mf_example_2fb4ccw2_.dbf'; Database altered. SQL> alter database rename file 2 '/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-USERS_FNO-5_0vhqpltd' 3 to '/u02/oradata/TESTDB/datafile/o1_mf_users_2fb4cqf4_.dbf'; Database altered. SQL> alter database rename file 2 '/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-APEX22_FNO-6_14hqpm8s'

o 3 to '/u02/oradata/TESTDB/datafile/o1_mf_apex22_2ft4eswu_.dbf'; o o Database altered. o o SQL> alter database rename file o 2 '/u02/oradata/TESTDB/data_D-TESTDB_I-2370649665_TS-FLOW_1_FNO-7_15hqpm9c' o 3 to '/u02/oradata/TESTDB/datafile/o1_mf_flow_1_2fb4cegw_.dbf'; o Database altered. o Open database and verify the new OMF files: o SQL> alter database open; o o Database altered. o o SQL> SELECT tablespace_name, file_name o 2 FROM dba_data_files; o o TABLESPACE_NAME FILE_NAME o --------------- --------------------------------------------------------o SYSTEM /u02/oradata/TESTDB/datafile/o1_mf_system_2fb4b8s2_.dbf o UNDOTBS1 /u02/oradata/TESTDB/datafile/o1_mf_undotbs1_2fb4c2wf_.dbf o SYSAUX /u02/oradata/TESTDB/datafile/o1_mf_sysaux_2fb4cb7z_.dbf o EXAMPLE /u02/oradata/TESTDB/datafile/o1_mf_example_2fb4ccw2_.dbf o USERS /u02/oradata/TESTDB/datafile/o1_mf_users_2fb4cqf4_.dbf o APEX22 /u02/oradata/TESTDB/datafile/o1_mf_apex22_2ft4eswu_.dbf o FLOW_1 /u02/oradata/TESTDB/datafile/o1_mf_flow_1_2fb4cegw_.dbf o 7 rows selected.

Sign up to vote on this title
UsefulNot useful