ASM Migrate Diskgroup

In this example we migrate all data from ORADATA1 to ORADATA2 then drop ORADATA1.

NOTE: Before starting any migrations ensure that any scheduled backups are complete.ALWAYS test your process on a system you can lose/recreate before attempting on servers that matter.

Create New Diskgroup

As a user (typically 'grid' or 'asm') with ASM environment set:

sqlplus / as sysasm

ALTER SYSTEM SET ASM_DISKSTRING = '/dev/rhdisk2*' , '/dev/asm*' SCOPE=BOTH;

CREATE DISKGROUP oradata2 EXTERNAL REDUNDANCY DISK '/dev/asm69','/dev/asm70','/dev/asm103','/dev/asm104','/dev/asm105';

Assuming asm69/asm70/asm103/asm104/asm105 are suitable candidate disks

As 'oracle' with Database environment set:

sqlplus / as sysdba

ALTER SYSTEM SET db_create_file_dest = '+ORADATA2' SCOPE=BOTH;

Migrate TEMP

Create new temporary tablespace:

As 'oracle' with Database environment set:

sqlplus / as sysdba

CREATE TEMPORARY TABLESPACE temp2;


SELECT property_value

FROM database_properties

WHERE property_name = 'DEFAULT_TEMP_TABLESPACE';


PROPERTY_VALUE--------------------------------------------------------------------------------TEMP

Make the new tablespace the default temporary tablespace for the database:

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp2;

SELECT property_value

FROM database_properties

WHERE property_name = 'DEFAULT_TEMP_TABLESPACE';

PROPERTY_VALUE--------------------------------------------------------------------------------TEMP2

Check no users still have the old tablespace as their default temporary tablespace:

SELECT username, temporary_tablespace

FROM dba_users;

Check whether any sessions still have active segments in the old temporary tablespace.

Script below available as /u01/dba/usr/tempuse.sql (See: Metalink 1069041.6)

SELECT b.tablespace, b.segfile#, b.segblk#, b.blocks, a.sid, a.serial#,

a.username, a.osuser, a.status

FROM v$session a,v$sort_usage b

WHERE a.saddr = b.session_addr

ORDER BY b.tablespace, b.segfile#, b.segblk#, b.blocks;

