Thursday, July 27, 2006

rman and controlfile moves

Till now i've been basically trying to just collect useful stuff from the web . This installment should be a bit different and based on my own experiences of working with rman.
I was recently tasked with migrating an approx 2 tb database including controlfiles and redo logs to filesystems. the database files and redo logs was the easy part thanks to rman , when it came down to controlfiles . it became tricky. rman require the instance to be mounted to copy the control. dd was not getting me the right bytes regardless of me setting the right offsets and all that.
so my only option was to do a copy controlfile and and then do a mock recovery using backup controlfile.
Well just thinking of fdoing a backup controlfile ins a working production environment gave me the jitters .
That is until i discovered the replicate command in rman. replicate allows you to replicate controlfile from a controlfile to multiple files listed in the init.ora or spfile

so my controlfile move went like this
2> allocate channel ch1 type disk
;3> copy current controlfile to '/tmp/control01.ctl'
;4> }
using target database controlfile instead of recovery catalog
allocated channel: ch1channel ch1:
sid=641 devtype=DISK
Starting copy at 27-JUL-06channel ch1:
copied current controlfile
output filename=/tmp/control01.ctl
Finished copy at 27-JUL-06
released channel: ch1

The above is optional but i found it a little on the careful side
add the controlfile to you spfile
alter system set control_files='/tmp/control01.ctl' scope=spfile ;
or change it in the init.ora
do a shutdown of the database and bring it back up in nomount state
replicate will not work unless a database is in nomount state

{2> allocate channel ch1 type disk;
3> replicate controlfile from '/dev/cntl01'
;4> }
using target database controlfile instead of recovery catalog
allocated channel: ch1channel ch1: sid=12 devtype=DISK
replicating controlfileinput filename=/dev/cntl01
output filename=/tmp/control01.ctl
released channel: ch1
then do an alter open.
one thing you might have the noticed . the controlfile that i used to replicate from was not listed in the spfile since i had already changed it to new controlfile.
then i just execute the
SQL> alter database mount
Database altered.
SQL> alter database open;
Database altered.

This concludes the converting raw to filesystem for controlfiles.
In filesystems obviously moving controlfiles is just a plain cp command with the instance shutdown.Please leave me a note if you think there could have been a better way to do this

Google Search