Monday, January 25, 2010

Old fashion database cloning with RMAN.



I used to do this a few times a day in 2005-2008. Oracle 10.1 was glorious back then. Somedays, I lost track of what incremental number I need to use for my next target database.


In this example, dupr7710 is the auxiliary and qa7710 is the target.

Pre-RMAN requirements


1) a backup of the source database AKA target


RMAN> list backup;

2) set the tnsnames.ora


3) set the oratab


4) create all necessary directories in /oracle/product/admin/dbname/


5) create orapwd


e.g:
orapwd file=/oracle/product/9.2.0.1/dbs/orapwDUP password=password entries=10

6) target in mount mode


7) auxiliary in nomount mode


** beware of compatibility of oracle version

Making the connections

. oraenv
<to auxiliary>

/stage/conversion/Install_10:(dupr7710)$

rman
Recovery Manager: Release 10.1.0.5.0 - Production
Copyright (c) 1995, 2004, Oracle. All rights reserved.
RMAN> connect auxiliary /
connected to auxiliary database: dupr7710 (not mounted)
RMAN> connect target sys@qa7710
target database Password:
connected to target database: QA7710 (DBID=3895033173)

Performing the duplication using pfile


RMAN>
run {
allocate channel ch1 type disk;
allocate auxiliary channel ch3 type disk;
duplicate target database to dupr7710 pfile=/oracle/product/admin/dupr7710/pfile/initdupr7710.ora;

}

Playing with my thumbs and move on to other database cloning ....

Friday, January 1, 2010

Oracle: Recovering missing datafile from RMAN

Old note of mine from 2005 on how to recover and missing datafile. The RMAN backup was good, so I was able to recover it.

ORA-01110: data file 30: '/ora0/tech/tech_d1.dbf'
ORA-02063: preceding 2 lines from tech
ORA-00376: file 30 cannot be read at this time
ORA-01110: data file 30: '/ora0/tech/tech_d1.dbf'
ORA-02063: preceding 2 lines from tech

SQL> alter database recover datafile '/ora0/tech/tech1.dbf';
Database altered.
SQL> alter database datafile '/ora0/tech/tech1.dbf' online;
Database altered.

SQL> select * from v$datafile where name like '%tech_d1%';

FILE# STATUS ENABLED CHECKPOINT_CHANGE# BYTES CREATE_BYTES NAME
---------- ------- ---------- ------------------ ---------- ------------ ---------------------------
30 ONLINE READ WRITE 58379635 104857600 104857600 /ora0/tech/encounter_d1.dbf