Instance Details:
Source Instance : PRD
Target Instance : TST
Pre-Tasks:
Do blackout and bring down taget system’s services
Backup parameter file, CONTEXT_FILEs and all environment file of both application and database.
Remove Application files(apps_st, tech_st and INST_TOP) of target system.
drop the database:
screen -S ownuser
sudo su - oracle
Startup mount exclusive restrict;
show parameter CLUSTER_DATABASE;
select name,open_mode from v$database;
Drop database;
Prepare the source system:
On source, run adpreclone.pl ( if not executed recently)
$ cd $ORACLE_HOME/appsutil/scripts/[CONTEXT_NAME]
$ perl adpreclone.pl dbTier
$ cd $INST_TOP/admin/scripts
$ perl adpreclone.pl appsTier
Copying files:
On DB Node
Copy the latest DB backups from source to target (Including archivelog backup and controlfile backup)
On Apps Node
Copy apps_st and tech_st from source application node to target application node.
Steps to Clone Database, here can be multiple ways.
1.With duplicate from backup or standby database:
cle@hostname scripts]$ cat duplicate.sh
#!/bin/ksh
today=`date +"%Y%m%d_%H:%M:%S"`
. /u01/home/oracle/TST.env
rman=$ORACLE_HOME/bin/rman
$ORACLE_HOME/bin/rman cmdfile=/u01/script/duplicate.fic log=/u01/log/rman_9june17.log
[oracle@hostname scripts]$ cat duplicate.fic
@/u01/script/duplicate.cnx
run {
allocate auxiliary channel uisk1 type DISK;
SET NEWNAME FOR BLOCK CHANGE TRACKING FILE TO '+MAN';
#set until time "TO_DATE('2016-06-19 00:25:00','yyyy-mm-dd hh24:mi:ss')";
duplicate database to TST backup location '/backup/PRD/rman' nofilenamecheck
LOGFILE
GROUP 1 ('+TST_REDO') SIZE 500M,
GROUP 2 ('+TST_REDO') SIZE 500M,
GROUP 3 ('+TST_REDO') SIZE 500M
;
}
[oracle@hostname scripts]$ cat /u01/script/duplicate.cnx
set echo off
connect auxiliary /
set echo on
[oracle@hostname scripts]$
2. Available hot backup:
Change the db_name parameter in pfile that is backed up (eg: TST to PRD)
Start the target db using modified pfile
Sql > startup nomount pfile=’/backup/clone/initTST.ora’
Rstore the controlfile from the backup of PRD
RMAN> restore controlfile from ‘/backup/clone/PRD/PRD.ctl’
Mount the database
Sql> alter database mount
Once db is mounted catalog the backups copied from source.
RMAN > catalog start with ‘/backup/clone/PROD/’;
Once the backups are cataloged we can restore the database usig the PRD’s backup. But the database files are pointing to PRD’s
location so it will try to restore the datafiles to PRD’s location which may not exist in target.
Hence we will have to rename the datafiles to point to new(TST) location before restoring. We can rename the files or use SET NEWNAME in RMAN before restoring.
eg: set newname for datafile 1 to ‘/u01/oracle/TST/system.dbf’;
Note : Below script can be used to create the script for “SET NEWNAME”. Change the path of target datafile location and run the script in source.
select ‘set newname for datafile ‘ || file_id || ‘ to ”/u01/oracle/TST/’ ||
substr(file_name,instr(file_name,’/’,-1)+1) || ”’;’
from dba_data_files;
Restore and recover the database
Eg:
Rman>run {
set until time “to_date(’26/08/2017 24:20:00′,’dd/mm/yyyy hh24:mi:ss’)”;
set newname for datafile 1 to ‘/u01/oracle/TST/system.dbf’;
set newname for datafile 44 to ‘/u01/oracle/TST/apps_ts_tx_data_01.dbf’;
set newname for datafile 76 to ‘/u01/oracle/TST/apps_ts_tx_idx01.dbf’;
set newname for datafile 35 to ‘/u01/oracle/TST/sysaux_01.dbf’;
set newname for datafile 37 to ‘/u01/oracle/TST/undotbs1_01.dbf’;
allocate channel ch1 type disk;
allocate channel ch2 type disk;
restore database;
switch datafile all;
recover database;
release channel ch1;
release channel ch2;
}
After the database is restored and recovered then open the database using resetlogs.
SQL> alter database open resetlogs;
Change the database name to TEST
nid TARGET=SYS/welcome123 DBNAME=TEST
Once the database is renamed the nid command will bring down the database. Start it using the old pfile in ORACLE_HOME/dbs. (which has db_name as TEST)
Sql>startup mount
Sql>alter database open resetlogs;
3. Put the source in begun backup mode and contnue:
Put the database in the begin backup mode so that the backup can be performed without disturbing to other operations in the database.
SQL> alter database begin backup;
You can check the status of backup activation mode by using the below command
SQL> select * from v$backup;
status:ACTIVE
Copy the all database files from the database tier to the target location
Next release the database from the backup mode,
SQL> alter database end backup;
Status:NOT ACTIVE
Next take backup of the controlfile to the backup location by using the command,
SQL> alter database backup contolfile to trace as ‘/u01/oraR12/cont.sql’;
Copy the generated archivelog file to the target location which is required for recovering the database at target location. Copy the trace of controlfile also.
$ cd /u01/oraR12/db/tech_st/11.1.0/appsutil/clone/bin
$ perl adcfgclone.pl dbTechStack
Recreates the database control files
Once control file is created, database will be in mount stage. Execute recover command using backup control file after the database is mounted.
SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
Starts the database
4.Cold Backup
Post Steps in Database:
Recreate ALL the temp tablespaces.
SQL> EXEC FND_CONC_CLONE.SETUP_CLEAN;
Run auto-config on DB Tier after ensuring that the DB and listener are up and running.
Steps to Clone Application:
Compare the size (du –sh) output with production for same content.
cd /u01/oracle/TST/apps/apps_st/comn/clone/bin
perl adcfgclone.pl appsTier <Path of the context_file that was saved in Pre Task B>
Stop the concurrent managers and workfow.
Stop the Applications
Change Apps password:
FNDCPASS apps/xxx 0 Y system/xx SYSTEM APPLSYS XXX
Change Sysasmin password:
FNDCPASS apps/xxx 0 Y system/xxx USER SYSADMIN xxx
Point all the fndcpesr soft links in $XX_TOP/bin to $FND_TOP/bin/fndcpesr
Run cmclean.sql
Run adautocfg.sh
Start all the services
Login to the application using login page and launch the forms.CM check
Change the Site Name to the name of the current environment with information of the Refreshed time
Source Instance : PRD
Target Instance : TST
Pre-Tasks:
Do blackout and bring down taget system’s services
Backup parameter file, CONTEXT_FILEs and all environment file of both application and database.
Remove Application files(apps_st, tech_st and INST_TOP) of target system.
drop the database:
screen -S ownuser
sudo su - oracle
Startup mount exclusive restrict;
show parameter CLUSTER_DATABASE;
select name,open_mode from v$database;
Drop database;
Verify space on the database node and applications node
Prepare the source system:
On source, run adpreclone.pl ( if not executed recently)
$ cd $ORACLE_HOME/appsutil/scripts/[CONTEXT_NAME]
$ perl adpreclone.pl dbTier
$ cd $INST_TOP/admin/scripts
$ perl adpreclone.pl appsTier
Copying files:
On DB Node
Copy the latest DB backups from source to target (Including archivelog backup and controlfile backup)
On Apps Node
Copy apps_st and tech_st from source application node to target application node.
Steps to Clone Database, here can be multiple ways.
1.With duplicate from backup or standby database:
cle@hostname scripts]$ cat duplicate.sh
#!/bin/ksh
today=`date +"%Y%m%d_%H:%M:%S"`
. /u01/home/oracle/TST.env
rman=$ORACLE_HOME/bin/rman
$ORACLE_HOME/bin/rman cmdfile=/u01/script/duplicate.fic log=/u01/log/rman_9june17.log
[oracle@hostname scripts]$ cat duplicate.fic
@/u01/script/duplicate.cnx
run {
allocate auxiliary channel uisk1 type DISK;
SET NEWNAME FOR BLOCK CHANGE TRACKING FILE TO '+MAN';
#set until time "TO_DATE('2016-06-19 00:25:00','yyyy-mm-dd hh24:mi:ss')";
duplicate database to TST backup location '/backup/PRD/rman' nofilenamecheck
LOGFILE
GROUP 1 ('+TST_REDO') SIZE 500M,
GROUP 2 ('+TST_REDO') SIZE 500M,
GROUP 3 ('+TST_REDO') SIZE 500M
;
}
[oracle@hostname scripts]$ cat /u01/script/duplicate.cnx
set echo off
connect auxiliary /
set echo on
[oracle@hostname scripts]$
2. Available hot backup:
Change the db_name parameter in pfile that is backed up (eg: TST to PRD)
Start the target db using modified pfile
Sql > startup nomount pfile=’/backup/clone/initTST.ora’
Rstore the controlfile from the backup of PRD
RMAN> restore controlfile from ‘/backup/clone/PRD/PRD.ctl’
Mount the database
Sql> alter database mount
Once db is mounted catalog the backups copied from source.
RMAN > catalog start with ‘/backup/clone/PROD/’;
Once the backups are cataloged we can restore the database usig the PRD’s backup. But the database files are pointing to PRD’s
location so it will try to restore the datafiles to PRD’s location which may not exist in target.
Hence we will have to rename the datafiles to point to new(TST) location before restoring. We can rename the files or use SET NEWNAME in RMAN before restoring.
eg: set newname for datafile 1 to ‘/u01/oracle/TST/system.dbf’;
Note : Below script can be used to create the script for “SET NEWNAME”. Change the path of target datafile location and run the script in source.
select ‘set newname for datafile ‘ || file_id || ‘ to ”/u01/oracle/TST/’ ||
substr(file_name,instr(file_name,’/’,-1)+1) || ”’;’
from dba_data_files;
Restore and recover the database
Eg:
Rman>run {
set until time “to_date(’26/08/2017 24:20:00′,’dd/mm/yyyy hh24:mi:ss’)”;
set newname for datafile 1 to ‘/u01/oracle/TST/system.dbf’;
set newname for datafile 44 to ‘/u01/oracle/TST/apps_ts_tx_data_01.dbf’;
set newname for datafile 76 to ‘/u01/oracle/TST/apps_ts_tx_idx01.dbf’;
set newname for datafile 35 to ‘/u01/oracle/TST/sysaux_01.dbf’;
set newname for datafile 37 to ‘/u01/oracle/TST/undotbs1_01.dbf’;
allocate channel ch1 type disk;
allocate channel ch2 type disk;
restore database;
switch datafile all;
recover database;
release channel ch1;
release channel ch2;
}
After the database is restored and recovered then open the database using resetlogs.
SQL> alter database open resetlogs;
Change the database name to TEST
nid TARGET=SYS/welcome123 DBNAME=TEST
Once the database is renamed the nid command will bring down the database. Start it using the old pfile in ORACLE_HOME/dbs. (which has db_name as TEST)
Sql>startup mount
Sql>alter database open resetlogs;
3. Put the source in begun backup mode and contnue:
Put the database in the begin backup mode so that the backup can be performed without disturbing to other operations in the database.
SQL> alter database begin backup;
You can check the status of backup activation mode by using the below command
SQL> select * from v$backup;
status:ACTIVE
Copy the all database files from the database tier to the target location
Next release the database from the backup mode,
SQL> alter database end backup;
Status:NOT ACTIVE
Next take backup of the controlfile to the backup location by using the command,
SQL> alter database backup contolfile to trace as ‘/u01/oraR12/cont.sql’;
Copy the generated archivelog file to the target location which is required for recovering the database at target location. Copy the trace of controlfile also.
$ cd /u01/oraR12/db/tech_st/11.1.0/appsutil/clone/bin
$ perl adcfgclone.pl dbTechStack
Recreates the database control files
Once control file is created, database will be in mount stage. Execute recover command using backup control file after the database is mounted.
SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;
Starts the database
4.Cold Backup
Post Steps in Database:
Recreate ALL the temp tablespaces.
SQL> EXEC FND_CONC_CLONE.SETUP_CLEAN;
Run auto-config on DB Tier after ensuring that the DB and listener are up and running.
Steps to Clone Application:
Compare the size (du –sh) output with production for same content.
cd /u01/oracle/TST/apps/apps_st/comn/clone/bin
perl adcfgclone.pl appsTier <Path of the context_file that was saved in Pre Task B>
Stop the concurrent managers and workfow.
Stop the Applications
Change Apps password:
FNDCPASS apps/xxx 0 Y system/xx SYSTEM APPLSYS XXX
Change Sysasmin password:
FNDCPASS apps/xxx 0 Y system/xxx USER SYSADMIN xxx
Point all the fndcpesr soft links in $XX_TOP/bin to $FND_TOP/bin/fndcpesr
Run cmclean.sql
Run adautocfg.sh
Start all the services
Login to the application using login page and launch the forms.CM check
Change the Site Name to the name of the current environment with information of the Refreshed time
No comments:
Post a Comment