Presentation is loading. Please wait.

Presentation is loading. Please wait.

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

Similar presentations


Presentation on theme: "Clonedb: The quick and easy cloning solution you never knew you had. Tim Hall Oracle ACE Director Oracle ACE of the Year 2006."— Presentation transcript:

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

2 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 solution you never knew you had.

3 What is a Clone? http://www.oracle-base.com An exact copy of the original.An exact copy of the original.

4 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 from production.Data refresh for development and test environments from production. Test backup & recovery.Test backup & recovery. Create standby databases.Create standby databases. Recover lost data or objects (where flashback is not appropriate).Recover lost data or objects (where flashback is not appropriate).

5 How do we Clone Databases? http://www.oracle-base.com There are already several methods for cloning databases including:There are already several methods for cloning databases including: –Manually copy files and recreate the database. –RMAN DUPLICATE - active database (11g). –RMAN DUPLICATE - backup. –3 rd Party solutions. All require copying or restoring files to new location requiring:All require copying or restoring files to new location requiring: –Additional disk space. –Time to perform the copy. Clonedb makes cloning quicker and saves space.Clonedb makes cloning quicker and saves space.

6 What is Clonedb? http://www.oracle-base.com In 11.1 Oracle added the Direct NFS Client to the database.In 11.1 Oracle added the Direct NFS Client to the database. The 11.2.0.2 patch set introduced Clonedb functionality, built on top of Direct NFS.The 11.2.0.2 patch set introduced Clonedb functionality, built on top of Direct NFS. Clonedb uses Copy-On-Write (COW) technology for clones.Clonedb uses Copy-On-Write (COW) technology for clones.

7 Copy-On-Write (COW) http://www.oracle-base.com DatafileImageCopiesDatafileImageCopies CloneDatabaseCloneDatabase NFSC.O.W.FilesNFSC.O.W.Files CloneDatabaseCloneDatabase NFSC.O.W.FilesNFSC.O.W.Files Clones use read-only image copies of datafiles as source.Clones use read-only image copies of datafiles as source. Only modified blocks are written to NFS location.Only modified blocks are written to NFS location.

8 What is Clonedb? (continued) http://www.oracle-base.com Clonedb saves space when you have multiple clones as they can all reference the same source files.Clonedb saves space when you have multiple clones as they can all reference the same source files. One-time server setup, then repeated cloning is super-quick.One-time server setup, then repeated cloning is super-quick. Only documented in My Oracle Support (MOS) Note 1210656.1Only documented in My Oracle Support (MOS) Note 1210656.1

9 Demo http://www.oracle-base.com (cleanup.sql)cleanup.sql

10 NFS Server Setup http://www.oracle-base.com Create a directory to hold the copy-on-write files. # mkdir -p /u01/nfs-shareCreate a directory to hold the copy-on-write files. # mkdir -p /u01/nfs-share Append the share into the “/etc/exports” file. /u01/nfs-share *(rw,sync,no_wdelay,insecure, insecure_locks,no_root_squash)Append the share into the “/etc/exports” file. /u01/nfs-share *(rw,sync,no_wdelay,insecure, insecure_locks,no_root_squash) Make sure the NFS service is turned on. # chkconfig nfs on # service nfs restartMake sure the NFS service is turned on. # chkconfig nfs on # service nfs restart

11 Production Backup Make an image copy backup of the database. The copy can be placed on a share (CIFS/NFS) or copied to the local file system of the server running the clone. configure controlfile autobackup off; sql 'alter database begin backup'; run { set nocfau; backup as copy database format ’/u01/backups/prod/%U’; } sql 'alter database end backup'; ( backup.sh)Make an image copy backup of the database. The copy can be placed on a share (CIFS/NFS) or copied to the local file system of the server running the clone. configure controlfile autobackup off; sql 'alter database begin backup'; run { set nocfau; backup as copy database format ’/u01/backups/prod/%U’; } sql 'alter database end backup'; ( backup.sh) backup.sh http://www.oracle-base.com

