Top Banner
http://www.oracle- base.com Clonedb: The quick and easy Clonedb: The quick and easy cloning solution you never knew cloning solution you never knew you had. you had. Tim Hall Tim Hall Oracle ACE Director Oracle ACE Director Oracle ACE of the Year 2006 Oracle ACE of the Year 2006 OakTable Network OakTable Network OCP DBA (7, 8, 8i, 9i, 10g, 11g) OCP DBA (7, 8, 8i, 9i, 10g, 11g) OCP Advanced PL/SQL Developer OCP Advanced PL/SQL Developer Oracle Database: SQL Certified Expert Oracle Database: SQL Certified Expert http://www.oracle-base.com Books Books Oracle PL/SQL Tuning Oracle PL/SQL Tuning Oracle Job Scheduling Oracle Job Scheduling
23

Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Dec 24, 2015

Download

Documents

Beryl Barton
Welcome message from author
This document is posted to help you gain knowledge. Please leave a comment to let me know what you think about it! Share it to your friends and learn new things together.
Transcript
Page 1: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

http://www.oracle-base.com

Clonedb: The quick and easy cloning Clonedb: The quick and easy cloning solution you never knew you had.solution you never knew you had.

Tim HallTim Hall

Oracle ACE DirectorOracle ACE Director

Oracle ACE of the Year 2006Oracle ACE of the Year 2006

OakTable NetworkOakTable NetworkOCP DBA (7, 8, 8i, 9i, 10g, 11g)OCP DBA (7, 8, 8i, 9i, 10g, 11g)

OCP Advanced PL/SQL DeveloperOCP Advanced PL/SQL Developer

Oracle Database: SQL Certified ExpertOracle Database: SQL Certified Expert

http://www.oracle-base.com

BooksBooksOracle PL/SQL TuningOracle PL/SQL TuningOracle Job SchedulingOracle Job Scheduling

Page 2: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

http://www.oracle-base.com

• What is a clone?What is a clone?

• Why clone databases?Why clone databases?

• How do we clone databases?How do we clone databases?

• What is Clonedb?What is Clonedb?

• Demo of ClonedbDemo of Clonedb

• ConsiderationsConsiderations

Clonedb: The quick and easy cloning Clonedb: The quick and easy cloning solution you never knew you had.solution you never knew you had.

Page 3: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

What is a Clone?What is a Clone?

http://www.oracle-base.com

• An exact copy of the original.An exact copy of the original.

Page 4: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Why Clone Databases?Why Clone Databases?

http://www.oracle-base.com

• Set up new databases as copies of existing ones.Set up new databases as copies of existing ones.

• Data refresh for development and test environments Data refresh for development and test environments from production.from production.

• Test backup & recovery.Test backup & recovery.

• Create standby databases.Create standby databases.

• Recover lost data or objectsRecover lost data or objects(where flashback is not(where flashback is notappropriate).appropriate).

Page 5: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

How do we Clone Databases?How do we Clone Databases?

http://www.oracle-base.com

• There are already several methods for cloning There are already several methods for cloning databases including:databases including:– Manually copy files and recreate the database.Manually copy files and recreate the database.

– RMAN DUPLICATE - active database (11g).RMAN DUPLICATE - active database (11g).

– RMAN DUPLICATE - backup.RMAN DUPLICATE - backup.

– 33rdrd Party solutions. Party solutions.

• All require copying or restoring filesAll require copying or restoring filesto new location requiring:to new location requiring:– Additional disk space.Additional disk space.

– Time to perform the copy.Time to perform the copy.

• Clonedb makes cloning quicker and saves space.Clonedb makes cloning quicker and saves space.

Page 6: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

What is Clonedb?What is Clonedb?

http://www.oracle-base.com

• In 11.1 Oracle added the Direct NFS Client to the In 11.1 Oracle added the Direct NFS Client to the database.database.

• The 11.2.0.2 patch set introduced Clonedb The 11.2.0.2 patch set introduced Clonedb functionality, built on top of Direct NFS.functionality, built on top of Direct NFS.

