Exporting on Unix Systems [ID 1018477.6]

msdnchina發表於2011-09-14
修改時間 17-APR-2009 型別 BULLETIN 狀態 PUBLISHED


PURPOSE 
The basic function of the export utility is to extract the objects of a 
database and locate them in a flat file that is usually on tape or on disk.  
The process for exporting to tape is explained in this bulletin. 
 
SCOPE & APPLICATION
Informative

SEARCH WORDS
2 gig limit

This bulletin examines several considerations and steps for exporting data to 
tape on unix platforms either directly or using a unix named pipe.  Several 
items are covered including: 
 
It will discuss in detail the following considerations: 
 
        o Why do you need to export to tape? 
        o How do you calculate the size of your export? 
        o Exporting directly to tape.  (An example is provided.) 
        o How do you export to tape via unix named pipes? 
        o How do you create a compressed export file? 
        o How do you export to a remote tape device? 
        o How do you perform export/import over the network using named  
          pipes? 
 
 
============================================================================== 
============================================================================== 
 
 
o Why do you need to export to a tape ? 
 
        Export to tape is not a preferred practice, but it may be necessary 
        for the following reasons: 
 
        o  Lack of disk space  - you do not have enough disk space to perform 
           the export to a disk. 
  
        o  If your export file will be greater than 2 Gigabytes - There is a 
           unix restriction of 2G on the size of a file. 
 
 
----------------------------------------------------------------------------- 
 
o How to calculate the size of your export? 
 
  
        If the site is unsure how large a resultant export file will be, they 
        can use the following commands to calculate its size: 
  
        (1) Create a unix named pipe:    
  
            % mknod /tmp/exp_pipe p 
  
        (2) Start the export in the background, specifying the named pipe as 
            the output file: 
 
            % exp file=/tmp/exp_pipe  & 
  
        (3) Next, dd in from the named pipe, out to /dev/null in 1K blocks: 
  
            % dd if=/tmp/exp_pipe of=/dev/null bs=1024 
 
        (4) This will return the size of the export file in 1K blocks as 
            follows: 
 
            +0 records in 
            +0 records out 
 
------------------------------------------------------------------------------ 
 
o  Exporting directly to tape. 
 
  
        Once you have decided that you need to perform the export directly to 
        tape, you will need to change the syntax of your export statement so 
        that export knows the name of the tape device and how much data can be 
        written to that tape device. 
  
        There are only 2 parameters that you need to change to do this: 
  
        -  FILE - The name of the tape device you are exporting to 
           e.g. /dev/rmt/0 . 
  
        -  VOLSIZE - The amount of data that can be written to one tape. 
 
        Considerations: 
  
        -  If the entire export file will fit onto a single tape, then a 
           volsize of 0 (variable length) can be used  
                (e.g. exp  volsize=0) 
        -  If the resultant export file is larger than a single tape, then 
           volsize needs to be set accordingly  
                (e.g. exp  volsize=M) 
 
           Please note, there is a 4 Gigabyte limit to the volsize parameter. 
 
        ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
  
                  AN EXAMPLE OF EXPORTING DIRECTLY TO TAPE 
 
        ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 
 
 - This example involves a full database export to a QIC 150 (150 Megabytes    
  capacity) to a tape device "/dev/rmt/0m", where the resultant file is        
 200M.    
   The following syntax is used: 
 
        (1) os> exp userid=scott/tiger full=y file=/dev/rmt/0M volsize=145M 
  
 - You will note that the volsize is set to 145M, even though the tape is a    
  QIC 150.  This is because there may not be exactly 150M of tape on the       
 volume. 
 
 - Once the export utility has written  to the tape, it will 
   prompt for the next tape: 
        (2) "Please mount the next volume and press  when you are done." 
  
 - To import from the resultant export on tape, the following commands 
   are used : 
 
        (3) os> imp userid=scott/tiger full=y file=/dev/rmt/0M volsize=145M 
 
------------------------------------------------------------------------------ 
  
o How do you export to tape via unix named pipes? 
 
On some Oracle platforms/versions there may be difficulties with exporting 
directly to tape using the Oracle export utility.  In these cases, you may 
need to perform the export to tape via unix named pipes. 
 
A unix named pipe is a FIFO special file, created using the unix mknod 
command.  The syntax of the mknod command may change from port to port.  It is 
important, therefore, that you consult your systems manual. 
 
