DATABASE CLONING


cloning a database:
-------------------
--> you can colne databases in 3 ways
    -- using RMAN
    -- using database control
    -- manual cloning a database

manually cloning a database :
----------------------------

1) copy the prod database files to the target location

2) prepare a text file for the creation of a control file for the new database
    sql> alter database backup controlfile to trace;

3) on the target location creates all the directories for the various files

4) copy the four sets of files from the production(source) database to the target database: parameter file,controlfiles,datafiles and redolog files

5) in all the clone datafile,change the name to test

6) rum the create database command statement,which was prepared with alter database backup controlfile to trace statement.

7) create the controlfile for the test database using the following

    sql> create controlfile reuse set database "test" resetlogs noarchivelog;

8) once you get the prompt back from the previous command, run this statement
    sql> aalter database open resetlogs using backup controlfile;

9) finally, change the global name of the database you just created by running the following command
    sql>update global_name set global_name='test.world';

Manual Cloning Of Database


step 1.

          first take complete backup of database.


step 2.

             go into SQL*Plus, sign on as SYSDBA and issue: “alter database backup      
controlfile to trace”, for create control file script.--

SQL> alter database backup controlfile to trace;

#edit the controlfile and change the database name and locations othe datafiles and logfiles and save as ctl.sql

Old:

    CREATE CONTROLFILE REUSE DATABASE "DB1" NORESETLOGS

New:

    CREATE CONTROLFILE SET DATABASE "CDB1" RESETLOGS


-- Re-names of the data files & log files names that have changed, & Save as crctl.sql.

Old:

    DATAFILE
     '/u02/oradata/db1/system01.dbf',
   '/u02/oradata/db1/undotbs01.dbf',
   '/u02/oradata/db1/sysaux01.dbf',
   '/u02/oradata/db1/example01.dbf',
   '/u02/oradata/db1/users01.dbf'

New:

    DATAFILE
     '/u02/clonedb/oradata/cdb1/system01.dbf',
   '/u02/clonedb/oradata/cdb1/undotbs01.dbf',
   '/u02/clonedb/oradata/cdb1/sysaux01.dbf',
   '/u02/clonedb/oradata/cdb1/example01.dbf',
   '/u02/clonedb/oradata/cdb1/users01.dbf'

Old:

    LOGFILE
     GROUP 1 '/u02/oradata/db1/redo01.log'  SIZE 50M,
   GROUP 2 '/u02/oradata/db1/redo02.log'  SIZE 50M,
   GROUP 3 '/u02/oradata/db1/redo03.log'  SIZE 50M

New:

    LOGFILE
     GROUP 1 '/u02/clonedb/oradata/cdb1/redo01.log'  SIZE 50M,
   GROUP 2 '/u02/clonedb/oradata/cdb1/redo02.log'  SIZE 50M,
   GROUP 3 '/u02/clonedb/oradata/cdb1/redo03.log'  SIZE 50M

-- It will look something like this:--

--------------------------------------------------------------------------------------
STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "CDB1" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u02/clonedb/oradata/cdb1/redo01.log'  SIZE 50M,
  GROUP 2 '/u02/clonedb/oradata/cdb1/redo02.log'  SIZE 50M,
  GROUP 3 '/u02/clonedb/oradata/cdb1/redo03.log'  SIZE 50M
-- STANDBY LOGFILE
DATAFILE
  '/u02/clonedb/oradata/cdb1/system01.dbf',
  '/u02/clonedb/oradata/cdb1/undotbs01.dbf',
  '/u02/clonedb/oradata/cdb1/sysaux01.dbf',
  '/u02/clonedb/oradata/cdb1/example01.dbf',
  '/u02/clonedb/oradata/cdb1/users01.dbf'
CHARACTER SET AL32UTF8
;

--------------------------------------------------------------------------------------

SQL> create pfile='/u02/clonedb/backup/cdb1init.ora' from spfile;

File created.

SQL> shut immediate


step 3.

copy all datafiles and logfiles to new location.


step 4.

set ORACLE_SID

[oracle@shadab-pc ]$ export ORACLE_SID=cdb1

step 5.

create password file for clone database

[oracle@shadab-pc ]$ orapwd file=$ORACLE_HOME/dbs/orapwclone password=ab entries=10;

step 6.

create spfile and start database in nomount, then run controlfile script (crctl.sql).

[oracle@shadab-pc ]$ sqlplus "/ as sysdba"

SQL*Plus: Release 10.2.0.1.0 - Production on Tue Dec 14 00:39:02 2010

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

Connected to an idle instance.

SQL> create spfile from pfile='/u02/clonedb/backup/cdb1init.ora';

File created.

SQL> startup nomount
ORACLE instance started.

Total System Global Area  209715200 bytes
Fixed Size                  1218532 bytes
Variable Size              67110940 bytes
Database Buffers          134217728 bytes
Redo Buffers                7168000 bytes
SQL> 

SQL> @crctl.sql

step 7.

after controlfile create open db with resetlogs

SQL> alter database open resetlogs.

step 8.

 create temporary tablespace.

SQL> create temporary tablespace temp tempfile '/home/oracle/clone/temp02.dbf' size 50m;

ALTER DATABASE DEFAULT TEMPORARY TABLESPACE temp;

step 10.
create connection string for cdb1, because manual database clone not creating connection string.

[oracle@shadab-pc ~]$ netmgr






No comments:

Post a Comment