• Clonedb uses Copy-On-Write (COW)Clonedb uses Copy-On-Write (COW)technology for clones.technology for clones.

Page 7: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Copy-On-Write (COW)Copy-On-Write (COW)

http://www.oracle-base.com

DatafileDatafileImageImageCopiesCopies

CloneCloneDatabaseDatabase

NFSNFSC.O.W.C.O.W.FilesFiles

NFSNFSC.O.W.C.O.W.FilesFiles

CloneCloneDatabaseDatabase

NFSNFSC.O.W.C.O.W.FilesFiles

NFSNFSC.O.W.C.O.W.FilesFiles

• Clones use read-only image copies of datafiles as Clones use read-only image copies of datafiles as source.source.

• Only modified blocks are written to NFS location. Only modified blocks are written to NFS location.

Page 8: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

What is Clonedb? (continued)What is Clonedb? (continued)

http://www.oracle-base.com

• Clonedb saves space when you have multiple clones Clonedb saves space when you have multiple clones as they can all reference the same source files.as they can all reference the same source files.

• One-time server setup, then repeatedOne-time server setup, then repeatedcloning is super-quick.cloning is super-quick.

• Only documented in Only documented in My Oracle Support (MOS)My Oracle Support (MOS)Note 1210656.1Note 1210656.1

Page 9: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

DemoDemo

http://www.oracle-base.com

(cleanup.sql)

Page 10: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

NFS Server SetupNFS Server Setup

http://www.oracle-base.com

• Create a directory to hold the copy-on-write files.Create a directory to hold the copy-on-write files.

# mkdir -p /u01/nfs-share# mkdir -p /u01/nfs-share

• Append the share into the “/etc/exports” file.Append the share into the “/etc/exports” file.

/u01/nfs-share/u01/nfs-share *(rw,sync,no_wdelay,insecure, *(rw,sync,no_wdelay,insecure, insecure_locks,no_root_squash) insecure_locks,no_root_squash)

• Make sure the NFS service is turned on.Make sure the NFS service is turned on.

# chkconfig nfs on# chkconfig nfs on# service nfs restart# service nfs restart

Page 11: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Production BackupProduction Backup

• Make an image copy backup of the database. The Make an image copy backup of the database. The copy can be placed on a share (CIFS/NFS) or copied copy can be placed on a share (CIFS/NFS) or copied to the local file system of the server running the to the local file system of the server running the clone.clone.

configure controlfile autobackup off;configure controlfile autobackup off;sql 'alter database begin backup';sql 'alter database begin backup';run {run { set nocfau; set nocfau; backup as copy database backup as copy database format ’/u01/backups/prod/%U’; format ’/u01/backups/prod/%U’;}}sql 'alter database end backup';sql 'alter database end backup';

((backup.sh))

http://www.oracle-base.com

Page 12: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Copy Production PFILECopy Production PFILE

http://www.oracle-base.com

