NOTE:

All the videos in this blog are High Definition Videos most with Audio. The videos are best watched in full screen with "HD option enabled". You would also find screenshots and some handy scripts for DBAs.

Monday, December 21, 2009

How to speed up cloning

Usually during clones, we normally tar & gzip source files. Then copy them over to the target and then gunzip & untar it. Using the below method, we can actually avoid the two fold step and do the entire operation in a single step.

eg.
We want to copy the Oracle Home from source to target.

Create the Oracle Home location on target (lxhyd02):
mkdir -p /data/oracle/product/10.2.0/db_1

On the source (lxhyd01):
cd /u01/oracle/product/10.2.0/db_1
tar cf - * | ssh lxhyd02.learning.com '(cd /data/oracle/product/10.2.0/db_1/; tar xf - )'

Check if files are being untarred on target:

[oracle@lxhyd02 data]$ cd /data/oracle/product/10.2.0/db_1
[oracle@lxhyd02 db_1]$ ls -tlr
total 240
drwxr-x--- 3 oracle dba 4096 Oct 25 20:38 jre
drwxr-x--- 7 oracle dba 4096 Oct 25 20:38 javavm
drwxr-x--- 3 oracle dba 4096 Oct 25 20:38 has
drwxr-x--- 3 oracle dba 4096 Oct 25 20:38 diagnostics
drwxr-x--- 3 oracle dba 4096 Oct 25 20:38 demo
drwxr-x--- 6 oracle dba 4096 Oct 25 20:38 crs
drwxr-x--- 4 oracle dba 4096 Oct 25 20:38 clone
drwxr-x--- 7 oracle dba 4096 Oct 25 20:38 assistants
drwxr-x--- 4 oracle dba 4096 Oct 25 20:49 jdbc
.....
.....

Advantages:

1) Faster that the two folds approach
2) Does not require disk space to store the tar/gzip files on source and target. Here, the tar files are created on the fly and immediately untarred on the target.

Limitations:

1) Speed would depend on the network bandwidth.

2 comments:

  1. excellent tip, thanks a lot.

    I believe in Linux you can use -z flag to compress the tar file. like
    tar czf - * | ssh lxhyd02.learning.com '(cd /data/oracle/product/10.2.0/db_1/; tar xzf - )'

    -Siddhu

    ReplyDelete
  2. Yes Siddhu, you are right. That option can also be used to compress it. Thanks for expressing your views.

    -Ritesh

    ReplyDelete