Please note: Exporting via a named pipe (to tape or disk), is slower 
than using export directly.  This is because of the size limit   
of a unix named pipe (usually 8K). 
 
  
 - The following commands should be used to export to tape via a named pipe: 
  
        1. Create a unix named pipe : 
  
                os> mknod /tmp/exp_pipe p 
  
        2. Next, dd in from the named pipe, out to the tape device, in the 
                   background : 
  
                os> dd if=/tmp/exp_pipe of= & 
  
        3. Start the export, specifying the named pipe as the output file: 
 
                os> exp file=/tmp/exp_pipe  
 
  
 - To import from the resultant export on tape, the following commands 
   are used : 
  
        1. Create a unix named pipe : 
 
                os> mknod /tmp/imp_pipe p 
 
        2. Next, dd in from the tape device, out to the named pipe, in the 
           background : 
  
                os> dd if= of=/tmp/imp_pipe & 
  
        3. Start the import, specifying the named pipe as the input file : 
 
                os> imp file=/tmp/imp_pipe  
 
------------------------------------------------------------------------------ 
  
  
o How do you create a compressed export file? 
 
 
If you have calculated the size of the file your export will produce and 
it is too large to fit onto disk, you may want to consider producing a 
compressed export file as an alternative to exporting directly to tape. 
 
Please note, this method should be thoroughly tested before being implemented. 
 
- To create a compressed export file: 
  
        1. Create a unix named pipe : 
  
                os> mknod /tmp/exp_pipe p 
  
        2. Start compress in the background reading in from the named pipe, 
           writing out to 'export.dmp.Z' : 
  
                os> compress < /tmp/exp_pipe > export.dmp.Z & 
  
        3. Start the export, specifying the named pipe as the output file : 
  
                os> exp file=/tmp/exp_pipe  
  
- To import to disk from the resultant export on tape, the following commands 
  would be used : 
 
        1. Create a unix named pipe : 
  
                os> mknod /tmp/imp_pipe p 
 
        2. Start uncompress in the background reading from 'export.dmp.Z', 
           writing out to the named pipe : 
 
                os> uncompress < export.dmp.Z > /tmp/imp_pipe & 
 
        3. Start the import, specifying the named pipe as the input file : 
 
                os> imp file=/tmp/imp_pipe  
 
        Please Note: 
        ============ 
 
        You cannot export directly to tape and compress.  
 
 
         
------------------------------------------------------------------------------  
  
o How do you export to a remote tape device? 
 
 
You may want to perform an export directly to tape but you do not 
have a local tape drive on your machine. There is, however, a tape drive 
on another machine on the network, to which you have remote shell (rsh) 
access.  
  
 - The following commands allow you to perform the export to the remote 
   machine, either to file or to a tape device : 
  
        1. Create a unix named pipe : 
  
                os> mknod /tmp/exp_pipe p 
  
        2. Next, dd in from the named pipe, and out to the remote tape device 
           via a remote shell : 
  
                os> dd if=/tmp/exp_pipe | rsh  dd of= & 
  
        3. Start the export, specifying named pipe as the output file : 
  
                os> exp file=/tmp/exp_pipe  
  
 - To import from the resultant export on tape, the following commands 
   would be used : 
  
        1. Create a unix named pipe : 
 
                os> mknod /tmp/imp_pipe p 
 
        2. Start a remote shell, in the background  that dd's from the remote 
           tape, piping to the local named pipe : 
 
                os> rsh  dd if= | dd 
                                   if=/tmp/imp_pipe & 
  
        3. Start the import, specifying the named pipe as the input file : 
                os> imp file=/tmp/imp_pipe  
  
------------------------------------------------------------------------------ 
 
o How do you perform import/export over the network using named pipes?  
 
---------- 
 - Host 1: 
---------- 
        *  mknod -p /dev/FIFO.dmp 
        *  exp u/p FILE=/dev/FIFO.dmp   yada, yada, yada... 
----------  
- Host 2: 
---------- 
        * mknod -p /dev/FIFO2.dmp 
        * rsh host1 dd if=/dev/FIFO.dmp > /dev/FIFO2.dmp  & 
        * imp u/p FILE=/dev/FIFO2.dmp yada, yada, yada... 
 
  
Please note: 
 
It is important that you verify that the named pipe is ready on each side 
before you start the process. 
  
 
================================= 
Additional information 
================================= 
Oracle does not recommend use of Named Pipe. It may create corrupted dumps. 
Oracle10g Datapump does not support named pipe as per Note 463336.1  
 
For more information on the RDBMS export/import utility: 
 
        * Oracle7 Server Utility User's Guide, Part 1
[@more@]

來自 “ ITPUB部落格 ” ,連結:http://blog.itpub.net/161195/viewspace-1055068/,如需轉載,請註明出處,否則將追究法律責任。

相關文章