database cloning using cold backup
DESCRIPTION
oracle 11g cloningTRANSCRIPT
![Page 1: Database Cloning Using Cold Backup](https://reader036.vdocuments.site/reader036/viewer/2022082505/55cf931c550346f57b9bc8b4/html5/thumbnails/1.jpg)
DATABASE CLONING USING COLD BACKUP
[root@localhost ~]# su - raman[raman@localhost ~]$ ls -ltrh
-rw-r--r-- 1 raman dba1 167 Apr 6 11:33 raman.env-rw-r--r-- 3 raman dba1 4096 Apr 6 13:11 raman1.env
[raman@localhost ~]$ . raman.env[raman@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Apr 22 04:48:40 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
SQL> startupORACLE instance started.
Total System Global Area 272011264 bytesFixed Size 1299344 bytesVariable Size 230689904 bytesDatabase Buffers 37748736 bytesRedo Buffers 2273280 bytesDatabase mounted.Database opened. Check all the datafiles in the database and take only the backup of datafiles, not the backup of redolog files and control files because it is a clean shutdown, so no need of taking the backup of redolog files and we will also create control files, so no need of taking the backup of control files also.
SQL> select name from v$datafile;
NAME--------------------------------------------------------------------------------/d01/oracle/oradata/raman/system01.dbf
![Page 2: Database Cloning Using Cold Backup](https://reader036.vdocuments.site/reader036/viewer/2022082505/55cf931c550346f57b9bc8b4/html5/thumbnails/2.jpg)
/d01/oracle/oradata/raman/sysaux01.dbf/d01/oracle/oradata/raman/undotbs01.dbf/d01/oracle/oradata/raman/users01.dbf
Take the backup of control file to trace only because we need to change the database name while creating the control file.
SQL> alter database backup controlfile to trace;
Database altered.
Check the alert log file locations using either v$diag_info or background_dump_dest parameter;
SQL> show parameter background_dump_dest;
NAME VALUE------------------------------------ ----------- ------------------------------background_dump_dest /d01/oracle/diag/rdbms/raman/raman/trace
Create pfile from spfile and do the appropriate changes in stage database.
SQL> create pfile from spfile;
Go to datafile locations and copy all the datafiles to backup locations.
[raman@localhost ~]$ cd /d01/oracle/oradata/raman
[raman@localhost raman]$ ll
-rw-r----- 1 raman dba1 9748480 Apr 22 04:52 control01.ctl-rw-r----- 1 raman dba1 9748480 Apr 22 04:52 control02.ctl-rw-r----- 1 raman dba1 9748480 Apr 22 04:52 control03.ctl-rw-r----- 1 raman dba1 52429312 Apr 22 04:48 redo01.log-rw-r----- 1 raman dba1 52429312 Apr 22 04:52 redo02.log-rw-r----- 1 raman dba1 52429312 Apr 22 04:48 redo03.log-rw-r----- 1 raman dba1 590880768 Apr 22 04:52 sysaux01.dbf-rw-r----- 1 raman dba1 713039872 Apr 22 04:52 system01.dbf-rw-r----- 1 raman dba1 20979712 Apr 22 04:21 temp01.dbf
![Page 3: Database Cloning Using Cold Backup](https://reader036.vdocuments.site/reader036/viewer/2022082505/55cf931c550346f57b9bc8b4/html5/thumbnails/3.jpg)
-rw-r----- 1 raman dba1 41951232 Apr 22 04:52 undotbs01.dbf-rw-r----- 1 raman dba1 5251072 Apr 22 04:52 users01.dbf
Before copying the datafiles, create directory clonedb inside oradata because physically it should exist.
[raman@localhost oradata]$ cd /d01/oracle/oradata
[raman@localhost oradata]$ mkdir clonedb
Now, copy all the datafiles to backup locations.
[raman@localhost raman]$ cp *.dbf /d01/oracle/oradata/clonedb
Now, come to alert log file and find out the trace files for creation of control file.
[raman@localhost ~]$ cd d01/oracle/diag/rdbms/raman/raman/trace
[raman@localhost ~]$ vi alert_raman.log
Sun Apr 22 04:49:32 2012Completed: ALTER DATABASE OPENSun Apr 22 04:51:50 2012alter database backup controlfile to traceBackup controlfile written to trace file d01/oracle/diag/rdbms/raman/raman/trace/raman_ora_7774.trcCompleted: alter database backup controlfile to traceSun Apr 22 04:52:11 2012Stopping background process SMCOStopping background process FBDAShutting down instance: further logons disabled
[raman@localhost trace]$ cp /d01/oracle/diag/rdbms/raman/raman/trace/raman_ora_7774.trc /d01/raman.sql
Edit the trace file script and do the appropriate changes i.e. change REUSE to SET, NORESETLOGS to RESETLOGS and database name also.
![Page 4: Database Cloning Using Cold Backup](https://reader036.vdocuments.site/reader036/viewer/2022082505/55cf931c550346f57b9bc8b4/html5/thumbnails/4.jpg)
[raman@localhost trace]$ vi /d01/raman.sql
STARTUP NOMOUNTCREATE CONTROLFILE SET DATABASE "CLONEDB" RESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 3 MAXDATAFILES 100 MAXINSTANCES 8 MAXLOGHISTORY 292LOGFILE GROUP 1 '/d01/oracle/oradata/clonedb/redo01.log' SIZE 50M, GROUP 2 '/d01/oracle/oradata/clonedb/redo02.log' SIZE 50M, GROUP 3 '/d01/oracle/oradata/clonedb/redo03.log' SIZE 50M-- STANDBY LOGFILEDATAFILE '/d01/oracle/oradata/clonedb/system01.dbf', '/d01/oracle/oradata/clonedb/sysaux01.dbf', '/d01/oracle/oradata/clonedb/undotbs01.dbf', '/d01/oracle/oradata/clonedb/users01.dbf'CHARACTER SET WE8MSWIN1252;:%s/raman/clonedb/g (change the name raman to clonedb)
Note: All the locations of this control file creation script should exist physically, so create the appropriate directory physically.
Now, come to parameter file locations and copy the pfile.
[raman@localhost dbs]$ cd $ORACLE_HOME/dbs[raman@localhost dbs]$ cp initraman.ora initclonedb.ora
Edit the parameter file and do the appropriate changes.
Note: All the locations of this parameter file should exist physically, so create the appropriate directory physically and change the database name also
[raman@localhost dbs]$ vi initclonedb.ora
clonedb.__db_cache_size=37748736
![Page 5: Database Cloning Using Cold Backup](https://reader036.vdocuments.site/reader036/viewer/2022082505/55cf931c550346f57b9bc8b4/html5/thumbnails/5.jpg)
clonedb.__java_pool_size=4194304clonedb.__large_pool_size=4194304clonedb.__oracle_base='/d01/oracle'#ORACLE_BASE set from environmentclonedb.__pga_aggregate_target=121634816clonedb.__sga_target=150994944clonedb.__shared_io_pool_size=0clonedb.__shared_pool_size=100663296clonedb.__streams_pool_size=0*.audit_file_dest='/d01/oracle/admin/clonedb/adump'*.audit_trail='db'*.compatible='11.1.0.0.0'*.control_files='/d01/oracle/oradata/clonedb/control01.ctl','/d01/oracle/oradata/clonedb/control02.ctl','/d01/oracle/oradata/clonedb/control03.ctl'*.db_block_size=8192*.db_domain='xcellit.com'*.db_name='clonedb'*.db_recovery_file_dest='/d01/oracle/flash_recovery_area'*.db_recovery_file_dest_size=2147483648*.diagnostic_dest='/d01/oracle'*.dispatchers='(PROTOCOL=TCP) (SERVICE=clonedbXDB)'*.memory_target=269484032*.open_cursors=300*.processes=150*.remote_login_passwordfile='EXCLUSIVE'*.undo_tablespace='UNDOTBS1'
:%s/raman/clonedb/g
Copy the environment file to backup locations and give the appropriate name of new environment file and change the ORACLE_SID parameter.
[raman@localhost ~]$ cp raman.env clonedb.env
export ORACLE_BASE=/d01/oracleexport ORACLE_HOME=/d01/oracle/11gR2export ORACLE_SID=clonedbexport PATH=$ORACLE_HOME/bin:$PATHexport LD_LIBRARY_PATH=$ORACLE_HOME/lib
![Page 6: Database Cloning Using Cold Backup](https://reader036.vdocuments.site/reader036/viewer/2022082505/55cf931c550346f57b9bc8b4/html5/thumbnails/6.jpg)
[raman@localhost ~]$ lltotal 32-rw-r--r-- 1 raman dba1 169 Apr 22 05:09 clonedb.env-rw-r--r-- 1 raman dba1 168 Apr 6 12:47 raman1.env-rw-r--r-- 1 raman dba1 167 Apr 6 11:33 raman.env
Now run the environment file in stage server.
[raman@localhost ~]$ . clonedb.env[raman@localhost ~]$ sqlplus / as sysdba
SQL*Plus: Release 11.1.0.6.0 - Production on Sun Apr 22 05:19:24 2012
Copyright (c) 1982, 2007, Oracle. All rights reserved.
Connected to an idle instance.
Start the database in nomount stage.
SQL> startup nomountORACLE instance started.
Total System Global Area 272011264 bytesFixed Size 1299344 bytesVariable Size 230689904 bytesDatabase Buffers 37748736 bytesRedo Buffers 2273280 bytes
Run the trace file script to create control file
SQL> @/d01/raman.sql
Control file created.
Now, the database is in mount stage, so open it with reset logs. SQL> alter database open resetlogs;
Database altered.
![Page 7: Database Cloning Using Cold Backup](https://reader036.vdocuments.site/reader036/viewer/2022082505/55cf931c550346f57b9bc8b4/html5/thumbnails/7.jpg)
Now, verify whether cloning is done or not successfully.
SQL> select name from v$database;
NAME---------CLONEDB
STEPS OF DATABASE CLONING USING COLD BACKUP:1. Check all the datafiles in database.2. Take the backup of control file to trace.3. Shutdown the database cleanly with IMMEDIATE, NORMAL, OR TRANSACTIONAL.4. Copy all the datafiles to backup locations (no need of taking the backup of redo log files and control files because it is clean shutdown and we will create control file also).[root@localhost ~]# scp –r backup [email protected]:/d01/oracle/
5. Create pfile from spfile and copy to stage server. [root@localhost ~]# scp initraman.ora [email protected]:/d01/oracle/11gR2/dbs
6. Copy the control file script to stage server and do the appropriate changes.7. Copy the environment file to backup location.8. Now, log on to stage server and create environment file and change ORACLE_SID parameter to new name.9. Edit in pfile: dbname, control file parameter etc.10. Run the environment file.11. Start the database in nomount stage.12. Execute the control file script.13. Open the database with reset logs.14. Verify whether the cloning is done or not.