Download as txt, pdf, or txt
Download as txt, pdf, or txt
You are on page 1of 8

clonings:

cloning is nothing but creating the duplicate database using production


backup.

In realtime we have different database environments.

production environment
preproduction
PQA primary quality assurance
SQA secondary quality assurance
dev
test/stage/UAT user acceptance testing

production means where the live applications will connect and work.
production is very business critical environments.

preproduction means almost similar to production but criticality will


be less.

PQA primary quality assurance -- quality checking purpose.


SQA second quality assurance -- quality checking purpose

Dev -- development -- developers will connect and work.


developers they will first develop the code in development then they
will deploy in production.

Test -- testing purpose --suppose DBAs are applying any patching or


upgradations first they will deploy the patch in test environment if
it is successfully then they will deploy in production environment.

In few projects we have all environments.

production
preproduction
PQA
SQA
test
dev

In few projects we have below environments.

production
preproduction
test
dev

In few projects we have below environments.

production
test
dev

how many databases you are supporting in your project?

1000+ databases
200+ production
200+ preproduction
200+ test
200+ dev

500+ databases

100+ production
100+ preproduction
100+ test
100+ dev

200+ databases

50+ production
50+ preproduction
50+ test
50+ dev

we can create the preproduction,PQA,SQA,Test and dev environment using


cloning method only.

we can do the cloning in different ways.

1. cold cloning
2. hot cloning
3. rman cloning with duplicate
4. rman cloning with out duplicate
5. BCV cloning.

1. cold cloning:

if will clone the database using cold backup then it is called


cold cloning.

production:

shutdown the database gracefully


shutdown normal/immediate/transactional
cd /prod/abc/oradata
cp * /prod/abc/admin/cold/
startup
copy the cold backup to clone server using scp

clone server
install the same version os including patch level
install the same version of oracle software including patch level
create env file
create same/different directory structure
configure pfile
compatible
db_block_size
undo_management
log_archive_format
memory_target -- these parameters should be same as production

startup nomount
@recreate controlfile with resetlogs
alter database open resetlogs;

2. hot cloning:

will take the hot backup and will do the clone that is called hot cloning.

production

alter database begin backup;


cd /prod/abc/oradata/
cp *dbf /prod/abc/admin/hot/
alter database end backup;
alter system archive log current;
alter database backup controlfile to trace;
copy the hot backup and archives to clone server

clone server.

install the same version os including patch level


install the same version of oracle software including patch level
create env file
create same/different directory structure
configure pfile
compatible
db_block_size
undo_management
log_archive_format
memory_target -- these parameters should be same as production

startup nomount
@recreate controlfile with resetlogs
recover database using backup controlfile until cancel;
alter database open resetlogs;

3. rman cloning with duplicate command:

In rman we can do the cloning with duplicate in 2 ways.

1. backup based duplicate


2. active duplicate (11gr2 new feature)

1. backup based duplicate:

will take the rman backup in production and will do the clone that is
called backup based duplicate.

production:

1. take the rman backup and copy the backup to clone server

rman target=/
rman>backup database include current controlfile plus archivelogs;

2. configure the tnsentry

3. rman target=/ auxiliary=sys/sys@tnsabc1


rman>duplicate target database to abc1 nofilenamecheck;
clone server

install the same version of os including patch level


install the same version of oracle software including patch level
create env file
create same/different directory structure
configure pfile
compatible
db_block_size
undo_management
log_archive_format
memory_target -- these parameters should be same as production
db_file_name_convert=
log_file_name_convert= -- if directory structure is different

configure the listener


configure the password file
startup nomount
exit

password file:

purpose of password files is remote users to connect to the database


as sys user.

default location is $ORACLE_HOME/dbs

syntax: orapwd file=orapw$ORACLE_SID password= force= ignorecase=

cd $ORACLE_HOME/dbs
orapwd file=orapwabc1 password=sys force=y ignorecase=y

how to check password file is enabled or not?

select * from pwfile_users;

