5.28.2006

clone and Oracle 9i DB

Clone an Oracle 9i database:

In source DB:

  • ALTER DATABASE BACKUP CONTROLFILE TO TRACE AS '/b1/mytracefile.trc';

  • shutdown immediate


  • Copy data files and redo logs to clone location. aka:

    • for id in 01 02 03 04 05 06 07 08 09 10 11 12

    • do

    • mkdir -p /u${id}/mydb1 ; chown -R oracle:oinstall /u${id}/mydb1 ; cp -p -r /u${id}/prevea2/* /u${id}/mydb1

    • done

  • Copy source db's init{SID}.ora file to init{newSID}.ora ( usually in $ORACLE_HOME/dbs )


In trace file created earlier:

  • Remove second half of file (starts at the section: "Set #2. RESETLOGS case")

  • Remove all comment lines (they begin with #)

  • Remove blank space between -- STANDBY LOGFILE and DATAFILE

  • At top insert: connect / as sysdba

  • Change line: startup nomount to: startup nomount pfile={location of new cloned init file}

  • Change ALL file references from source db location to new clone location.


In the init{newSID}.ora:

  • Change ALL file references from source db location to new clone location.


  • export ORACLE_SID={newSID}

  • Create a new password file: orapwd file=$ORACLE_HOME/dbs/orapw{SID} password=sys entries=1

  • sqlplus /nolog

    • sql> @/b1/mytracefile.trc

    • You'll see 2 message, these are OK to ignore:

      • ORA-00283: recovery session canceled due to errors

      • ORA-00264: no recovery required

    • Test the database: select count(1) from v$database;

    • alter database backup controlfile to trace as '/b1/newtracefile.trc';

    • shutdown immediate


  • Delete all control files in the clone location: *.ctl example:

    • confirm with - find /u[0-9][0-9]/{clonelocation} -name "*.ctl"

    • then delete - find /u[0-9][0-9]/{clonelocation} -name "*.ctl" -exec rm {} \;


In the newly created trace file:

  • Remove second half of file (starts at the section: "Set #2. RESETLOGS case")

  • Remove all comment lines (they begin with #)

  • Remove blank space between -- STANDBY LOGFILE and DATAFILE

  • At top insert: connect / as sysdba

  • Change line: startup nomount to: startup nomount pfile={location of new cloned init file}

  • Change line: create controlfile to: create controlfile set database "{newDBname}" resetlogs noarchivelog

  • Change line: alter datbase open; to: alter database open resetlogs;


In the init{newSID}.ora :

  • change the db_name, instance_name, service_names, dispatchers parameter to the new DB name.

  • sqlplus /nolog

    • sql> @/b1/newtracefile.trc

  • confirm updated dbname: select * from v$database;



for name in arch audit bdump cdump create pfile udump

do

mkdir -p /u02/srcdb1/${name}

done


for id in 01 02 03 04 05 06 07 08 09 10 11 12

do

mkdir -p /u${id}/srcdb1 ; chown -R oracle:dba /u${id} ; chmod -R 775 /u${id}

done

No comments: