Anda di halaman 1dari 16

Oralce Cloning - 3 Articles

Page | 1 -

12/31/07

Article 1
10 steps for cloning a database. Summary :Step 1. Shutdown database in normal mode and start it up in restricted mode. Step 2. Take the backup of control file Step 3. Shutdown database again in normal mode. Step 4. Copy /FTP init parameter file ,control file script and all the database file on the destination server/location, once all the files are successfully copied, you may startup the database normally.

The following steps must be on Source -Production instance/Server

The following step must be on destination Clone instance/server


Step 5. Edit init parameter file and control file script. Step 6. New Environment setup . Step 7. recreate control file Step 8. Open the database in resetlogs. Step 9. Shutdown the database in normal mode Step 10. Take the cold backup and start the database in archive/non archive mode.

Details :Step 1 3 on the Source Server ( Server A)

SVRMGR> connect internal/oracle


Connected. SVRMGR> shutdown ;
Database closed. Database dismounted.

Oralce Cloning - 3 Articles

Page | 2 -

12/31/07
ORACLE instance shut down.

SQL> startup restrict


ORACLE instance started. Total System Global Area Fixed Size Variable Size Database Buffers Redo Buffers Database mounted. Database opened. 57124108 bytes 70924 bytes 40198144 bytes 16777216 bytes 77824 bytes

SQL> alter database backup controlfile to trace; Statement processed. SQL> show parameter user_dump_dest NAME TYPE VALUE

----------------------------------- ------- ------------------------user_dump_dest string E:\ora816\admin\ora816\udump

Note :- Backup control file will generate in user dump destination as above. Check for the latest Ora<xxxxx>.trc . Rename this file to Ctrlprod.sql

SQL> shutdown immediate;


Database closed. Database dismounted. ORACLE instance shut down.

Oralce Cloning - 3 Articles

Page | 3 -

12/31/07
1.All Parameter files 1.All Parameter files

2. Control file 3. Datafiles 4. Redo log

2. Control file 3. Datafiles 4. Redo log

Source Production

Destination Clone

Step 4: Copy all the parameter files (initsid.ora, configsid.ora ), Control files, Ctrlprod.sql ( created as above) and all data files to clone server . It is good to follow the OFA. If you are cloning a database on the same machine then create a different directory structure ( as OFA) for cloning instance and copied all the required files of primary instance here. Step 4a : On Unix ( Let us say your cloning instance name is clone) If you had followed OFA , your initsid.ora parameters files would be in $ORACLE_BASE/admin/clone/pfile/initclone.ora and configsid.ora would be in $ORACLE_BASE/admin/clone/pfile/configclone.ora. Create a symbolic link Change the working directory to $ORACLE_HOME/dbs and create a symbolic link $ ln s $ORACLE_BASE/admin/clone/pfile/initclone.ora initclone.ora

Step 5 : On destination server


Change the following parameter in the initsid.ora of the cloning instance/server

InitSid.ora (initora816.ora) of the Source/production server.

InitSid.ora (initclone.ora) of the


destination/clone server.

Oralce Cloning - 3 Articles

Page | 4 -

12/31/07
db_name = "ora816" instance_name = ora816 service_names = ora816 control_files = ("e:\ora816\oradata\ora816\contr ol01.ctl", "f:\ora816\oradata\ora816\contro l02.ctl", "g:\ora816\oradata\ora816\contr ol03.ctl") Db_name= clone Instance_name= clone Service_name = clone Control_file = (C:\clone\control01.ctl,D:\clone\cont rol02.ctl)

The other parameter which is required to change is user_dump_dest, background_dump_dest,log_archive_dest Oraxxxx.trc is copied from source/production instance to destination/clone instance and renamed it as ctrlclone.sql . Edit ctrlclone.sql as follows.

Oraxxxx.trc in user dump dest of Source/Production instance

Ctrlclone.sql

/* Delete everything upto startup nomount */ STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "ORA816" NORESETLOGS ARCHIVELOG MAXLOGFILES 32 MAXLOGMEMBERS 2 MAXDATAFILES 32 MAXINSTANCES 16 MAXLOGHISTORY 1815 LOGFILE STARTUP NOMOUNT pfile=f:\clone\initclone.ora

CREATE CONTROLFILE set DATABASE "CLONE" rese noarchivelog MAXLOGFILES 32 MAXLOGMEMBERS 2 MAXDATAFILES 32 MAXINSTANCES 16 MAXLOGHISTORY 1815 LOGFILE

Oralce Cloning - 3 Articles

Page | 5 -

