Search This Blog

Thursday, April 26, 2012

Convert Oracle Database From Non-ASM to ASM.

Modify parameters

SQL> alter database disable block change tracking;

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

System altered.

SQL> alter system set db_recovery_file_dest='+FLASH' scope=spfile;

System altered.

SQL> alter system set control_files='+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  201326592 bytes
Fixed Size                  1218508 bytes
Variable Size              67110964 bytes
Database Buffers          130023424 bytes
Redo Buffers                2973696 bytes

Connect through RMAN.

[oracle@vmlinux1 bin]$ rman target=/

Recovery Manager: Release 10.2.0.1.0 - Production on Wed Apr 25 19:35:38 2012

Copyright (c) 1982, 2005, Oracle.  All rights reserved.

connected to target database: racorcl (not mounted)


#Restore current controlfile from where it is presently located.

RMAN> restore controlfile from '/u05/app/oracle/oradata/racorcl/control01.ctl';

Starting restore at 25-APR-2012 19:37:58
using target database control file instead of recovery catalog
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK

channel ORA_DISK_1: copied control file copy
output filename=+DATA/racorcl/controlfile/backup.269.781558685
Finished restore at 25-APR-2012 19:38:08


# Mount The Database.

RMAN> alter database mount;

database mounted
released channel: ORA_DISK_1

# Copy the database to ASM group.

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

Starting backup at 25-APR-2012 19:40:14
allocated channel: ORA_DISK_1
channel ORA_DISK_1: sid=156 devtype=DISK
channel ORA_DISK_1: starting datafile copy
input datafile fno=00001 name=/u05/app/oracle/oradata/racorcl/system01.dbf
output filename=+DATA/racorcl/datafile/system.270.781558817 tag=TAG20120425T194015 recid=2 stamp=781558865
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:55
channel ORA_DISK_1: starting datafile copy
input datafile fno=00003 name=/u05/app/oracle/oradata/racorcl/sysaux01.dbf
output filename=+DATA/racorcl/datafile/sysaux.262.781558883 tag=TAG20120425T194015 recid=3 stamp=781558964
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:01:42
channel ORA_DISK_1: starting datafile copy
input datafile fno=00005 name=/u05/app/oracle/oradata/racorcl/example01.dbf
output filename=+DATA/racorcl/datafile/example.256.781558973 tag=TAG20120425T194015 recid=4 stamp=781558991
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:25
channel ORA_DISK_1: starting datafile copy
input datafile fno=00002 name=/u05/app/oracle/oradata/racorcl/undotbs01.dbf
output filename=+DATA/racorcl/datafile/undotbs1.257.781558999 tag=TAG20120425T194015 recid=5 stamp=781559002
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:08
channel ORA_DISK_1: starting datafile copy
input datafile fno=00004 name=/u05/app/oracle/oradata/racorcl/users01.dbf
output filename=+DATA/racorcl/datafile/users.258.781559007 tag=TAG20120425T194015 recid=6 stamp=781559007
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:01
channel ORA_DISK_1: starting datafile copy
copying current control file
output filename=+DATA/racorcl/controlfile/backup.259.781559007 tag=TAG20120425T194015 recid=7 stamp=781559008
channel ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel ORA_DISK_1: starting full datafile backupset
channel ORA_DISK_1: specifying datafile(s) in backupset
including current SPFILE in backupset
channel ORA_DISK_1: starting piece 1 at 25-APR-2012 19:43:32
channel ORA_DISK_1: finished piece 1 at 25-APR-2012 19:43:33
piece handle=+DATA/racorcl/backupset/2012_04_25/nnsnf0_tag20120425t194015_0.260.781559013
tag=TAG20120425T194015 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:03
Finished backup at 25-APR-2012 19:43:33

# Switch the database to new copy.

RMAN> switch database to copy;

datafile 1 switched to datafile copy "+DATA/racorcl/datafile/system.270.781558817"
datafile 2 switched to datafile copy "+DATA/racorcl/datafile/undotbs1.257.781558999"
datafile 3 switched to datafile copy "+DATA/racorcl/datafile/sysaux.262.781558883"
datafile 4 switched to datafile copy "+DATA/racorcl/datafile/users.258.781559007"
datafile 5 switched to datafile copy "+DATA/racorcl/datafile/example.256.781558973"


# Recover Database

RMAN> recover database;

Starting recover at 25-APR-2012 19:45:25
using channel ORA_DISK_1

starting media recovery
media recovery complete, elapsed time: 00:00:00

Finished recover at 25-APR-2012 19:45:27

# Connect Through SQL prompt.

# Move flashback logs if flashback is enabled.
# SQL> alter database flashback off;
# SQL> alter database flashback on;

SQL> select open_mode from v$database;

OPEN_MODE
----------
MOUNTED



SQL> alter database open;

Database altered


# Create temporary tablespace in the new location and drop
# the old one.

SQL> create temporary tablespace temp1 tempfile '+DATA';

Tablespace created.

SQL> alter database default temporary tablespace temp1;

Database altered.

SQL> drop tablespace temp including contents and datafiles;

Tablespace dropped.


# Create RedoLog Groups in the new location and drop the old ones.

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

Database altered.

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

Database altered.

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

Database altered.

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
         1          1          2   52428800          1 NO  ACTIVE
       475458 25-APR-12

         2          1          3   52428800          1 NO  CURRENT
       478631 25-APR-12

         3          1          1   52428800          1 NO  INACTIVE
       446075 25-APR-12


    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
         4          1          0  104857600          1 YES UNUSED
            0

         5          1          0  104857600          1 YES UNUSED
            0

         6          1          0  104857600          1 YES UNUSED
            0


6 rows selected.


SQL> alter system switch logfile;

SQL> alter system switch logile;

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
         1          1          2   52428800          1 NO  ACTIVE
       475458 25-APR-12

         2          1          3   52428800          1 NO  ACTIVE
       478631 25-APR-12

         3          1          1   52428800          1 NO  INACTIVE
       446075 25-APR-12


    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
         4          1          4  104857600          1 NO  ACTIVE
       478688 25-APR-12

         5          1          5  104857600          1 NO  CURRENT
       478690 25-APR-12

         6          1          0  104857600          1 YES UNUSED
            0


6 rows selected.


SQL> alter system checkpoint;

System altered.

SQL> select * from v$log;

    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
         1          1          2   52428800          1 NO  INACTIVE
       475458 25-APR-12

         2          1          3   52428800          1 NO  INACTIVE
       478631 25-APR-12

         3          1          1   52428800          1 NO  INACTIVE
       446075 25-APR-12


    GROUP#    THREAD#  SEQUENCE#      BYTES    MEMBERS ARC STATUS
---------- ---------- ---------- ---------- ---------- --- ----------------
FIRST_CHANGE# FIRST_TIM
------------- ---------
         4          1          4  104857600          1 NO  INACTIVE
       478688 25-APR-12

         5          1          5  104857600          1 NO  CURRENT
       478690 25-APR-12

         6          1          0  104857600          1 YES UNUSED
            0


6 rows selected.


SQL> alter database drop logfile group 1;

Database altered.

SQL> alter database drop logfile group 2;

Database altered.

SQL> alter database drop logfile group 3;

Database altered.



1 comment:

  1. dear sir
    your oracle is very use full of practice of oracle dba

    ReplyDelete