• Take a copy of the production PFILE by running the Take a copy of the production PFILE by running the following command as the SYS user.following command as the SYS user.((create_pfile.sh)

CREATE PFILE='/u01/backups/prod/initTEST.ora' FROM SPFILE;CREATE PFILE='/u01/backups/prod/initTEST.ora' FROM SPFILE;

• Edit the PFILE, changing allEdit the PFILE, changing allreferences to the original SIDreferences to the original SIDand database name.and database name.

Page 13: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Clonedb Server SetupClonedb Server Setup

http://www.oracle-base.com

• Turn on Direct NFS for the ORACLE_HOME on the Turn on Direct NFS for the ORACLE_HOME on the clonedb server.clonedb server.((dnfs.sh))

$$ cd $ORACLE_HOME/rdbms/libcd $ORACLE_HOME/rdbms/lib$ make -f ins_rdbms.mk dnfs_on$ make -f ins_rdbms.mk dnfs_on

• Make the necessary directoriesMake the necessary directoriesfor the NFS mount and tofor the NFS mount and tosupport the instance.support the instance.((directories.sh))

Page 14: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

NFS MountNFS Mount

http://www.oracle-base.com

• Add the NFS mount to the “/etc/fstab” file, along with Add the NFS mount to the “/etc/fstab” file, along with any other necessary shares.any other necessary shares.

nas1:/u01/nfs-share /u01/copy-on-write nas1:/u01/nfs-share /u01/copy-on-write nfs rw,bg,hard,nointr,tcp,vers=3,timeo=600, nfs rw,bg,hard,nointr,tcp,vers=3,timeo=600, rsize=32768,wsize=32768,actimeo=0 0 0 rsize=32768,wsize=32768,actimeo=0 0 0

• Mount the copy-on-write location.Mount the copy-on-write location.

# mount /u01/copy-on-write# mount /u01/copy-on-write

Page 15: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Clone the databaseClone the database

http://www.oracle-base.com

• Set the required environment variables and run the Set the required environment variables and run the “clone.pl” script.“clone.pl” script.(create_clone_script.sh)(create_clone_script.sh)

• Review the contents of theReview the contents of thegenerated files.generated files.

• Run the files to create the clone.Run the files to create the clone.(create_clone.sh)(create_clone.sh)

Page 16: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Clone the databaseClone the database

http://www.oracle-base.com

• If you did hot backup you may need to recover If you did hot backup you may need to recover database.database.

SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL;SQL> ALTER DATABASE OPEN RESETLOGS;SQL> ALTER DATABASE OPEN RESETLOGS;

• Make sure the TEMP tablespaceMake sure the TEMP tablespacehas been handled properly.has been handled properly.(manage_temp.sql)(manage_temp.sql)

• Check the database.Check the database.(datafiles.sql)(datafiles.sql)

Page 17: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Considerations - PerformanceConsiderations - Performance

http://www.oracle-base.com

• Copy-On-Write location is NFS. Is that an issue for Copy-On-Write location is NFS. Is that an issue for you?you?

• If a cloned database is to be usedIf a cloned database is to be usedfor performance testing, do youfor performance testing, do youreally want a different storagereally want a different storagetechnology in the mix?technology in the mix?

• Possible performancePossible performanceimprovements on the horizon?improvements on the horizon?

Page 18: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Considerations - Space SavingsConsiderations - Space Savings

http://www.oracle-base.com

• Over time more changed blocks will be written to Over time more changed blocks will be written to NFS location, so space savings will reduce.NFS location, so space savings will reduce.

• Only works with image copies.Only works with image copies.If you don’t use image copyIf you don’t use image copybackups how much space are youbackups how much space are youreally saving?really saving?

Page 19: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Considerations - OthersConsiderations - Others

http://www.oracle-base.com

• Very little documentation.Very little documentation.

• Very new.Very new.

Page 20: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Where would I use it?Where would I use it?

http://www.oracle-base.com

• For short-lived clones used for functional, not For short-lived clones used for functional, not performance testing.performance testing.

• To test backups.To test backups.

• To recover lost objects.To recover lost objects.

Page 21: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

Where would I NOT use it?Where would I NOT use it?

http://www.oracle-base.com

• Setting up long-term clones.Setting up long-term clones.

• For clones used for performance testing.For clones used for performance testing.

• For setting up a standby database.For setting up a standby database.

Page 22: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

SummarySummary

http://www.oracle-base.com

• Very quick cloning.Very quick cloning.

• Potential for big space savings.Potential for big space savings.

• Need to be on at least 11.2.0.2.Need to be on at least 11.2.0.2.

• Need to use NFS for COW location.Need to use NFS for COW location.

Page 23: Http:// Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006.

http://www.oracle-base.com

The End… The End…

• Download slides and example code at:Download slides and example code at:

http://www.oracle-base.com/workshopshttp://www.oracle-base.com/workshops

• Article:Article:

http://www.oracle-base.com/articles/11g/Clonedb_11gR2.phphttp://www.oracle-base.com/articles/11g/Clonedb_11gR2.php