12/31/07
GROUP 1 'E:\ORA816\ORADATA\ORA816\REDO03.LOG' SIZE 1M, GROUP 2 'E:\ORA816\ORADATA\ORA816\REDO02.LOG' SIZE 1M, GROUP 3 'E:\ORA816\ORADATA\ORA816\REDO01.LOG' SIZE 1M DATAFILE 'E:\ORA816\ORADATA\ORA816\SYSTEM01.DBF', 'E:\ORA816\ORADATA\ORA816\RBS01.DBF', 'E:\ORA816\ORADATA\ORA816\TEMP01.DBF', 'E:\ORA816\ORADATA\ORA816\TOOLS01.DBF', 'E:\ORA816\ORADATA\ORA816\INDX01.DBF', 'E:\ORA816\ORADATA\ORA816\DR01.DBF', 'E:\ORA816\DATABASE\NGAR5ORA81601.DBF', 'E:\ORA816\DATABASE\RBSTEST01.DBF' CHARACTER SET WE8ISO8859P1 ; # Recovery is required if any of the datafiles are restored backups, # or if the last shutdown was not normal or immediate. GROUP 1 'F:\CLONE\ORA816\REDO03.LOG' SIZE 1M, GROUP 2 'F:\CLONE\ORA816\REDO02.LOG' SIZE 1M, GROUP 3 'F:\CLONE\ORA816\REDO01.LOG' SIZE 1M DATAFILE 'F:\CLONE\ORA816\SYSTEM01.DBF', 'F:\CLONE\ORA816\RBS01.DBF', 'F:\CLONE\ORA816\TEMP01.DBF', 'F:\CLONE\ORA816\TOOLS01.DBF', 'F:\CLONE\ORA816\INDX01.DBF', 'F:\CLONE\ORA816\DR01.DBF', 'F:\CLONE\DATABASE\NGAR5ORA81601.DBF', 'F:\CLONE\DATABASE\RBSTEST01.DBF' CHARACTER SET WE8ISO8859P1 ; # Recovery is required if any of the datafiles are restored backups,

RECOVER DATABASE
# All logs need archiving and a log switch is needed. ALTER SYSTEM ARCHIVE LOG ALL; # Database can now be opened normally. ALTER DATABASE OPEN;

# or if the last shutdown was not normal or immedi #RECOVER DATABASE

# All logs need archiving and a log switch is needed #ALTER SYSTEM ARCHIVE LOG ALL; # Database can now be opened normally. #ALTER DATABASE OPEN;

Oralce Cloning - 3 Articles

Page | 6 -

12/31/07

STEP 6 :ON NT :- You have to create a windows NT services as follows. C:\>oradim -new -sid clone -srvc oracleserviceClone -intpwd oracle -startmode auto -pfile f:\clone\initclone.ora ON Unix :(A) Change the working directory to /etc and edit the oratab file to put the entry for CLOBE instance. (B) Setup login profile for the Oracle user having dba group. ORACLE_SID=CLONE Export ORACLE_SID Or .oraenv

STEP 7 :- Create controlfile as follows :Check in the initclone.ora REMOTE_LOGIN_PASSWORDFILE is set to exclusive or shared. If this is set, then a valid passwordfile should exist in ORACLE_HOME/dbs or created using orapwd as orapwd file=/u01/oracle/V816/dbs/orapwV722 password=oracle entries=1 where /u01/oracle/V816 is an oracle home

SQL> @f:\clone\ctrlclone.sql
ORACLE instance started. Total System Global Area Fixed Size 57123804 bytes 70620 bytes

Oralce Cloning - 3 Articles

Page | 7 -

12/31/07
Variable Size Database Buffers Redo Buffers Statement processed. 40198144 bytes 16777216 bytes 77824 bytes

STEP 8 :- Open the database in resetlog mode as follows. SVRMGR> alter database open resetlogs; Statement processed.

STEP 9 :- Shutdown the database in Normal mode

SVRMGR> connect internal/oracle


Connected. SVRMGR> shutdown ;
Database closed. Database dismounted. ORACLE instance shut down.

STEP 10 :- Take the cold backup and start the database in archive/non archive mode.

Note :-

You cannot move datafiles from one operating system and use them on a different operating system. Therefore, it is not possible to clone a database running on SUN on an HP machine. You would have to use export/import.

Thanks for reading this article. Email me your comments or suggestions

Sameer Wadhwa
Wadhwa_S@Hotmail.com SamWad@msn.com

Oralce Cloning - 3 Articles

Page | 8 -

12/31/07

Article 2

Super fast Database Copying/Cloning


Oracle Tips by Burleson Consulting

