0% found this document useful (0 votes)
125 views

Clone Database

The document provides instructions for backing up and restoring an Oracle database from a source instance to a target instance. The steps include: 1) Backing up initialization files, password files, and configuration files from the source instance. 2) Taking a hot backup of the source database. 3) Configuring the target instance by copying files from backup, relinking executables, creating initialization files and control files, and recovering the database using archived redo logs. 4) Opening the database on the target instance with the logs reset.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
0% found this document useful (0 votes)
125 views

Clone Database

The document provides instructions for backing up and restoring an Oracle database from a source instance to a target instance. The steps include: 1) Backing up initialization files, password files, and configuration files from the source instance. 2) Taking a hot backup of the source database. 3) Configuring the target instance by copying files from backup, relinking executables, creating initialization files and control files, and recovering the database using archived redo logs. 4) Opening the database on the target instance with the logs reset.
Copyright
© Attribution Non-Commercial (BY-NC)
Available Formats
Download as DOC, PDF, TXT or read online on Scribd
You are on page 1/ 6

A) Backup the following files.

Give appropriate names to the backup so that one can make out the file. <backup_loc> or <backup_location> in the doc = Refers to the location where you have taken the backup of the corresponding file A) Backup the following files on the TARGET system. As target user DB - dbaquest Backup init.ora , pwfile , spfile , listener.ora ,tnsnames.ora ,sqlnet.ora export BKPDATE=18jul10 echo $BKPDATE export DBBKP=<backup_location> echo $DBBKP Init.ora files cp $ORACLE_HOME/dbs/initTARGET.ora $DBBKP/ cp $ORACLE_HOME/dbs/pwdTARGET.ora $DBBKP/ Env file cp $ORACLE_HOME/TARGET_dbaquest.env $DBBKP/ Tnsnames,listen and sqlnet files cp $TNS_ADMIN/listener.ora $DBBKP/ cp $TNS_ADMIN/tnsnames.ora $DBBKP/ cp $TNS_ADMIN/sqlnet.ora $DBBKP/

B) Take a hot backup of the SOURCE Instance C) alter database backup controlfile to trace Copy the trace file to the target system by the name TARGET_control.sql D) SHUTDOWN the target DATABASE and LISTENER E) Remove the TARGET ORACLE_HOME and database F) Copy the ORACLE_HOME and the database from the hot backup to the TARGET system to replace the target system. CONFIGURING TARGET DB

1 Login as target user user and Verify .profile and *.env file under $ORACLE_HOME Make sure that the environment is set for the Target System. cd $ORACLE_HOME pwd 2 Check all oracle related file systems for user and group ownership

cd <TARGET file systems> ls -l Check user and group ownership : It should be proper 3 Get tnsnames.ora and listener.ora from Backup / Create the tnsnames and listener.ora

cd <backup_location> pwd cp ./tnsnames.ora $TNS_ADMIN/tnsnames.ora cp ./sqlnet.ora $TNS_ADMIN/sqlnet.ora cp ./listener.ora $TNS_ADMIN/listener.ora 4 In config.c, make sure the entries are pointing to target .

cd $ORACLE_HOME/rdbms/lib ls -ltr config* vi config.c Take care of Group. It should be modified to look like : #define SS_DBA_GRP "dbTARGET" #define SS_OPER_GRP "dbTARGET"

Move config.o

cd $ORACLE_HOME/rdbms/lib mv config.o config.o.old_18jul10

As this is RAC to NON-RAC Refresh, relink Oracle with rac_off cd $ORACLE_HOME/rdbms/lib make -f ins_rdbms.mk rac_off

If this step did not fail with fatal errors, proceed with : make -f ins_rdbms.mk ioracle 7 Relink all the executables. cd $ORACLE_HOME/bin ./relink all 8 Verify the Timestamp ls -l $ORACLE_HOME/bin/oracle

Verify that you can run sqlplus / as sysdba without prompting for any password. sqlplus "/ as sysdba" connected to idle instance

10

Get the init.ora from the backup location / Create the init.ora export BKPDATE=18jul10 echo $BKPDATE cd /ptsadmin/refresh/Refresh_TARGET/$BKPDATE/DB cp ./initTARGET.ora $ORACLE_HOME/dbs/

11

Check the following parameter Values - should be appropriate :

log_archive_start = TRUE log_archive_dest = /TARGET/arch log_archive_format= TARGET_%t_%s.arc 12 Prepare the Control file script .

