Wednesday, 30 March 2016

Moving a Single Datafile from File System to ASM System (METHOD 2)


Condition ,
-  If you want to move SYSTEM & UNDO tablespace, DB stage is mounted.
-  If you want to other tablespace datafiles , Tablespace should be OFFLINE

Step 1:
Check datafile & ASM diskgroup size
SQL> col FILE_NAME format a40
SQL> select tablespace_name , file_name from dba_data_files;

TABLESPACE   FILE_NAME
---------------       --------------------------------
USERS                   +DATA/myasm/datafile/users.305.907085495
UNDOTBS1         +DATA/myasm/datafile/undotbs1.304.907085495
SYSAUX                +DATA/myasm/datafile/sysaux.303.907085493
SYSTEM                +DATA/myasm/datafile/system.302.90708541
USERS                  /u01/demo.dbf

TABLESPACE   FILE_NAME
---------------       --------------------------------
DEMO                  +DATA/myasm/datafile/demo.319.907106321

6 rows selected.

Step 2: Tablespace offline

SQL> alter tablespace users offline;

Tablespace altered.

Step 3:
Here i just moved Users tablespace datafile to ‘+DATA’ diskgroup.

SQL> !rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Mon Mar 21 22:15:46 2016
Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.
connected to target database: MYASM (DBID=36010415)

RMAN> copy datafile '/u01/demo.dbf' to '+DATA';

Starting backup at 21-MAR-16
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=47 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/demo.dbf
output file name=+DATA/myasm/datafile/users.320.907107373 tag=TAG20160321T221611 RECID=2 STAMP=907107378
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08
Finished backup at 21-MAR-16

Step 4 :
Updataing the controlfile

RMAN> switch datafile '/u01/demo.dbf' to copy;

datafile 5 switched to datafile copy "+DATA/myasm/datafile/users.320.907107373"

RMAN> exit

Recovery Manager complete.

Step 5:
Check datafile location

SQL> select file_name from dba_data_files;

TABLESPACE   FILE_NAME
---------------       --------------------------------
USERS                   +DATA/myasm/datafile/users.305.907085495
UNDOTBS1         +DATA/myasm/datafile/undotbs1.304.907085495
SYSAUX                +DATA/myasm/datafile/sysaux.303.907085493
SYSTEM              +DATA/myasm/datafile/system.302.90708541
USERS                  +DATA/myasm/datafile/users.320.907107373

TABLESPACE   FILE_NAME
---------------       --------------------------------
DEMO                  +DATA/myasm/datafile/demo.319.907106321

6 rows selected.


SQL>


No comments:

Post a Comment