Pages

Thursday, 1 August 2013

Cold backup Cloning



Clone orcl database as catalog using clod backup

Copy init.ora file

cp initorcl.ora initcatalog.ora

[oracle@localhost dbs]$ vi initcatalog.ora

change orcl as catalog

db_name=catalog
change paths of control_files and dump dests parameters etc

Take backup of orcl database controlfile into readable format.SO that we can edit

[oracle@localhost dbs]$export ORACLE_SID=ORCL
[oracle@localhost dbs]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 29 10:19:22 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2217952 bytes
Variable Size             507512864 bytes
Database Buffers          322961408 bytes
Redo Buffers                2412544 bytes
Database mounted.
Database opened.
SQL> alter database backup controlfile to trace as '/disk1/admin/control.sql';

Database altered.

SQL> exit

Take backup of orcl database.

Edit controlfile trace to create new controlfile

[oracle@localhost dbs]$ cd /disk1/admin/
[oracle@localhost admin]$ ls
control.sql  ORCL

remove the unnecessary lines

change the below in control.sql file

CREATE CONTROLFILE RESUE DATABASE
RESUE-->SET

CREATE CONTROLFILE SET DATABASE "ORCL"
ORCL-->"CATALOG"

Replace the oradata location of orcl with catalog database locations
Replace the directories of orcl as catalog

/disk1/oradata/orcl -->/disk1/oradata/catalog


[oracle@localhost admin]$ vi control.sql

CREATE CONTROLFILE SET DATABASE "CATALOG" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/disk1/oradata/catalog/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/disk1/oradata/catalog/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/disk1/oradata/catalog/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/disk1/oradata/catalog/system01.dbf',
  '/disk1/oradata/catalog/sysaux01.dbf',
  '/disk1/oradata/catalog/undotbs01.dbf',
  '/disk1/oradata/catalog/users01.dbf',
  '/disk1/oradata/catalog/example01.dbf'
CHARACTER SET WE8MSWIN1252
;


[oracle@localhost admin]$ cd /disk1

[oracle@localhost disk1]$ cd oradata

[oracle@localhost oradata]$ mkdir catalog
[oracle@localhost oradata]$ ls
catalog  orcl

copy backup of orcl into catalog oradata location

[oracle@localhost oradata]$ cd ..
[oracle@localhost disk1]$ cd coldbackup/
[oracle@localhost coldbackup]$ ls
control01.ctl  example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf
control02.ctl  redo01.log     redo03.log  system01.dbf  undotbs01.dbf
[oracle@localhost coldbackup]$ cp * ../oradata/catalog/

[oracle@localhost coldbackup]$ cd ../oradata/catalog/
[oracle@localhost catalog]$ ls
control01.ctl  example01.dbf  redo02.log  sysaux01.dbf  temp01.dbf     users01.dbf
control02.ctl  redo01.log     redo03.log  system01.dbf  undotbs01.dbf

Remove old controlfiles

[oracle@localhost catalog]$ rm -rf control01.ctl control02.ctl
[oracle@localhost catalog]$ ls
example01.dbf  redo01.log  redo02.log  redo03.log  sysaux01.dbf  system01.dbf  temp01.dbf  undotbs01.dbf  users01.dbf
[oracle@localhost catalog]$ cd /disk1/admin

connect to catalog database

[oracle@localhost admin]$ export ORACLE_SID=catalog
[oracle@localhost admin]$ ls
catalog  control.ctl  ORCL
[oracle@localhost admin]$ sqlplus / as sysdba

SQL*Plus: Release 11.2.0.1.0 Production on Wed Aug 29 10:25:24 2012

Copyright (c) 1982, 2009, Oracle.  All rights reserved.

Connected to an idle instance.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  835104768 bytes
Fixed Size                  2217952 bytes
Variable Size             171968544 bytes
Database Buffers          658505728 bytes
Redo Buffers                2412544 bytes

SQL> @control.sql

Control file created.

SQL> alter database open resetlogs;

Database altered.

SQL> exit
Disconnected from Oracle Database 11g Enterprise Edition Release 11.2.0.1.0 - 64bit Production
With the Partitioning, OLAP, Data Mining and Real Application Testing options

No comments:

Post a Comment