Database 11g

Monday, December 25, 2017

How to Convert Non ASM File System to ASM File System in Oracle Windows.



Oracle DB version     = 11.2.0.3
Operating system       = Windows 2008 Server
Datafile Location        = E:\KKPROD to +DATA diskgroup


>> Note :- This is my Test Environment.

>> Check the existing location of all the files like control files,datafiles,spfiles,archivelog files.

SQL> select name from v$controlfile;

NAME
--------------------------------------------------------------------------------
E:\KKPROD\CONTROL01.CTL
E:\KKPROD\CONTROL02.CTL


SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      C:\APP\MOIN\PRODUCT\11.2.0\DBHOME_1\DATABASE\SPFILEKKPROD.ORA


>> Set the controlfile location to your diskgroup where you planned to migrate control file.

SQL> alter system set control_files='+DATA' scope=spfile;


>> Set the Datafiles location to your diskgroup where you planned to migrate all your datafiles.

SQL> alter system set db_create_file_dest='+DATA' scope=spfile;

>> Shutdown immediate and open database in nomount state.

SQL> shutdown immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

SQL> startup nomount
ORACLE instance started.
Total System Global Area 2087780352 bytes
Fixed Size                  2256784 bytes
Variable Size             536871024 bytes
Database Buffers         1543503872 bytes
Redo Buffers                5148672 bytes

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.3.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options


>> Connect from RMAN and restore controlfile, oracle will restore the controlfile in new   diskgroup location as we SET above parameter control_files='+DATA'

C:\Windows\system32>rman target /

Recovery Manager: Release 11.2.0.3.0 - Production on Sun Dec 17 18:45:12 2017
Copyright (c) 1982, 2011, Oracle and/or its affiliates.  All rights reserved.
connected to target database: KKPROD (not mounted)

>> Here controlfile New location is updated in new diskgroup

RMAN> restore controlfile from 'E:\KKPROD\CONTROL01.CTL';

Starting restore at 17-DEC-17
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=68 device type=DISK
channel ORA_DISK_1: copied control file copy
output file name=+DATA/kkprod/controlfile/current.262.962995555
Finished restore at 17-DEC-17

 >> We can mount the database.

RMAN> alter database mount;
              database mounted

>> The 'BACKUP AS COPY' command creates image copies and removes the need to extract them from a backup set.  This command works on same principles of (CP) command in linux. these files are same as datafiles which you see below output. Image copies are used to quickly switch to datafile without the need of restore. this is the reason our next step will be to 'Swtich Database to Copy'.


RMAN> backup as copy database format '+DATA';

Starting backup at 17-DEC-17
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=5 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=E:\KKPROD\USERS01.DBF
output file name=+DATA/kkprod/datafile/users.267.962995627 tag=TAG20171217T184707 RECID=1 STAMP=962995725
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=E:\KKPROD\SYSTEM01.DBF
output file name=+DATA/kkprod/datafile/system.266.962995733 tag=TAG20171217T184707 RECID=2 STAMP=962995772
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=E:\KKPROD\SYSAUX01.DBF
output file name=+DATA/kkprod/datafile/sysaux.265.962995779 tag=TAG20171217T184707 RECID=3 STAMP=962995815
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=E:\KKPROD\UNDOTBS01.DBF
output file name=+DATA/kkprod/datafile/undotbs1.264.962995823 tag=TAG20171217T184707 RECID=4 STAMP=962995862
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:45
Finished backup at 17-DEC-17
Starting Control File and SPFILE Autobackup at 17-DEC-17
piece handle=E:\FRA\KKPROD\AUTOBACKUP\2017_12_17\O1_MF_S_962995260_F3F4MHM3_.BKP comment=NONE
Finished Control File and SPFILE Autobackup at 17-DEC-17


>> Switch command updates datafiles to the latest image copies.

RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DATA/kkprod/datafile/system.266.962995733"
datafile 2 switched to datafile copy "+DATA/kkprod/datafile/sysaux.265.962995779"
datafile 3 switched to datafile copy "+DATA/kkprod/datafile/undotbs1.264.962995823"
datafile 4 switched to datafile copy "+DATA/kkprod/datafile/users.267.962995627"


>> Now open the database and check whether all the datafiles are switched to +DATA diskgroup.

RMAN> alter database open;

database opened

SQL> select name from v$datafile;

NAME
------------------------------------------------------------------------------
+DATA/kkprod/datafile/system.266.962995733
+DATA/kkprod/datafile/sysaux.265.962995779
+DATA/kkprod/datafile/undotbs1.264.962995823
+DATA/kkprod/datafile/users.267.962995627


>> Done, All the files are switched to +DATA diskgroup.

>> Drop the old location of tempfile.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
E:\KKPROD\TEMP01.DBF
+DATA/kkprod/tempfile/temp.263.962996209

SQL> alter tablespace temp add tempfile size 500M;

Tablespace altered.

SQL> alter database tempfile 'E:\KKPROD\TEMP01.DBF' drop including datafiles;

Database altered.

SQL> select name from v$tempfile;

NAME
--------------------------------------------------------------------------------
+DATA/kkprod/tempfile/temp.263.962996209


>> Drop all the logfiles which are pointing to old location and add the new redologs.

>> All our database is migrated to ASM and now move archivelogs to ASM by clicking this link.


http://pages.di.unipi.it/ghelli/didattica/bdldoc/B19306_01/backup.102/b14191/rcmasm002.htm#BABJHIHA




Enjoy Reading...




No comments:

Post a Comment