A database cloning procedure is especially useful for the DBA who wants to give his developers a full-sized TEST and DEV instance by cloning the PROD instance into the development server areas. This Oracle clone procedure can be use to quickly migrate a system from one UNIX server to another. It clones the Oracle database and this Oracle cloning procedures is often the fastest way to copy a Oracle database. STEP 1: On the old system, go into SQL*Plus, sign on as SYSDBA and issue: alter database backup controlfile to trace. This will put the create database syntax in the trace file directory. The trace keyword tells oracle to generate a script containing a create controlfile command and store it in the trace directory identified in the user_dump_dest parameter of the init.ora file. It will look something like this:
STARTUP NOMOUNT CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS NOARCHIVELOG MAXLOGFILES 16 MAXLOGMEMBERS 2 MAXDATAFILES 240 MAXINSTANCES 1 MAXLOGHISTORY 113 LOGFILE GROUP 1 ('/u03/oradata/oldlsq/log1a.dbf', '/u03/oradata/olslsq/log1b.dbf') SIZE 30M, GROUP 2 ('/u04/oradata/oldlsq/log2a.dbf', '/u04/oradata/oldlsq/log2b.dbf') SIZE 30M DATAFILE '/u01/oradata/oldlsq/system01.dbf', '/u01/oradata/oldlsq/mydatabase.dbf' ; # Recovery is required if any of the datafiles are restored # backups, or if the last shutdown was not normal or immediate. RECOVER DATABASE # Database can now be opened normally. ALTER DATABASE OPEN;

STEP 2: Shutdown the old database

Oralce Cloning - 3 Articles

Page | 9 -