ls SOURCE1_control.sql cp SOURCE1_control.sql TARGET_control.sql vi TARGET_control.sql a) Consider the resetlog portion of this script . Delete the noresetlogs section of the script. b) Old Entry - CREATE CONTROLFILE REUSE DATABASE "SOURCE" NORESETLOGS ARCHIVELOG FORCE LOGGING

New Entry - CREATE CONTROLFILE REUSE SET DATABASE "SOURCE" RESETLOGS ARCHIVELOG c) Change the location of Datafiles to point to the Target, Replace all occurances of : SOURCE replaced by Replace all occurances of : SOURCE replaced by TARGET TARGET

d) Remove the TEMP file entries ( keep a safe copy, for later use). Keep a safe backup of Temporary creation part and redo logfile creation statements. After this , you can remove all lines after characterset and semicolon. e) Inspect the control file script The number of Datafiles should match that in the source. select count(*) from v$datafile at the source. Similarily, number of copied Datafiles at the Target should match the definition in the script. Example of what you will be left with in TARGET_control.sql STARTUP NOMOUNT; CREATE CONTROLFILE REUSE SET DATABASE "TARGET" RESETLOGS ARCHIVELOG MAXLOGFILES 32 MAXLOGMEMBERS 5 MAXDATAFILES 1024 MAXINSTANCES 8 MAXLOGHISTORY 1361 LOGFILE GROUP 1 ( '/TARGET/..../log01a.dbf', '/TARGET/..../log01b.dbf' ) SIZE 200M, GROUP 2 ( '/TARGET/..../log02a.dbf', '/TARGET/..../log02b.dbf' ) SIZE 200M, GROUP 3 ( '/TARGET/..../log03a.dbf', '/TARGET/..../log03b.dbf' ) SIZE 200M, . DATAFILE '/TARGET/..../system01.dbf', '/TARGET/..../system02.dbf', . .. (representing other datafiles) CHARACTER SET UTF8

; 13 Create the Controlfile

$sqlplus "/ as sysdba" SQL>@TARGET_control.sql 14 See archive log mode

SQL>ARCHIVE LOG LIST Should show automatic archiving Enabled and Archivelog Mode 15 Recover the database SQL> recover database using backup controlfile until cancel; Enter the archive file location, when prompted. Use the following query on SOURCE to get the list of archives needed to be recovered select THREAD#, SEQUENCE# from v$log_history where &1 between FIRST_CHANGE# and NEXT_CHANGE#; Here For the value for $1 to be given will come from the sequence returned by the command recover database using backup controlfile until cancel; which you have given on TARGET 16 Open the DB with resetlogs SQL> alter database open resetlogs; When the DB opens, check for any missing files or files needed for recovery SQL> select * from v$recover_file; SQL> select * from v$datafile where name like '%MISS%'; Should not return any rows for these queries. 17 Shutdown the Database 18 Make sure that the entries in oraInst.loc are correct.

Example $ cat /etc/oraInst.loc inventory_loc=/TARGET/oracle/product/oraInventory inst_group=dbTARGET

19 Check for the Default Temporary file select * from database_properties where property_name = 'DEFAULT_TEMP_TABLESPACE'; Confirm that this TEMP. If the default is not TEMP, SQL>alter database default temporary tablespace TEMP 20 Create the Temp datafiles , using the commands taken from the control file. ALTER TABLESPACE TEMP ADD TEMPFILE __________
Example - The commands will be similar to below

ALTER TABLESPACE TEMP ADD TEMPFILE '/TARGET/..../temp20.dbf' SIZE 134217728 REUSE AUTOEXTEND ON NEXT 52428800 MAXSIZE 1800M; ALTER TABLESPACE TEMP ADD TEMPFILE '/TARGET/..../temp19.dbf' SIZE 134217728 REUSE AUTOEXTEND ON NEXT 52428800 MAXSIZE 1800M; ALTER TABLESPACE TEMP ADD TEMPFILE '/TARGET/..../temp18.dbf' SIZE 134217728 REUSE AUTOEXTEND ON NEXT 52428800 MAXSIZE 1800M; ALTER TABLESPACE TEMP ADD TEMPFILE '/TARGET/..../temp17.dbf' SIZE 134217728 REUSE AUTOEXTEND ON NEXT 52428800 MAXSIZE 1800M; Verify dba_temp_files, for all the temp file entries added to TEMP SQL> select file_name from dba_temp_files; 21 Update global_name select * from global_name; update global_name set global_name='TARGET.ORACLEOUTSOURCING.COM'; commit; SQL> select * from global_name; GLOBAL_NAME -------------------------------------------------------------------------------TARGET

You might also like