Sunday, May 17, 2015

Migrate Non ASM to ASM Database - 11g

Prerequisite
Running Non ASM 11g Database

Migration Steps

Download and Install appropriate ASMLib RPM's
  • oracleasm-support-2.1.7-1.el5.i386.rpm
  • oracleasmlib-2.0.4-1.el5.i386.rpm
  • oracleasm-[your-kernel-version].rpm

Then create the disk as follows which using creation of ASM instance









I have created 2 disks DISK1 and DISK2

Check the permission of created disk under /dev/oracleasm/disks/


Now unzip the grid software and install using ./runInstaller

And select 'Install and Configure Grid Infrastructure for Standalone Server' as we are not using ASM for RAC database.


Here you can able see the disks created earlier. I have kept the redundancy 'External' so that only one disk is required for a disk group. For redundancy 'Normal' we need to have a two disks in a diskgroup and for 'High' we need a minimum for three disks. Select the disk which has to be added to diskgroup named 'DATA'.

Provide the password for SYS and ASMSNMP

 Select the OS group or keep as It is



 Click Finish to begin the installation





Once the installation is completed you can check whether ASM processes are running

Now below are the steps to move Non ASM DB to ASM disks
SQL> select name from v$database;

NAME
---------
DEV

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEV/users01.dbf
/u01/app/oracle/oradata/DEV/undotbs01.dbf
/u01/app/oracle/oradata/DEV/sysaux01.dbf
/u01/app/oracle/oradata/DEV/system01.dbf
/u01/app/oracle/oradata/DEV/example01.dbf

SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEV/temp01.dbf


SQL> show parameter spfile;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
spfile                               string      /u01/app/oracle/product/11.2.0
                                                 /dbhome_1/dbs/spfileDEV.ora


SQL> show parameter control_file;

NAME                                 TYPE        VALUE
------------------------------------ ----------- ------------------------------
control_file_record_keep_time        integer     7
control_files                        string      /u01/app/oracle/oradata/DEV/co
                                                 ntrol01.ctl, /u01/app/oracle/f
                                                 lash_recovery_area/DEV/control
                                                 02.ctl

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

System altered.

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

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

SQL> startup nomount;
ORACLE instance started.

Total System Global Area 1653518336 bytes
Fixed Size                  2213896 bytes
Variable Size             956303352 bytes
Database Buffers          687865856 bytes
Redo Buffers                7135232 bytes

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


[oracle@dev ~]$ rman target /

Recovery Manager: Release 11.2.0.1.0 - Production on Thu May 14 11:05:40 2015

Copyright (c) 1982, 2009, Oracle and/or its affiliates.  All rights reserved.

connected to target database: DEV (not mounted)

RMAN> restore controlfile from '/u01/app/oracle/oradata/DEV/control01.ctl';

Starting restore at 14-MAY-15
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=23 device type=DISK

channel ORA_DISK_1: copied control file copy
output file name=+DATA/dev/controlfile/current.257.879678343
Finished restore at 14-MAY-15

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

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

Starting backup at 14-MAY-15
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=25 device type=DISK
channel ORA_DISK_1: starting datafile copy
input datafile file number=00001 name=/u01/app/oracle/oradata/DEV/system01.dbf
output file name=+DATA/dev/datafile/system.258.879679631 tag=TAG20150514T112711 RECID=2 STAMP=879679658
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:35
channel ORA_DISK_1: starting datafile copy
input datafile file number=00002 name=/u01/app/oracle/oradata/DEV/sysaux01.dbf
output file name=+DATA/dev/datafile/sysaux.259.879679667 tag=TAG20150514T112711 RECID=3 STAMP=879679687
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile file number=00003 name=/u01/app/oracle/oradata/DEV/undotbs01.dbf
output file name=+DATA/dev/datafile/undotbs1.260.879679691 tag=TAG20150514T112711 RECID=4 STAMP=879679697
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
input datafile file number=00005 name=/u01/app/oracle/oradata/DEV/example01.dbf
output file name=+DATA/dev/datafile/example.261.879679699 tag=TAG20150514T112711 RECID=5 STAMP=879679703
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:07
channel ORA_DISK_1: starting datafile copy
copying current control file
output file name=+DATA/dev/controlfile/backup.262.879679707 tag=TAG20150514T112711 RECID=6 STAMP=879679707
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting datafile copy
input datafile file number=00004 name=/u01/app/oracle/oradata/DEV/users01.dbf
output file name=+DATA/dev/datafile/users.263.879679709 tag=TAG20150514T112711 RECID=7 STAMP=879679709
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 14-MAY-15
channel ORA_DISK_1: finished piece 1 at 14-MAY-15
piece handle=+DATA/dev/backupset/2015_05_14/nnsnf0_tag20150514t112711_0.264.879679711 tag=TAG20150514T112711 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 14-MAY-15

RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DATA/dev/datafile/system.258.879679631"
datafile 2 switched to datafile copy "+DATA/dev/datafile/sysaux.259.879679667"
datafile 3 switched to datafile copy "+DATA/dev/datafile/undotbs1.260.879679691"
datafile 4 switched to datafile copy "+DATA/dev/datafile/users.263.879679709"
datafile 5 switched to datafile copy "+DATA/dev/datafile/example.261.879679699"

RMAN> alter database open;

database opened

RMAN> Exit

SQL> select file_name from dba_data_files;

FILE_NAME
--------------------------------------------------------------------------------
+DATA/dev/datafile/users.263.879679709
+DATA/dev/datafile/undotbs1.260.879679691
+DATA/dev/datafile/sysaux.259.879679667
+DATA/dev/datafile/system.258.879679631
+DATA/dev/datafile/example.261.879679699

SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEV/temp01.dbf

SQL> alter database tempfile '/u01/app/oracle/oradata/DEV/temp01.dbf' drop including datafiles;

Database altered.

SQL> select file_name from dba_temp_files;

no rows selected

SQL> alter tablespace temp add tempfile size 300M;

Tablespace altered.

SQL> select file_name from dba_temp_files;

FILE_NAME
--------------------------------------------------------------------------------
+DATA/dev/tempfile/temp.265.879682295

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEV/redo03.log
/u01/app/oracle/oradata/DEV/redo02.log
/u01/app/oracle/oradata/DEV/redo01.log


SQL> alter database add logfile group 4 '+DATA' size 10M;

Database altered.

SQL> alter database add logfile group 5 '+DATA' size 10M;

Database altered.

SQL> alter database add logfile group 6 '+DATA' size 10M;

Database altered.

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEV/redo03.log
/u01/app/oracle/oradata/DEV/redo02.log
/u01/app/oracle/oradata/DEV/redo01.log
+DATA/dev/onlinelog/group_4.266.879682579
+DATA/dev/onlinelog/group_5.267.879682595
+DATA/dev/onlinelog/group_6.268.879682607

6 rows selected.


SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.

SQL> select member from v$logfile;

MEMBER
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/DEV/redo01.log
+DATA/dev/onlinelog/group_4.266.879682579
+DATA/dev/onlinelog/group_5.267.879682595
+DATA/dev/onlinelog/group_6.268.879682607

SQL>  

SQL> select group#,status from v$log;

    GROUP# STATUS
---------- ----------------
         1 ACTIVE
         4 ACTIVE
         5 CURRENT
         6 UNUSED

SQL> alter system switch logfile;

System altered.

SQL> select group#,status from v$log;

    GROUP# STATUS
---------- ----------------
         1 ACTIVE
         4 ACTIVE
         5 ACTIVE
         6 CURRENT


SQL> alter system checkpoint;

System altered.

SQL> select group#,status from v$log;

    GROUP# STATUS
---------- ----------------
         1 INACTIVE
         4 CURRENT
         5 INACTIVE
         6 INACTIVE

SQL> alter database drop logfile group 1;

Database altered.

SQL>