12 Copy Production PFILE http://www.oracle-base.com Take a copy of the production PFILE by running the following command as the SYS user. (create_pfile.sh) CREATE PFILE='/u01/backups/prod/initTEST.ora' FROM SPFILE;Take a copy of the production PFILE by running the following command as the SYS user. (create_pfile.sh) CREATE PFILE='/u01/backups/prod/initTEST.ora' FROM SPFILE;create_pfile.sh Edit the PFILE, changing all references to the original SID and database name.Edit the PFILE, changing all references to the original SID and database name.

13 Clonedb Server Setup http://www.oracle-base.com Turn on Direct NFS for the ORACLE_HOME on the clonedb server. ( dnfs.sh) $ cd $ORACLE_HOME/rdbms/lib $ make -f ins_rdbms.mk dnfs_onTurn on Direct NFS for the ORACLE_HOME on the clonedb server. ( dnfs.sh) $ cd $ORACLE_HOME/rdbms/lib $ make -f ins_rdbms.mk dnfs_on dnfs.sh Make the necessary directories for the NFS mount and to support the instance. (directories.sh)Make the necessary directories for the NFS mount and to support the instance. (directories.sh)directories.sh

14 NFS Mount http://www.oracle-base.com Add the NFS mount to the “/etc/fstab” file, along with any other necessary shares. nas1:/u01/nfs-share /u01/copy-on-write nfs rw,bg,hard,nointr,tcp,vers=3,timeo=600, rsize=32768,wsize=32768,actimeo=0 0 0Add the NFS mount to the “/etc/fstab” file, along with any other necessary shares. nas1:/u01/nfs-share /u01/copy-on-write nfs rw,bg,hard,nointr,tcp,vers=3,timeo=600, rsize=32768,wsize=32768,actimeo=0 0 0 Mount the copy-on-write location. # mount /u01/copy-on-writeMount the copy-on-write location. # mount /u01/copy-on-write

15 Clone the database http://www.oracle-base.com Set the required environment variables and run the “clone.pl” script. (create_clone_script.sh)Set the required environment variables and run the “clone.pl” script. (create_clone_script.sh)create_clone_script.sh Review the contents of the generated files.Review the contents of the generated files. Run the files to create the clone. (create_clone.sh)Run the files to create the clone. (create_clone.sh)create_clone.sh

16 Clone the database http://www.oracle-base.com If you did hot backup you may need to recover database. SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL; SQL> ALTER DATABASE OPEN RESETLOGS;If you did hot backup you may need to recover database. SQL> RECOVER DATABASE USING BACKUP CONTROLFILE UNTIL CANCEL; SQL> ALTER DATABASE OPEN RESETLOGS; Make sure the TEMP tablespace has been handled properly. (manage_temp.sql)Make sure the TEMP tablespace has been handled properly. (manage_temp.sql)manage_temp.sql Check the database. (datafiles.sql)Check the database. (datafiles.sql)datafiles.sql

17 Considerations - Performance http://www.oracle-base.com Copy-On-Write location is NFS. Is that an issue for you?Copy-On-Write location is NFS. Is that an issue for you? If a cloned database is to be used for performance testing, do you really want a different storage technology in the mix?If a cloned database is to be used for performance testing, do you really want a different storage technology in the mix? Possible performance improvements on the horizon?Possible performance improvements on the horizon?

18 Considerations - Space Savings http://www.oracle-base.com Over time more changed blocks will be written to NFS location, so space savings will reduce.Over time more changed blocks will be written to NFS location, so space savings will reduce. Only works with image copies. If you don’t use image copy backups how much space are you really saving?Only works with image copies. If you don’t use image copy backups how much space are you really saving?

19 Considerations - Others http://www.oracle-base.com Very little documentation.Very little documentation. Very new.Very new.

20 Where would I use it? http://www.oracle-base.com For short-lived clones used for functional, not performance testing.For short-lived clones used for functional, not performance testing. To test backups.To test backups. To recover lost objects.To recover lost objects.

21 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.

22 Summary 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.

23 http://www.oracle-base.com The End… Download slides and example code at: http://www.oracle-base.com/workshopsDownload slides and example code at: http://www.oracle-base.com/workshops http://www.oracle-base.com/workshops Article: http://www.oracle-base.com/articles/11g/Clonedb_11gR2.phpArticle: http://www.oracle-base.com/articles/11g/Clonedb_11gR2.php http://www.oracle-base.com/articles/11g/Clonedb_11gR2.php


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

Similar presentations


Ads by Google