Wait for all sessions using segments in TEMP to terminate (or kill them, if you're in a hurry)

DROP TABLESPACE temp INCLUDING CONTENTS AND DATAFILES;

Migrate Datafiles

Example assume you are using RMAN with a recovery catalog...

rman target / catalog=rcat/******@RCAT

report schema;

Use 'report schema' to retrieve the datafile File numbers (for use in the command below) and for reviewing your progress

sql 'alter database datafile 9 offline';

backup as copy datafile 9 format '+ORADATA2';

switch datafile '+ORADATA1/oratest/datafile/myts_1.267.608589927' to COPY;

Refer to the output of the "backup as copy" command for the correct datafile name to use (input datafile)

report schema;

Datafile should now be reported to be on the new Diskgroup. Use the new "Datafile Name" in the command below

recover datafile '+ORADATA2/oratest/datafile/newdatafilename';

sql 'alter database datafile 9 online';

Repeat until all datafiles are migrated

Migrate Redo Logs

GROUP# STATUS TYPE MEMBER IS_---------- ------- ------- -------------------------------------------------- --- 4 ONLINE +ORADATA1/oratest/onlinelog/group_4.274.612200571 NO 4 ONLINE +ORARECO1/oratest/onlinelog/group_4.647.612200579 NO 5 ONLINE +ORADATA1/oratest/onlinelog/group_5.275.612200669 NO 5 ONLINE +ORARECO1/oratest/onlinelog/group_5.652.612200677 NO 6 ONLINE +ORADATA1/oratest/onlinelog/group_6.276.612200753 NO 6 ONLINE +ORARECO1/oratest/onlinelog/group_6.655.612200761 NO
SET LINESIZE 132COLUMN member FORMAT A50 SELECT *FROM v$logfileORDER BY group#, member;

First, add group members on new diskgroup:

ALTER DATABASE ADD LOGFILE MEMBER '+ORADATA2' TO GROUP 4;

ALTER DATABASE ADD LOGFILE MEMBER '+ORADATA2' TO GROUP 5;

ALTER DATABASE ADD LOGFILE MEMBER '+ORADATA2' TO GROUP 6;

GROUP# STATUS TYPE MEMBER IS_---------- ------- ------- -------------------------------------------------- --- 4 ONLINE +ORADATA1/oratest/onlinelog/group_4.274.612200571 NO 4 INVALID ONLINE +ORADATA2/oratest/onlinelog/group_4.270.668618897 NO 4 ONLINE +ORARECO1/oratest/onlinelog/group_4.647.612200579 NO 5 ONLINE +ORADATA1/oratest/onlinelog/group_5.275.612200669 NO 5 INVALID ONLINE +ORADATA2/oratest/onlinelog/group_5.274.668618975 NO 5 ONLINE +ORARECO1/oratest/onlinelog/group_5.652.612200677 NO 6 ONLINE +ORADATA1/oratest/onlinelog/group_6.276.612200753 NO 6 INVALID ONLINE +ORADATA2/oratest/onlinelog/group_6.275.668618983 NO 6 ONLINE +ORARECO1/oratest/onlinelog/group_6.655.612200761 NO
SET LINESIZE 132COLUMN member FORMAT A50 SELECT *FROM v$logfileORDER BY group#, member;

Clear 'INVALID' status by switching logfile to initialize new members:

ALTER SYSTEM SWITCH LOGFILE;

ALTER SYSTEM SWITCH LOGFILE;

ALTER SYSTEM SWITCH LOGFILE;

GROUP# STATUS TYPE MEMBER IS_---------- ------- ------- -------------------------------------------------- --- 4 ONLINE +ORADATA1/oratest/onlinelog/group_4.274.612200571 NO 4 ONLINE +ORADATA2/oratest/onlinelog/group_4.270.668618897 NO 4 ONLINE +ORARECO1/oratest/onlinelog/group_4.647.612200579 NO 5 ONLINE +ORADATA1/oratest/onlinelog/group_5.275.612200669 NO 5 ONLINE +ORADATA2/oratest/onlinelog/group_5.274.668618975 NO 5 ONLINE +ORARECO1/oratest/onlinelog/group_5.652.612200677 NO 6 ONLINE +ORADATA1/oratest/onlinelog/group_6.276.612200753 NO 6 ONLINE +ORADATA2/oratest/onlinelog/group_6.275.668618983 NO 6 ONLINE +ORARECO1/oratest/onlinelog/group_6.655.612200761 NO
SET LINESIZE 132COLUMN member FORMAT A50 SELECT *FROM v$logfileORDER BY group#, member;

Remove logfiles from +ORADATA1:

If you see this error...ORA-01609: log 4 is the current log for thread 1 - cannot drop members Then you will need to do this before you will be able to drop that file...ALTER SYSTEM SWITCH LOGFILE;

ALTER DATABASE DROP LOGFILE MEMBER '+ORADATA1/oratest/onlinelog/group_5.275.612200669';

ALTER DATABASE DROP LOGFILE MEMBER '+ORADATA1/oratest/onlinelog/group_6.276.612200753';

ALTER DATABASE DROP LOGFILE MEMBER '+ORADATA1/oratest/onlinelog/group_4.274.612200571';

GROUP# STATUS TYPE MEMBER IS_---------- ------- ------- -------------------------------------------------- --- 4 ONLINE +ORADATA2/oratest/onlinelog/group_4.270.668618897 NO 4 ONLINE +ORARECO1/oratest/onlinelog/group_4.647.612200579 NO 5 ONLINE +ORADATA2/oratest/onlinelog/group_5.274.668618975 NO 5 ONLINE +ORARECO1/oratest/onlinelog/group_5.652.612200677 NO 6 ONLINE +ORADATA2/oratest/onlinelog/group_6.275.668618983 NO 6 ONLINE +ORARECO1/oratest/onlinelog/group_6.655.612200761 NO
SET LINESIZE 132COLUMN member FORMAT A50 SELECT *FROM v$logfileORDER BY group#, member;

Migrate Controlfile

Connect to the 'oracle' user with the regular database environment set.
Shutdown the database, then startup with 'nomount' option.

sqlplus / as sysdba

shutdown immediate

startup nomount

show parameter control_files

Take careful note of existing setting of CONTROL_FILES initialization parameter.

Using Recovery Manager, restore controlfile to new location from old location:

rman target / catalog rcat/******@RCAT

restore controlfile to '+ORADATA2' from '+ORADATA1/oratest/controlfile/currentfilename';

In another session as a user (typically 'grid' or 'asm') with ASM environment set:

asmcmd

cd +ORADATA2

find -t controlfile . *

Take careful note of new Controlfile path

Back in the original 'oracle' environment:

sqlplus / as sysdba

ALTER SYSTEM SET control_files='+ORADATA2/oratest/controlfile/newfilename',

'+ORARECO1/oratest/controlfile/currentfilename' SCOPE=spfile;

shutdown immediate

startup

Drop Diskgroup

As a user (typically 'grid' or 'asm') with ASM environment set:

asmcmd

cd +ORADATA1

ls

cd oratest

ls

cd controlfile

ls

The only file/directory you should find is the controlfile you replaced in the previous step

sqlplus / as sysasm

DROP DISKGROUP oradata1 INCLUDING CONTENTS;

Disk Group Name Path File Name Fail Group File Size (MB) Used Size (MB) Pct. Used-------------------- ----------------- -------------------- -------------------- -------------- -------------- ---------ORADATA2 /dev/asm69 ORADATA2_0000 ORADATA2_0000 102,400 52,115 50.89 /dev/asm70 ORADATA2_0001 ORADATA2_0001 102,400 51,779 50.57 /dev/asm103 ORADATA2_0002 ORADATA2_0002 102,400 51,780 50.57 /dev/asm104 ORADATA2_0003 ORADATA2_0003 102,400 52,106 50.88 /dev/asm105 ORADATA2_0004 ORADATA2_0004 117,132 60,064 51.28******************** -------------- -------------- 526,732 267,844 ORARECO1 /dev/rhdisk26 ORARECO1_0000 CONTROLLERA 69,494 840 1.21 /dev/rhdisk29 ORARECO1_0003 CONTROLLERB 69,494 843 1.21******************** -------------- -------------- 138,988 1,683 [CANDIDATE] /dev/rhdisk23 69,494 69,494 100.00 /dev/rhdisk27 69,494 69,494 100.00 /dev/rhdisk24 69,494 69,494 100.00 /dev/rhdisk28 69,494 69,494 100.00 /dev/rhdisk25 69,494 69,494 100.00 /dev/rhdisk22 69,494 69,494 100.00 /dev/rhdisk20 69,494 69,494 100.00 /dev/rhdisk21 69,494 69,494 100.00******************** -------------- -------------- 555,952 555,952 -------------- --------------Grand Total: 1,221,672 825,479

Bibliography


https://support.oracle.com1069041.6