Friday, 25 December 2015

Cloning by using cold backups:

Cloning by using cold backups:

ProdDB - amer
CloneDB - amercln

ProdDB Side (amer) :

1. Find datafiles/logfile and pfile locations by issuing the following queries.

select name from v$datafile;
select member from v$logfile;
sho parameter spfile;

2. Shut immediate the prod db and copy these datafiles/logfile and pfile to the other backup location.

Note: If you are using the spfile create the pfile from spfile and copy it to backup location.

3. startup the prod db.

4. Take backup of control file to the backup location by issuing the following command.

SQL> alter database backup controlfile to trace as '/u02/backup/control.ctl';

5. SCP the backup files to target database (amercln) backup location.

scp initamer.ora oracle@192.168.141.11:/u02/amercln/

6. Create password file for the prod db.

orapwd file=/u01/app/oracle/product/11.2.0/db_1/dbs/orapwAMERCLN password=oracle entries=10

CloneDB Side (amercln):

1. Create required directories in corresponding path and placed the backup files in corresponding directories.

Such as : adump,bdump,cdump,udump,oradata,...

2. Change the initamer.ora name to initamercln.ora

$mv initamer.ora initamercln.ora

3. Change the initamercln.ora parameters such as db_name, contolfile path, instance name, audit file location path, ... so on.

[oracle@euro dbs]$ more initAMERCLN.ora 
amercln.__db_cache_size=276824064
amercln.__java_pool_size=4194304
amercln.__large_pool_size=4194304
amercln.__oracle_base='/u02/app/oracle'#ORACLE_BASE set from environment
amercln.__pga_aggregate_target=314572800
amercln.__sga_target=528482304
amercln.__shared_io_pool_size=0
amercln.__shared_pool_size=234881024
amercln.__streams_pool_size=0
*.audit_file_dest='/u02/app/oracle/admin/amercln/adump'
*.audit_trail='db'
*.compatible='11.2.0.0.0'
*.control_files='/u02/app/oracle/oradata/amercln/control01.ctl','/u02/app/oracle/oradata/amercln/control02.ctl'
*.db_block_size=8192
*.db_domain=''
*.db_name='AMERCLN'
*.db_writer_processes=2
*.diagnostic_dest='/u02/app/oracle'
*.dispatchers='(PROTOCOL=TCP) (SERVICE=amerclnXDB)'
*.log_archive_dest='/u02/BackupArea/arch/'
*.log_archive_format='%t_amercln_%s_%r.ARC'
*.memory_target=843055104
*.open_cursors=300
*.processes=150
*.remote_login_passwordfile='EXCLUSIVE'
*.sec_case_sensitive_logon=FALSE
*.undo_tablespace='UNDOTBS1'
[oracle@euro dbs]$ 


4. create password file.

$orapwd file=$ORACLE_HOME/dbs/orapwdamercln password=oracle

Note: Source DB password and clone db password must be same.

5. Change control.sql file as per requirement.

Such as redolog file paths, datafile paths, ...

Change the below highlighted words from REUSE to SET and NORESETLOGS to RESETLOGS. 

FROM: CREATE CONTROLFILE REUSE DATABASE “olddbname” RESETLOGS …
TO: CREATE CONTROLFILE set DATABASE “newdbname” RESETLOGS …

$vi control.sql

STARTUP NOMOUNT
CREATE CONTROLFILE SET DATABASE "AMERCLN" RESETLOGS  ARCHIVELOG
    MAXLOGFILES 16
    MAXLOGMEMBERS 3
    MAXDATAFILES 100
    MAXINSTANCES 8
    MAXLOGHISTORY 292
LOGFILE
  GROUP 1 '/u02/app/oracle/oradata/amercln/redo01.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 2 '/u02/app/oracle/oradata/amercln/redo02.log'  SIZE 50M BLOCKSIZE 512,
  GROUP 3 '/u02/app/oracle/oradata/amercln/redo03.log'  SIZE 50M BLOCKSIZE 512
-- STANDBY LOGFILE
DATAFILE
  '/u02/app/oracle/oradata/amercln/system01.dbf',
  '/u02/app/oracle/oradata/amercln/sysaux01.dbf',
  '/u02/app/oracle/oradata/amercln/undotbs01.dbf',
  '/u02/app/oracle/oradata/amercln/users01.dbf',
  '/u02/app/oracle/oradata/amercln/example01.dbf'
CHARACTER SET WE8MSWIN1252
;
[oracle@euro amercln]$ 

6. open the database amercln with STARTUP NOMOUNT to execute the control.sql file.

$export ORACLE_SID=amercln

$sqlplus "/as sysdba"

SQL> startup nomount pfile=''


SQL>@/u02/amercln/control.sql

control file created.

7. Open the database with resetlog files.

SQL>alter database open resetlogs;

8. Check the database and instance statues (READ WRITE), logfiles, datafiles and controlfiles.

Some work notes:

* TO check CP command progress:

    stat -c "%s" /bin/ls

* To replace the words in vi editor

   :%s/Findword/Replaceword/g

* MEMORY_TARGET Issue:

   #df-k


   #mount -t tmpfs shmfs -o size=10g /dev/shm

All the best...!!!



No comments:

Post a Comment