APM Welcome, APM North West Network Conference, Synergies Across Sectors
Moving 12c database from non-asm to asm storage
1. +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
Moving 12c database from non-asm storage to asm storage
++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++
1. Check the current files (data, control, logs and temp)
================================================
RMAN> connect target
connected to target database: TESTP (DBID=1042086153)
RMAN> select name from v$datafile;
using target database control file instead of recovery catalog
NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/TESTP/system01.dbf
/u01/app/oracle/oradata/TESTP/example01.dbf
/u01/app/oracle/oradata/TESTP/sysaux01.dbf
/u01/app/oracle/oradata/TESTP/undotbs01.dbf
/u01/app/oracle/oradata/TESTP/users01.dbf
RMAN> select member from v$logfile;
MEMBER
-------------------------------------------------------------------------------/u01/app/oracle/oradata/TESTP/redo03.log
/u01/app/oracle/oradata/TESTP/redo02.log
/u01/app/oracle/oradata/TESTP/redo01.log
RMAN> select name from v$controlfile;
NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/TESTP/control01.ctl
/u01/app/oracle/oradata/TESTP/control02.ctl
RMAN> select name from v$tempfile;
NAME
-------------------------------------------------------------------------------/u01/app/oracle/oradata/TESTP/temp01.dbf
RMAN> show parameter pfile
RMAN-00571: ===========================================================
RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-00558: error encountered while parsing input commands
RMAN-01009: syntax error: found "parameter": expecting one of: "all, archivelog, auxiliary, auxname, backup,
channel, compression, controlfile, datafile, db_unique_name, default, device, encryption, exclude, maxsetsize,
retention, snapshot, "
RMAN-01007: at line 1 column 6 file: standard input
2. RMAN> select value from v$parameter where name='spfile';
VALUE
-------------------------------------------------------------------------------/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfileTESTP.ora
2. Create the required directories for ASM database
===========================================
From Other Session,
ASMCMD> pwd
+DATA/TESTP
ASMCMD> mkdir DATAFILE CONROLFILE TEMPFILE PARAMETERFILE ONLINELOG
ASMCMD> ls -l
Type Redund Striped Time
Sys Name
N CONROLFILE/
N DATAFILE/
N ONLINELOG/
N PARAMETERFILE/
N TEMPFILE/
3. Configure FRA
================
RMAN> select value from v$parameter where name='spfile';
VALUE
-------------------------------------------------------------------------------/u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfileTESTP.ora
RMAN> create pfile from spfile;
Statement processed
RMAN> alter system set db_recovery_file_dest_size = 1G;
Statement processed
RMAN> alter system set db_recovery_file_dest = '+FRA';
Statement processed
RMAN> alter system set control_files='+DATA/control01.ctl' scope=spfile;
Statement processed
4. Moving files (data and control) from NON ASM to ASM storage.
=========================================================
RMAN> shutdown immediate;
Oracle instance shut down
RMAN> startup nomount;
connected to target database (not started)
Oracle instance started
Total System Global Area
Fixed Size
Variable Size
Database Buffers
Redo Buffers
551165952 bytes
2290608 bytes
289410128 bytes
255852544 bytes
3612672 bytes
4. piece handle=+DATA/TESTP/BACKUPSET/2013_11_10/nnsnf0_tag20131110t130802_0.268.831129093
tag=TAG20131110T130802 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-NOV-13
RMAN> switch database to copy;
datafile 1 switched to datafile copy "+DATA/TESTP/DATAFILE/system.272.831128883"
datafile 2 switched to datafile copy "+DATA/TESTP/DATAFILE/example.275.831129033"
datafile 3 switched to datafile copy "+DATA/TESTP/DATAFILE/sysaux.273.831128959"
datafile 4 switched to datafile copy "+DATA/TESTP/DATAFILE/undotbs1.276.831129069"
datafile 6 switched to datafile copy "+DATA/TESTP/DATAFILE/users.267.831129091"
Open the database
----------------------RMAN> alter database open;
Statement processed
RMAN> select name from v$datafile;
NAME
-------------------------------------------------------------------------------+DATA/TESTP/DATAFILE/system.272.831128883
+DATA/TESTP/DATAFILE/example.275.831129033
+DATA/TESTP/DATAFILE/sysaux.273.831128959
+DATA/TESTP/DATAFILE/undotbs1.276.831129069
+DATA/TESTP/DATAFILE/users.267.831129091
RMAN> select name from v$controlfile;
NAME
-------------------------------------------------------------------------------+DATA/control01.ctl
5. MOVE redologs to ASM storage
===========================
RMAN> select member,group# from v$logfile;
MEMBER
GROUP#
--------------------------------------------------------------------------------------/u01/app/oracle/oradata/TESTP/redo03.log
3
/u01/app/oracle/oradata/TESTP/redo02.log
2
/u01/app/oracle/oradata/TESTP/redo01.log
1
RMAN> alter database add logfile group 4 size 50M;
Statement processed
RMAN> alter database add logfile group 5 size 50M;
Statement processed
RMAN> alter database add logfile group 6 size 50M;
Statement processed
RMAN> alter database drop logfile group 1;
RMAN-00571: ===========================================================
5. RMAN-00569: =============== ERROR MESSAGE STACK FOLLOWS ===============
RMAN-00571: ===========================================================
RMAN-03002: failure of sql statement command at 11/10/2013 13:18:40
ORA-01623: log 1 is current log for instance TESTP (thread 1) - cannot drop
ORA-00312: online log 1 thread 1: '/u01/app/oracle/oradata/TESTP/redo01.log'
RMAN> alter database drop logfile group 2;
Statement processed
RMAN> alter database drop logfile group 3;
Statement processed
RMAN> alter system checkpoint;
Statement processed
RMAN> alter system switch logfile;
Statement processed
RMAN> alter database drop logfile group 1;
Statement processed
RMAN> select member from v$logfile;
MEMBER
-------------------------------------------------------------------------------+DATA/TESTP/ONLINELOG/group_4.274.831129459
+FRA/TESTP/ONLINELOG/group_4.290.831129463
+DATA/TESTP/ONLINELOG/group_5.277.831129483
+FRA/TESTP/ONLINELOG/group_5.292.831129487
+DATA/TESTP/ONLINELOG/group_6.271.831129501
+FRA/TESTP/ONLINELOG/group_6.291.831129505
6. Migrate temp tablespace to ASM storage
===============================
RMAN> select tablespace_name, file_name from dba_temp_files;
TABLESPACE_NAME
FILE_NAME
-------------------------------------------------------------------------------TEMP
/u01/app/oracle/oradata/TESTP/temp01.dbf
RMAN> alter tablespace TEMP add tempfile '+DATA/TESTP/temp_01.dbf' size 50m;
Statement processed
RMAN> alter database tempfile '/u01/app/oracle/oradata/TESTP/temp01.dbf' drop;
Statement processed
RMAN> select name from v$tempfile;
NAME
-------------------------------------------------------------------------------+DATA/TESTP/temp_01.dbf
7. Migrate SPFILE to ASM storage
==============================
RMAN> select value from v$parameter where name='spfile';
VALUE
--------------------------------------------------------------------------------
6. /u01/app/oracle/product/12.1.0/dbhome_1/dbs/spfileTESTP.ora
RMAN> create pfile from spfile;
Statement processed
RMAN> create spfile='+DATA/TESTP/spfile' from
pfile='/u01/app/oracle/product/12.1.0/dbhome_1/dbs/initTESTP.ora';
Statement processed
RMAN> run {
BACKUP AS BACKUPSET SPFILE;
RESTORE SPFILE TO "+DATA/TESTP/spfile";
}
2> 3> 4>
Starting backup at 10-NOV-13
allocated channel: ORA_DISK_1
channel ORA_DISK_1: SID=51 device type=DISK
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 10-NOV-13
channel ORA_DISK_1: finished piece 1 at 10-NOV-13
piece handle=+FRA/TESTP/BACKUPSET/2013_11_10/nnsnf0_tag20131110t135115_0.309.831131477
tag=TAG20131110T135115 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 10-NOV-13
Starting restore at 10-NOV-13
using channel ORA_DISK_1
channel ORA_DISK_1: starting datafile backup set restore
channel ORA_DISK_1: restoring SPFILE
output file name=+DATA/TESTP/spfile
channel ORA_DISK_1: reading from backup piece
+FRA/TESTP/BACKUPSET/2013_11_10/nnsnf0_tag20131110t135115_0.309.831131477
channel ORA_DISK_1: piece
handle=+FRA/TESTP/BACKUPSET/2013_11_10/nnsnf0_tag20131110t135115_0.309.831131477
tag=TAG20131110T135115
channel ORA_DISK_1: restored backup piece 1
channel ORA_DISK_1: restore complete, elapsed time: 00:00:03
Finished restore at 10-NOV-13
RMAN> startup
connected to target database (not started)
Oracle instance started
database mounted
database opened
Total System Global Area
Fixed Size
Variable Size
Database Buffers
551165952 bytes
2290608 bytes
297798736 bytes
247463936 bytes
7. Redo Buffers
3612672 bytes
RMAN> select value from v$parameter where name='spfile';
VALUE
-------------------------------------------------------------------------------+DATA/TESTP/spfile
So all the database files and paramer file is now on ASM storage.