Wednesday, 3 July 2013

user managed database cloning in oracle

   Some time our need is to create clone database of current database for developing purpose.
simple meaning of clone database is to create same database on same server or different server
with same name or different name.so my this blog post describe you how to create user managed  database cloning in oracle ?

example:-
          ip address:  192.168.128.135 (target database ip address)
                    :  192.168.128.136 (source database ip address)

        
         database name: db11g

[oracle@oracle@example]$ export ORACLE_SID=db11g

[oracle@oracle@example]$ echo $ORACLE_SID

db11g

[oracle@oracle@example]$ sqlplus


SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 10:06:56 2013

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

Enter user-name: /as sysdba
Connected to an idle instance.

SQL>  alter database backup controlfile to trace as '/u01/archivelog/control.sql';   (take backup of controlfile to trace using this command)

Database altered.

SQL>shut immediate;
Database closed.
Database dismounted.
ORACLE instance shut down.

(make directory structure on source database server same as target database server)

:- On source database (192.168.128.136)

[oracle@oracle@example]$mkdir -p  /u01/app/oracle/oradata/dupli

[oracle@oracle@example]$mkdir -p  /u01/app/oracle/admin/dupli

[oracle@oracle@example]$cd /u01/app/oracle/admin/dupli

[oracle@oracle@example dupli]$ mkdir -p adump dpdump pfile

(transfer data from target database to source database example all datafile,redolog file,trace file(not cotrolfile). also modify trace file as below. use SET and RESETLOGS parameter )

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

--
  (save the file)

[oracle@oracle@example pfile]$ orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwdupli force=y

Enter password for SYS:
[oracle@oracle@example pfile]$ echo $ORACLE_HOME
/u01/app/oracle/product/11.2.0/db_1


[oracle@oracle@example pfile]$ export ORACLE_SID=db11g

[oracle@oracle@example pfile]$ echo $ORACLE_SID
db11g

[oracle@oracle@example pfile]$sqlplus


SQL*Plus: Release 11.2.0.1.0 Production on Thu Jul 4 10:06:56 2013

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

Enter user-name: /as sysdba
Connected to an idle instance.

SQL> startup nomount pfile='/u01/app/oracle/admin/dupli/pfile/init.ora.6420139223';
ORACLE instance started.

Total System Global Area  422670336 bytes
Fixed Size                  1336960 bytes
Variable Size             260049280 bytes
Database Buffers          155189248 bytes
Redo Buffers                6094848 bytes

SQL>  @'/u01/archivelog/control.sql';   (run  modify tracefile)


Control file created.

SQL> alter database open resetlogs;

Database altered.

SQL> select name,OPEN_MODE from v$database;

NAME      OPEN_MODE
--------- --------------------
DB11G     READ WRITE

SQL>


                                     ********END*********















1 comment:

work on autovacuum postgreSQL parameter

 In This blog, we are discussing the auto vacuum parameter on a small scale. we will understand the below parameters and will see how to mod...