Tuesday 20 March 2007

Going to ASM...

Converting non-ASM databases to ASM is quite easy...if you know what to do ;).

Actually I had to convert a non-ASM standby database to a two instance RAC ASM-database as part of a catastropical test. Why doing it this way, is really a good question. I will just say I'm trying to convince my customer to use Dataguard as the product is intended. No luck yet ;).

Here we go...

The tool you really need to know is RMAN! You don't get anywhere without RMAN working with ASM. This is not entirely true, but that's another story.

So basically you have a backup set of your non-ASM database. The files are typically stored on "/u02/oradata/SID/..." and so on... You ned RMAN to restore these files to ASM instead of "/u02/oradata/SID/...". To do this I use something called "set newname". The syntax is:

set newname for datafile 1 to '+DATA'

The reference "+DATA" is your diskgroup in ASM.

So, at some point you need to know how many datafiles you have, and probably how many tempfiles you have. You will typically have to write a little script like this:

connect / as sysdba
whenever sqlerror exit sql.sqlcode
set space 0
set pages 0
set heading off
set echo off
set trimspool on
set verify off
set feedback off
spool rman_newname_restore.rcv
select 'configure DEVICE TYPE DISK parallelism 4;' from dual;
select 'run' from dual;
select '{' from dual;
select 'set newname for datafile ' file# ' to ''' name '.dbf'';' from
v$datafile;
select 'restore database;' from dual;
select '}' from dual;
spool off;


Then you use the rman_newname_restore.rcv for the restore script. Rman will then restore your files to the new location set by newname.

There might be better solutions than mine, so I'm looking forward to reading your replays.

No comments: