Oracle Cloning-Conventional Restore method and Rename DB post DB Refresh
Oracle Cloning - Conventional Restore method and Rename DB post DB Refresh
For DBA Refreshing Table, Schema and Database are routine activity. You can refresh/Clone database using below method:
1.Conventional Restore method and Rename DB post DB Refresh
2.Conventional Duplicate Database method
3. Active database Cloning
4.Backup Base Cloning
We will cover all these methods of cloning in individual blogs. In This blog , We will discuss about how to refresh/Clone Database using Conventional Restore method and Rename DB post DB Refresh.
In this method , We will first restore target database on the auxiliary server as target DB name and post restore , We will change the name of the target database to auxiliary database. Below are the steps for cloning using this method:
1) Make the Source Database entry in oratab
2) Set ORACLE_SID environment variable: ORACLE_SID should be set to the proper SID name (target DB)
3) . Restore spfile from backup:
To restore the spfile, you first need to startup the database in the nomount state. This starts up the database using a dummy parameter file. After that you can restore the spfile from the backup. Finally you restart the database in nomount state. The restart is required in in order to start the instance using the restored parameter file. Below is snapshot RMAN transcript for the foregoing procedure. Note the difference in SGA size and components between the two startups:
RMAN> startup nomount
Note: if you get memory error while
running startup nomount command
Set environment variable ORA_RMAN_SGA_TARGET before executing rman. For example:
$ export ORA_RMAN_SGA_TARGET=350
Restore spfile from full online
backup.
RMAN>restore spfile from ‘H:\Restore\orabackup\flash_recovery_area\\BACKUPSET\2008_09_09\O1_MF_NCSN0_DAILY_FULL_ONLINE_4DCDWVKM_.BKP’;
4) Create pfile from spfile.
Open Another command prompt window
and set oracle_sid=<Target DB>
Open sqlplus and create pfile from spfile.
5) Change the parameter paths in the
pfile using OS editor.
Pfile will be created at
%ORACLE_HOME%\database\initngmes.ora
Note :
- DB_Name and Instance_name need to set as source database sid
- all folder like bdump,cdump and controlfile dir .. name need to set as target database
6) Create spfile from pfile.
RMAN> startup force nomount
7) Restore control file from backup
RMAN>restore controlfile from ‘H:\Restore\orabackup\flash_recovery_area\\BACKUPSET\2008_09_09\O1_MF_NCSN0_DAILY_FULL_ONLINE_4DCDWVKM_.BKP’;
RMAN> shutdown
RMAN> exit
C:\> sqlplus
Sql > startup mount;
8) Catalog the RMAN backup directory to
new created database .
RMAN > CATALOG START WITH 'H:\Restore\orabackup\flash_recovery_area\\BACKUPSET\2008_09_09' NOPROMPT ;
9) Create command to set new names for datafiles/logfile to new location on new server.
Note : You can use the below commands to make the
SET NEWNAME FOR DATAFILE command and place the same in run command
select 'set newname for datafile '''||name||''' to '''||replace(name,'Prod_SID','Auxiliary_SID ') ||''';' from v$datafile ;
select 'set newname for tempfile '''||name||''' to '''||replace(name,'Prod_sid','Auxiliary_SID') ||''';' from v$tempfile ;
e.g
select 'set newname for datafile '''||name||''' to '''||replace(name,'remp1','remd1') ||''';' from v$datafile ;
select 'set newname for tempfile '''||name||''' to '''||replace(name, 'remp1','remd1') ||''';' from v$tempfile ;
10) Restore and Recover database from the backup.
run
{
ALLOCATE CHANNEL ch1 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch2 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch3 DEVICE TYPE DISK ;
ALLOCATE CHANNEL ch4 DEVICE TYPE DISK ;
SET NEWNAME FOR DATAFILE 1 TO 'H:\oradata\auxdb\data\SYSTEM01.DBF';
SET NEWNAME FOR DATAFILE 2 TO 'H:\oradata\auxdb\data\UNDOTBS01.DBF';
SET NEWNAME FOR DATAFILE 3 TO 'H:\oradata\auxdb\data\SYSAUX01.DBF';
SET NEWNAME FOR DATAFILE 4 TO 'H:\oradata\auxdb\data\DRSYS01.DBF';
SET NEWNAME FOR DATAFILE 5 TO 'H:\oradata\auxdb\data\TOOLS01.DBF';
SET NEWNAME FOR DATAFILE 6 TO 'H:\oradata\auxdb\data\USERS01.DBF';
SET NEWNAME FOR DATAFILE 7 TO 'H:\oradata\auxdb\data\auxdb.DBF';
SET NEWNAME FOR DATAFILE 8 TO 'H:\oradata\auxdb\data\auxdb_02.DBF';
SET NEWNAME FOR DATAFILE 9 TO 'H:\oradata\auxdb\data\auxdb_03.DBF';
SET NEWNAME FOR DATAFILE 10 TO 'H:\oradata\auxdb\data\auxdb_04.DBF';
SET NEWNAME FOR DATAFILE 11 TO 'H:\oradata\auxdb\data\auxdb_05.DBF';
restore database ;
switch datafile all;
set until time "to_date('24-02-2022 09:14:00','dd-mm-yyyy hh24:mi:ss' )";
recover database ;
}
Time need to be put as per backup existing at server.
Execute the command at RMAN prompt
Recover database: Obviously recovery is dependent on the available archived (and online) redo logs. we can recover only up to the time of the backup. Further, since this is an incomplete recovery, we will have to open the database with reset logs.
11) Rename the Log files path :
select 'alter database rename
file '''||MEMBER||''' to '''||replace(MEMBER,'ghnomst1','ghnomsp1') ||''';' from
v$logfile ;
Need
to Disable the block tracking to open the database.
Snapshot below :
Check the Temp files if not ..kindly create as Prod have or better create
backup controlfile and you will get the command to create temp file
13) Change the name of the database:
Note : Database is open now with Source Database SID Which need to change
the source database Sid
Backup
the database.
Mount the
database after a clean shutdown:
SHUTDOWN
IMMEDIATE
STARTUP
MOUNT
Invoke
the DBNEWID utility (nid) from the command line using a user with SYSDBA
privilege.
oraware->nid target=sys as sysdba dbname=auxdb
Shutdown and open the database with RESETLOGS:
SHUTDOWN IMMEDIATE
Reset the DB_NAME and Instance_name of Refreshed DB in pfile
STARTUP MOUNT pfile = ‘PATH’
ALTER DATABASE OPEN RESETLOGS;
You can learn more about oracle database administration:
Pro Oracle GoldenGate for the DBA
Oracle Security Tools Installation and Configuration
==========================================================
Please check our other blogs for Refresh
Comments
Post a Comment
Please do not enter any spam link in comment Section suggestions are Always Appreciated. Thanks.. !