what will happen if will execute the duplicate command?

1. it will create the spfile and it will shutdown and start the instance
if DB is running with pfile.
2. it will change the dbname to production dbname and dbunique name to
clone name
3. it will restore the controlfile
4. it will go to mount state
5. it will restore the database
6. it will recover the database
7. it will change the dbname to clone dbname
8. it will open the database with open resetlogs

scenario1:

we can execute the duplicate command on production side.

production

configure the tnsentry

rman target=/ auxilary=sys/sys@tnsabc1


rman>duplciate target database to abc1 nofilenamecheck;

clone server:
configure the listener
configure the password file

scenario 2:
we can execute the duplicate command on clone side also.

production

configure the listener


configure the password file

clone side:

configure tnsentry

rman target=sys/sys@tnsabc auxiliary=/


rman>duplicate target database to abc1 nofilenamecheck;

2. active dupliction:

it is new feature introduced from oracle 11gr2 onwards.

active duplication means without taking the backup we can do the cloning
so directly it will read the production datafiles and it will do the
clone

limitations:
1. network should be fast between production and clone server for data
transfer.
2. we should enough cpu/memory/IO resources on production otherwise
production database performance may degrade.

production:

configure tnsentry
configure the password file
rman target=sys/sys auxiliary=sys/sys@tnsabc1

rman>duplicate target database to abc1 from active database;

clone server
configure the listener
configure the password

4. rman cloning without duplicate command:

production:

1. take the rman backup and copy the backup to the clone server
rman target=/
rman>backup database include current controlfile plus archivelog;

2. copy the backup to clone server using scp.


clone server:

install the same version of os including patch level


install the same version of oracle software including patch level
create env file
create same/directory structure
configure pfile
db_name
compatible
db_block_size
undo_management
log_archive_format
memory_Target -- these parameters should be same as production

startup nomount
rman> restore controlfile from '/prod/abc/admin/rman/piecename';
alter database mount
catalog backuppiece '/prod/abc1/admin/rman/piece1';
catalog backuppiece '/prod/abc1/admin/rman/piece2';
catalog backuppiece '/prod/abc1/admin/rman/piece3';(if backuplocation is
different we have to register the rman backuppieces in rman repository)

set newname for datafile 1 to '/prod/abc1/oradata/system01.dbf';


set newname for datafile 2 to '/prod/abc1/oradata/sysaux01.dbf';
set newname for datafile 3 to '/prod/abc1/oradata/undotbs01.dbf';
set newname for datafile 4 to '/prod/abc1/oradata/userdata01.dbf';
set newname for tempfile 1 to '/prod/abc1/oradata/temp01.dbf';
(if directory structure is different)

set until timestmap

restore database;
switch datafiles all; it will change the datafile location in controlfile
switch tempfile all; it will change the tempfile location in controlfile
recover database;
rename the redolog file member (if directory structure is different)

alter database open resetlogs

how to change the dbname and dbid?

we can change the dbname and dbid in 2 ways.


1. by recreating controlfile
2. using nid

2. using nid:

how to change the dbname:

shutdown immediate
startup mount
nid target=sys/sys dbname=abc1 setnewname=y
it will change the dbname in controlfile and datafile headers.

shutdown immediate
modify in the parameter file
startup
how to change the dbid

shutdown immediate
startup mount
nid target=sys/sys setnewname=n
it will change the dbid in controlfile and datafile headers.
shutdown immediate
startup mount
alter database open resetlogs;

presteps for the clonings:

1. we should take the successful backup on the production.


2. do the capacity planning - check sufficient storage is available in
the test or not based on the production DB Size
3. take the test database users password if test DB already exists
4. estimate the ETA of the activity.

post steps for cloning:

1. add the tempfile for cold and hot cloning method


2. change the dbid for cold,hot and rman cloning with out duplicate command
methods.
3. reset the users passwords in test db becauase production passwords
will come to test users
4. validate the dblinks
5. start the listener and check the tnsping and deliver the database
to apps team.

You might also like