12/31/07
STEP 3: Copy all data files into the new directories on the new server. You may change the file names if you want, but you must edit the controlfile to reflect the new data files names on the new server.
rcp rcp rcp rcp /u01/oradata/oldlsq/* /u01/oradata/oldlsq/* /u03/oradata/oldlsq/* /u04/oradata/oldlsq/* newhost:/u01/oradata/newlsq newhost:/u01/oradata/newlsq newhost:/u03/oradata/newlsq newhost:/u04/oradata/newlsq

STEP 4: Copy and Edit the Control file Using the output syntax from STEP 1, modify the controlfile creation script by changing the following: Old:
CREATE CONTROLFILE REUSE DATABASE "OLDLSQ" NORESETLOGS

New:
CREATE CONTROLFILE SET DATABASE "NEWLSQ" NORESETLOGS

STEP 5: Remove the recover database and alter database open syntax
# Recovery is required if any of the datafiles are restored # backups, or if the last shutdown was not normal or immediate. RECOVER DATABASE # Database can now be opened normally. ALTER DATABASE OPEN;

STEP 6: Re-names of the data files names that have changed. Save as db_create_controlfile.sql. Old:
DATAFILE '/u01/oradata/oldlsq/system01.dbf', '/u01/oradata/oldlsq/mydatabase.dbf'

New:
DATAFILE '/u01/oradata/newlsq/system01.dbf', '/u01/oradata/newlsq/mydatabase.dbf'

STEP 7: Create the bdump, udump and cdump directories

Oralce Cloning - 3 Articles

Page | 10 -

12/31/07

cd $DBA/admin mkdir newlsq cd newlsq mkdir bdump mkdir udump mkdir cdump mkdir pfile

STEP 8: Copy-over the old init.ora file


rcp $DBA/admin/olslsq/pfile/*.ora newhost:/u01/oracle/admin/newlsq/pfile

STEP 9: Start the new database


startup nomount; @db_create_controlfile.sql

STEP 10: Place the new database in archivelog mode

Oralce Cloning - 3 Articles

Page | 11 -

12/31/07

Article 3
http://oracle.ittoolbox.com/documents/popular-q-and-a/how-to-clone-anoracle-database-1623

Cloning an Oracle Database Database cloning is a procedure by which you can create an exact copy of an Oracle database without doing a full export/import. This method is used frequently by DBAs to update test or development environments from production. As a rule, testing and development should not be done on your production database. That much is common sense. Depending on the resources available to companies, some have separate test and development databases and many roll testing and development into a single database. Now, the developers need up-to-date data for testing purposes, and it is the DBA who provides this to them. There are a few ways to do this. The first one that comes to mind is, of course, export and import. But this is cumbersome if you have to do the data refresh frequently and import takes a long time if your database is of good size. You can of course, resort to exporting and importing tablespaces if they are self contained and you are running version 8i or greater, enterprise edition. A faster alternative is to clone the database. Clone means an exact copy. That is, you will copy the very datafiles from your production database and use it to create your test database. So your test database will be a mirror image of the production in all respects, except of course, for the database name. We will be changing that. The method used here is actually a backup/recovery of the production database on the test server. We just recreate the controlfile on the test machine using a new database name and do a recovery. The datafiles from the production database can be from a hot backup, a cold backup or an RMAN backup. If the database was open during backup (hot or RMAN), you will need all the archivelogs since the time the backup started to recover the database to its present state (that is, do a complete recovery). Throughout the article, I will refer to environment variables by their UNIX notation (example $ORACLE_HOME). Replace this with the Windows equivalent if you are using NT/2000 (example $ORACLE_HOME becomes %ORACLE_HOME %). Let us use our customary server names and database names as an example. You have a production database named PROD, which resides on the machine PRODSERVER. You also have another server called TESTSERVER where you want to create a database called TEST, which is a clone of PROD. Here are the steps:

Oralce Cloning - 3 Articles

Page | 12 -

12/31/07
* Make sure your environment variables have been set properly on TESTSERVER. On UNIX, assuming you're using Korn Shell, export ORACLE_BASE=/u01/app/oracle export ORACLE_HOME=/u01/app/oracle/product/8.1.7 export ORACLE_SID=test On Windows NT/2000, set ORACLE_BASE=c:oracle set ORACLE_HOME=c:oracleora81 set ORACLE_SID=test * On TESTSERVER, create a directory called test under $ORACLE_BASE/admin. Create the following sub-directories for the TEST database under $ORACLE_BASE/admin/test --> pfile (This is where your init.ora file will reside) --> bdump (This is the directory that the init.ora parameter, BACKGROUND_DUMP_DEST, points to) --> udump (This is the directory that the init.ora parameter, USER_DUMP_DEST, points to) --> cdump (This is the directory that the init.ora parameter, CORE_DUMP_DEST, points to) * Copy your initprod.ora file to from the production machine to the directory $ORACLE_BASE/admin/test/pfile and rename it to init.ora. Make sure you copy any IFILE referenced in your init.ora file. If running UNIX, create a link to the init.ora file from $ORACLE_HOME/dbs. [] $ cd $ORACLE_HOME/dbs [oracle@testserver] $ ln -s /u01/app/oracle/admin/test/pfile/init.ora inittest.ora

If running Windows NT/2000, create a file called inittest.ora in %ORACLE_HOME%database. Edit this file using Notepad and add this single line to it IFILE=c:oracleadmintestpfileinit.ora * Change the following parameters in the inittest.ora file (or the init.ora file for the TEST database). - DB_NAME - Change from PROD to TEST - SERVICE_NAMES - If defined (by default, it is DB_NAME.DB_DOMAIN). For example, from PROD.WORLD to TEST.WORLD - CONTROL_FILES - Change it to an appropriate directory on TESTSERVER. You can leave the actual filenames as they are. - LOG_ARCHIVE_DEST_n - If you want to run TEST in archivelog mode - BACKGROUND_DUMP_DEST, USER_DUMP_DEST, CORE_DUMP_DEST - Change them to the new directories that you just created under $ORACLE_BASE/admin/test - Resize SHARED_POOL, DB_BLOCK_BUFFERS (or DB_CACHE_SIZE in 9i) to fit your TESTSERVER environment

Oralce Cloning - 3 Articles

Page | 13 -

12/31/07
Your init.ora file is now ready for use. * Copy all the datafiles from your production database to the test server. These files may be from a hot, cold or RMAN backup. You can place the datafiles wherever you want. They do not have to be in the same directory structure as on the production server. Also copy all the archivelogs from the production database to the test server to some backup directory (say /home/oracle/backup). DO NOT copy the controlfiles and the redo logfiles. These will be newly created. If you have tempfiles (check v$tempfile), you can copy the tempfiles to the TESTSERVER although they will not be used duing recovery. After recovery, we can make them a part of our new database. You will need the current redo log, though, since your current transactions are stored in this logfile and Oracle will need it to recover completely. Even if you archive the current redo log and try to use it, Oracle will ask you for the next logfile during recovery (unless you do an incomplete recovery UNTIL CANCEL, UNTIL TIME or UNTIL SCN). Find your current redo log with this query SQL> select f.group# "GROUP", f.member, g.status group_status, 2 g.sequence#, g.archived arc 3 from v$logfile f, v$log g where f.group#=g.group#; GROUP MEMBER GROUP_STATUS SEQUENCE# ARC ---------- ------------------------------------------------------- ---------- --1 /u03/oracle/oradata/prod/redo01a.log INACTIVE 521 YES 2 /u04/oracle/oradata/prod/redo02a.log INACTIVE 522 YES 3 /u05/oracle/oradata/prod/redo03a.log CURRENT 523 NO Copy the CURRENT logfile (redo03a.log in our case) from PRODSERVER into the backup directory containing the archivelogs on TESTSERVER. We will use this during the last step of our recovery. * On your production machine, PRODSERVER, log in to the PROD database and create a text copy of the controlfile. We will use this to recreate the controlfile on the test machine. The following ALTER DATABASE command will create a SQL script with the CREATE CONTROLFILE statement in your USER_DUMP_DEST directory. [oracle@prodserver] $ sqlplus "sys as sysdba" SQL> alter database backup controlfile to trace; [oracle@prodserver] $ cd $ORACLE_BASE/admin/prod/udump [oracle@prodserver] $ ls -lrt -rw-r----1 oracle dba 831484 Sep 8 13:01 ora_4463.trc -rw-r----1 oracle dba 410412 Dec 29 08:58 ora_32183.trc -rw-r----1 oracle dba 410450 Dec 29

Oralce Cloning - 3 Articles

Page | 14 -

12/31/07
08:58 ora_32182.trc -rw-r----1 oracle 08:58 ora_32179.trc -rw-r----1 oracle 11:02 ora_32108.trc dba dba 410384 Dec 29 2331 Jan 6

Article 4
http://www.sap-img.com/oracle-database/cloning-database-from-hotbackup.htm

Cloning Database From Hot Backup


To clone a db on another machine from hot backup, follow these steps: 1. Install Oracle server on new machine 2. Create directories, initfile, etc for the copy database on second server 3. Add database name to tnsnames.ora, listener.ora on second server 4. Create database service with ORADIM (if OS is Windows) 5. On original OPEN db: ALTER DATABASE BACKUP CONTROL FILE TO TRACE RESETLOGS; 6. Rename trace file to create_control.sql, edited, contents are as follows: STARTUP NOMOUNT CREATE CONTROLFILE SET DATABASE "<SID>" RESETLOGS ARCHIVELOG ... ... ; 7. Then do:

Oralce Cloning - 3 Articles

Page | 15 -

12/31/07
ALTER SYSTEM ARCHIVE LOG CURRENT; 8. Copy the ORADATA dirctory including archived logs to second server 9. Go to second server, set SID, and use sqlplus to connect as SYSDBA 10. Delete the control files already copied over using OS commands 11. Run the CREATE CONTROL file script shown above 12. Issue: RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL; --------------------------------------------------------------------------------------------------If you have 9i then use RMAN to create a duplicate the database. Create the necessary folders, init.ora, password file, etc. I am using the DB_FILE_NAME_CONVERT and LOG_FILE_NAME_CONVERT parameters in the init.ora file for the clone database: Example: -- INIT.ORA NAME_CONVERT parameters. db_file_name_convert = ('/DATA/ORACLE/ORADATA/HOMEBD', '/DATA/ORACLE/ORADATA/CLNE') log_file_name_convert = ('/DATA/ORACLE/ORADATA/HOMEDB', '/DATA/ORACLE/ORADATA/CLNE') Then use one of these RMAN scripts ( if you want or don't want to change the SID): -- RMAN script without SET NEWNAME run { set until logseq 18 thread 1; allocate auxiliary channel d1 type disk; duplicate target database to CLNE logfile '/data/oracle/oradata/clne/redo01.log' size 100M, '/data/oracle/oradata/clne/redo02.log' size 100M, '/data/oracle/oradata/clne/redo03.log' size 100M;

Oralce Cloning - 3 Articles

Page | 16 -

12/31/07
} -- RMAN script with SET NEWNAME run { set newname for datafile 1 to '/data/oracle/oradata/clne/system01.dbf'; set newname for datafile 2 to '/data/oracle/oradata/clne/undotbs01.dbf'; set newname for datafile 3 to '/data/oracle/oradata/clne/cwmlite01.dbf'; set newname for datafile 4 to '/data/oracle/oradata/clne/drsys01.dbf'; set newname for datafile 5 to '/data/oracle/oradata/clne/example01.dbf'; set newname for datafile 6 to '/data/oracle/oradata/clne/indx01.dbf'; set newname for datafile 7 to '/data/oracle/oradata/clne/tools01.dbf'; set newname for datafile 8 to '/data/oracle/oradata/clne/users01.dbf'; set until logseq 18 thread 1; allocate auxiliary channel d1 type disk; duplicate target database to CLNE logfile '/data/oracle/oradata/clne/redo01.log' size 100M, '/data/oracle/oradata/clne/redo02.log' size 100M, '/data/oracle/oradata/clne/redo03.log' size 100M; }

Anda mungkin juga menyukai