Author:
Ashwani
1) I have a database YYAPRD running on normal file system
2) I have created disks DG1, DG2, DG3 and DG4 which will be used during ASM instance creation
2) I have created disks DG1, DG2, DG3 and DG4 which will be used during ASM instance creation
I have a database db11g running on normal
file system. I have two disk group +DATA and +FRA .
Disk Group Name
Path File
Name Fail Group File Size (MB) Used Size (MB)
------------------------- -------------------- --------------------
-------------------- -------------- --------------
DATA
ORCL:DISK1 DISK1 DISK1 2,047 1,396
ORCL:DISK4 DISK4 DISK4 2,047 1,393
*************************
-------------- --------------
4,094 2,789
FRA
ORCL:DISK3 DISK3 DISK3 2,047 232
ORCL:DISK2 DISK2 DISK2 2,047 232
*************************
-------------- --------------
4,094 464
-------------- --------------
Grand Total:
8,188 3,253
SQL> select name from v$database;
NAME
---------
DB11G
SQL> select file_name from
dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/db11g/users01.dbf
/u01/app/oracle/oradata/db11g/undotbs01.dbf
/u01/app/oracle/oradata/db11g/sysaux01.dbf
/u01/app/oracle/oradata/db11g/system01.dbf
SQL> select file_name from
dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/db11g/temp01.dbf
SQL> col member form a50
SQL> select member from v$logfile;
MEMBER
--------------------------------------------------
/u01/app/oracle/oradata/db11g/redo03.log
/u01/app/oracle/oradata/db11g/redo02.log
/u01/app/oracle/oradata/db11g/redo01.log
SQL> show parameter spfile
NAME TYPE VALUE
------------------------------------
----------- ------------------------------
spfile string /u01/app/oracle/product/11.2.0
/dbhome_1/dbs/spfiledb11g.ora
SQL> show parameter control_file
NAME TYPE VALUE
------------------------------------
----------- ------------------------------
control_file_record_keep_time integer 7
control_files string /u01/app/oracle/oradata/db11g/
control01.ctl, /u01/app/oracle
/flash_recovery_area/db11g/con
trol02.ctl
LOGIN to ASM INSTANCE and Check
DG-Group and disk available :
[oracle@db12c-prod grid]$ sqlplus / as
sysasm
SQL*Plus: Release 11.2.0.4.0
Production on Mon Jan 23 17:04:59 2017
Copyright (c) 1982, 2013,
Oracle. All rights reserved.
Connected to:
Oracle Database 11g Enterprise
Edition Release 11.2.0.4.0 - 64bit Production
With the Automatic Storage
Management option
SQL>-- Check the available DG groups
Out put:
Disk Group Name Path File Name Fail Group File Size (MB) Used Size (MB)
------------------------- -------------------- -------------------- -------------------- -------------- --------------
DATA ORCL:DISK1 DISK1 DISK1 2,047 1,396
ORCL:DISK4 DISK4 DISK4 2,047 1,393
************************* -------------- --------------
4,094 2,789
FRA ORCL:DISK3 DISK3 DISK3 2,047 232
ORCL:DISK2 DISK2 DISK2 2,047 232
************************* -------------- --------------
4,094 464
-------------- --------------
Grand Total: 8,188 3,253
Now, changed the location for control_file parameter to newly created
ASM disks and set parameter DB_CREATE_FILE_DEST to ASM disks which will be used
for datafiles. This parameter will serve as default location for all the
datafiles which will be created in database. I am using multiplexing for
controlfiles, so using two disk groups “+DATA” and “+FRA”. Once parameters are
set, restart the database in nomount state for RMAN to start movement.
SQL> alter system set
control_files='+DATA','+FRA' 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 626327552 bytes
Fixed Size 2215944 bytes
Variable Size 205524984 bytes
Database Buffers 415236096 bytes
Redo Buffers 3350528 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@db12c-prod ~]$
Now, connect with RMAN and restore control file first from the existing
one. This is create a new control file in ASM disk “+DATA” and “+FRA” and then
mount the database and backup the database as copy in ASM disk “+DATA” and as
last step switch database to copy. Following is the logs from this activity.
RMAN> restore controlfile from
'/u01/app/oracle/oradata/db11g/control01.ctl';
Starting restore at 23-JAN-17
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/db11g/controlfile/current.262.934047269
output file
name=+FRA/db11g/controlfile/current.258.934047271
Finished restore at 23-JAN-17
RMAN> alter database mount;
database
mounted
released
channel: ORA_DISK_1
RMAN> backup as copy database format '+DATA';
Starting
backup at 23-JAN-17
using
channel ORA_DISK_1
channel
ORA_DISK_1: starting datafile copy
input
datafile file number=00001 name=/u01/app/oracle/oradata/db11g/system01.dbf
output file
name=+DATA/db11g/datafile/system.260.934048403 tag=TAG20170123T175322 RECID=1
STAMP=934048441
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=/u01/app/oracle/oradata/db11g/sysaux01.dbf
output file
name=+DATA/db11g/datafile/sysaux.269.934048447 tag=TAG20170123T175322 RECID=2
STAMP=934048468
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/db11g/undotbs01.dbf
output file
name=+DATA/db11g/datafile/undotbs1.270.934048473 tag=TAG20170123T175322 RECID=3
STAMP=934048475
channel
ORA_DISK_1: datafile copy complete, elapsed time: 00:00:03
channel
ORA_DISK_1: starting datafile copy
copying
current control file
output file
name=+DATA/db11g/controlfile/backup.271.934048475 tag=TAG20170123T175322
RECID=4 STAMP=934048477
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/db11g/users01.dbf
output file
name=+DATA/db11g/datafile/users.272.934048479 tag=TAG20170123T175322 RECID=5
STAMP=934048479
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 23-JAN-17
channel ORA_DISK_1:
finished piece 1 at 23-JAN-17
piece
handle=+DATA/db11g/backupset/2017_01_23/nnsnf0_tag20170123t175322_0.273.934048481
tag=TAG20170123T175322 comment=NONE
channel
ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished
backup at 23-JAN-17
RMAN> switch database to copy;
datafile 1
switched to datafile copy "+DATA/db11g/datafile/system.260.934048403"
datafile 2
switched to datafile copy "+DATA/db11g/datafile/sysaux.269.934048447"
datafile 3
switched to datafile copy "+DATA/db11g/datafile/undotbs1.270.934048473"
datafile 4
switched to datafile copy "+DATA/db11g/datafile/users.272.934048479"
RMAN> alter database open;
database
opened
RMAN> exit
Recovery
Manager complete.
Now, we need to move the temporary tablespace files and online redo
logfiles to ASM. Best way is to create new ones in ASM and drop the old ones.
Following the steps to do that.
[oracle@db12c-prod
~]$ sqlplus
/ as sysdba
SQL*Plus:
Release 11.2.0.1.0 Production on Mon Jan 23 17:58:08 2017
Copyright
(c) 1982, 2009, Oracle. All rights
reserved.
Connected
to:
Oracle
Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the
Partitioning, Automatic Storage Management, OLAP, Data Mining
and Real
Application Testing options
SQL> select file_name from
dba_data_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/db11g/datafile/users.272.934048479
+DATA/db11g/datafile/undotbs1.270.934048473
+DATA/db11g/datafile/sysaux.269.934048447
+DATA/db11g/datafile/system.260.934048403
SQL> select bytes/1024/1024
from dba_temp_files;
BYTES/1024/1024
---------------
20
SQL> alter tablespace temp add
tempfile size 20M;
Tablespace
altered.
SQL> select file_name from
dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
/u01/app/oracle/oradata/db11g/temp01.dbf
+DATA/db11g/tempfile/temp.274.934049343
SQL> alter database tempfile '/u01/app/oracle/oradata/db11g/temp01.dbf' drop including datafiles;
Database altered.
SQL> SQL>
SQL> select file_name from dba_temp_files;
FILE_NAME
--------------------------------------------------------------------------------
+DATA/db11g/tempfile/temp.274.934049343
SQL> alter database add logfile group 4
('+DATA','+FRA') size 10M;
Database altered.
SQL> alter database add logfile group 5
('+DATA','+FRA') size 10M;
Database altered.
SQL> alter database add logfile group 6
('+DATA','+FRA') size 10M;
Database altered.
SQL> select * from v$log;
GROUP#
THREAD# SEQUENCE# BYTES
BLOCKSIZE MEMBERS ARC
---------- ---------- ----------
---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE#
NEXT_TIME
---------------- -------------
--------- ------------ ---------
1 1 1
52428800 512 1 NO
INACTIVE 945184 23-JAN-17 949175 23-JAN-17
2 1
2 52428800 512 1 NO
INACTIVE 949175 23-JAN-17 959074 23-JAN-17
3 1 3
52428800 512 1 NO
CURRENT 959074 23-JAN-17 2.8147E+14
4 1
0 10485760 512 2 YES
UNUSED 0 0
5 1 0
10485760 512 2 YES
UNUSED 0 0
6 1 0
10485760 512 2 YES
UNUSED 0 0
6 rows selected.
SQL> alter database drop logfile group 1;
Database altered.
SQL> alter database drop logfile group 2;
Database altered.
SQL> select * from v$log;
GROUP#
THREAD# SEQUENCE# BYTES
BLOCKSIZE MEMBERS ARC
---------- ---------- ----------
---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE#
NEXT_TIME
---------------- -------------
--------- ------------ ---------
3 1 3
52428800 512 1 NO
CURRENT 959074 23-JAN-17 2.8147E+14
4 1 0
10485760 512 2 YES
UNUSED 0 0
5 1 0
10485760 512 2 YES
UNUSED 0 0
GROUP#
THREAD# SEQUENCE# BYTES
BLOCKSIZE MEMBERS ARC
---------- ---------- ----------
---------- ---------- ---------- ---
STATUS FIRST_CHANGE# FIRST_TIM NEXT_CHANGE#
NEXT_TIME
---------------- -------------
--------- ------------ ---------
6 1 0
10485760 512 2 YES
UNUSED 0 0
SQL> alter system switch logfile;
System altered.
SQL> alter database drop logfile group 3;
alter database drop logfile group
3
*
ERROR at line 1:
ORA-01624: log 3 needed for crash
recovery of instance db11g (thread 1)
ORA-00312: online log 3 thread 1:
'/u01/app/oracle/oradata/db11g/redo03.log'
SQL> alter system switch logfile;
System altered.
SQL> alter database drop logfile group 3;
alter database drop logfile group
3
*
ERROR at line 1:
ORA-01624: log 3 needed for crash
recovery of instance db11g (thread 1)
ORA-00312: online log 3 thread 1:
'/u01/app/oracle/oradata/db11g/redo03.log'
SQL>
SQL>
select * from v$log;
GROUP#
THREAD# SEQUENCE# BYTES
BLOCKSIZE MEMBERS ARC
STATUS FIRST_CHANGE#
---------- ---------- ----------
---------- ---------- ---------- --- ---------------- -------------
FIRST_TIM NEXT_CHANGE# NEXT_TIME
--------- ------------ ---------
3 1 3
52428800 512 1 NO
ACTIVE 959074
23-JAN-17 968057 23-JAN-17
4 1 4
10485760 512 2 NO
ACTIVE 968057
23-JAN-17 968062 23-JAN-17
5 1 5
10485760 512 2 NO
ACTIVE 968062
23-JAN-17 968093 23-JAN-17
6 1 6
10485760 512 2 NO
CURRENT 968093
23-JAN-17 2.8147E+14
SQL> alter system checkpoint;
System altered.
SQL> select * from v$log;
GROUP#
THREAD# SEQUENCE# BYTES
BLOCKSIZE MEMBERS ARC
STATUS FIRST_CHANGE#
---------- ---------- ----------
---------- ---------- ---------- --- ---------------- -------------
FIRST_TIM NEXT_CHANGE# NEXT_TIME
--------- ------------ ---------
3 1 7
52428800 512 1 NO
INACTIVE 969077
23-JAN-17 969107 23-JAN-17
4 1 8
10485760 512 2 NO
CURRENT 969107
23-JAN-17 2.8147E+14
5 1 5
10485760 512 2 NO
INACTIVE 968062
23-JAN-17 968093 23-JAN-17
6 1 6
10485760 512 2 NO
INACTIVE 968093
23-JAN-17 969077 23-JAN-17
SQL> alter database drop logfile group 3;
Database altered.
SQL> select member from v$logfile;
MEMBER
----------------------------------------------------------------------------------------------------
+DATA/db11g/onlinelog/group_4.275.934049553
+FRA/db11g/onlinelog/group_4.259.934049553
+DATA/db11g/onlinelog/group_5.276.934049589
+FRA/db11g/onlinelog/group_5.260.934049589
+DATA/db11g/onlinelog/group_6.277.934049591
+FRA/db11g/onlinelog/group_6.261.934049591
6 rows selected.
Now, the DB is migrated to ASM. Other things like FRA, archivelogs can
be moved to ASM also by setting the respective parameters for these features.