Export Files più grandi di 2GB con split
by Mariano Pollio, Database Administrator

Nel caso in cui stiamo di fronte ad un database molto grande, in ambiente Unix, è possibile utilizzare la compressione del datafile sia in export che in import del database, limitando anche la grandezza del file di export sotto i 2Giga..


Verificare che la variabile d'ambiente ORACLE_SID sia settata in modo corretto. Sia tramite comando unix e sia tramite collegamento a sqlplus. (su unix echo $ORACLE_DBSID)
sqlplus  /nolog                                                  

SQL*Plus: Release 10.2.0.4.0 - Production on Tue March 20 11:26:23 2008

Copyright (c) 1982, 2007, Oracle.  All Rights Reserved.

SQL> connect sys/sys as sysdba

SQL> select name from v$database;
 
  NAME
  ---------------------------------------
  DBSID

Verificare la grandezza dell'export che si andrebbe a produrre.

  
SQL> select tablespace_name, sum(bytes)/1024/1024 from dba_segments
     where owner in ( 'USER' , 'SYSTEM' )
     and segment_type != 'INDEX'
group by tablespace_name;

TABLESPACE_NAME                SUM(BYTES)/1024/1024
------------------------------ --------------------
USER_DATA                                 6966.7676 - circa 7Giga
SYSTEM                                      12.1875
 
 


Esempio: (Usando Compress e Split file)

Export
#!/bin/ksh
 
# +-------------------------------------------------------+
# | Posizionarsi nella directory dove eseguire l'export.  |
# +-------------------------------------------------------+
cd /filesystem/DB/export
pwd
 
# +-------------------------------------------------------+
# | Rimuovere le pipe ( se esistenti )                    |
# +-------------------------------------------------------+
rm -f pipeCompress
rm -f pipeExp
 
# +-------------------------------------------------------+
# | Creare con comando unix due pipe per split e Compress |
# +-------------------------------------------------------+
mknod pipeCompress p
mknod pipeExp p
chmod 666 pipeExp pipeCompress
 
# +-------------------------------------------------------+
# | Attiva lo Split e Compress in backgroud               |
# +-------------------------------------------------------+
nohup split -b 1024m < pipeExp &
nohup compress < pipeCompress > pipeExp &
 
# +-------------------------------------------------------+
# | Esegui l'export su pipe.                              |
# +-------------------------------------------------------+
exp userid=system/manager file=pipeCompress full=yes log=exportDBSID.log
 
# +-------------------------------------------------------+
# | Rimuovere le pipe.                                    |
# +-------------------------------------------------------+
rm -f pipeCompress
rm -f pipeExp
Import
#!/bin/ksh
# +-------------------------------------------------------+
# | Posizionarsi nella directory dove eseguire l'export.  |
# +-------------------------------------------------------+
cd /filesystem/DB/export
pwd
 
# +-------------------------------------------------------+
# | Rimuovere la pipe ( se esistente )                    |
# +-------------------------------------------------------+
rm -f pipeImp
 
# +-------------------------------------------------------+
# | Creare con comando unix due pipe per split e compress |
# +-------------------------------------------------------+
mknod pipeImp p
chmod 666 pipeImp
 
# +-------------------------------------------------------+
# | Attiva l'Uncompress in backgroud                      |
# | Lo split è dato da xaa...xac                          |
# +-------------------------------------------------------+
nohup cat xaa xab xac | uncompress - > pipeImp &

# +-------------------------------------------------------+
# | Si attiva l'import sulla pipe dello split             |
# +-------------------------------------------------------+
 imp userid=system/manager file=pipeImp full=yes ignore=yes log=importDBSID.log
 
# +-------------------------------------------------------+
# | Rimuovere la pipe                                     |
# +-------------------------------------------------------+
rm -f pipeImp



Esempio: (Usando solo lo Split)

Export
#!/bin/ksh
 
# +-------------------------------------------------------+
# | Posizionarsi nella directory dove eseguire l'export.  |
# +-------------------------------------------------------+
cd /filesystem/DB/export
pwd
 
# +-------------------------------------------------------+
# | Rimuovere la pipe ( se esistente )                    |
# +-------------------------------------------------------+
rm -f pipeExp
 
# +-------------------------------------------------------+
# | Creare con comando unix pipe per lo  split            |
# +-------------------------------------------------------+
mknod pipeExp p
chmod 666 pipeExp
 
# +-------------------------------------------------------+
# | Start the Split backgroud process.                    |
# +-------------------------------------------------------+
nohup split -b 1024m < pipeExp &
 
# +-------------------------------------------------------+
# | Finally, start the export to the pipe.|
# +-------------------------------------------------------+
exp userid=system/manager file=pipeExp full=yes log=exportDBSID.log
 
# +-------------------------------------------------------+
# | Remove the pipe.                                      |
# +-------------------------------------------------------+
rm -f pipeExp
Import
#!/bin/ksh
# +-------------------------------------------------------+
# | Posizionarsi nella directory dove eseguire l'export.  |
# +-------------------------------------------------------+
cd /filesystem/DB/export
pwd
 
# +-------------------------------------------------------+
# | Rimuovere la pipe ( se esistente )                    |
# +-------------------------------------------------------+
rm -f pipeImp
 
# +-------------------------------------------------------+
# | Creare con comando unix pipe per lo split             |
# +-------------------------------------------------------+
mknod pipeImp p
chmod 666 pipeImp
 
# +-------------------------------------------------------+
# | Attivo l'Uncompress in backgroud                      |
# | Lo split dell'export è dato dai files xaa...xac       |
# +-------------------------------------------------------+
nohup cat xaa xab xac > pipeImp &

# +-------------------------------------------------------+
# | Si attiva l'import sulla pipe dello split             |
# +-------------------------------------------------------+
imp userid=system/manager file=pipeImp full=yes ignore=yes log=importDBSID.log
 
# +-------------------------------------------------------+
# | Cancellazione la pipe.                                |
# +-------------------------------------------------------+
rm -f pipeImp



Esempio: (Usando solo la Compress)

Export
#!/bin/ksh
 
# +-------------------------------------------------------+
# | Posizionarsi nella directory dove esguire l'export.   |
# +-------------------------------------------------------+
cd /filesystem/DB/export
pwd
 
# +-------------------------------------------------------+
# | Rimuovere la pipe ( se esistente )                    |
# +-------------------------------------------------------+
rm -f pipeExp
 
# +-------------------------------------------------------+
# | Creare con comando unix pipe per gzip                 |
# +-------------------------------------------------------+
mknod pipeExp p
chmod 666 pipeExp
 
# +-------------------------------------------------------+
# | Eseguire il processo in background di compressione 9  |
# +-------------------------------------------------------+
nohup cat pipeExp | gzip -9 > expdat.dmp.gz &
 
# +-------------------------------------------------------+
# | Esegui il comando per fare l'export del database      |
# +-------------------------------------------------------+
exp userid=system/manager file=pipeExp full=yes log=exportDBSID.log
 
# +-------------------------------------------------------+
# | Rimuovere la pipe.                                    |
# +-------------------------------------------------------+
rm -f pipeExp
Import
#!/bin/ksh
# +-------------------------------------------------------+
# | Posizionarsi nella directory dove esguire l'export.   |
# +-------------------------------------------------------+
cd /filesystem/DB/export
pwd
 
# +-------------------------------------------------------+
# | Rimuovere la pipe ( se esistente )                    |
# +-------------------------------------------------------+
rm -f pipeImp
 
# +-------------------------------------------------------+
# | Creare con comando unix pipe per gzip                 |
# +-------------------------------------------------------+
mknod pipeImp p
chmod 666 pipeImp
 
# +-------------------------------------------------------+
# | Attiva gunzip in backgroud                            |
# | Lo split dell'export è dato dai files xaa...xac       |
# +-------------------------------------------------------+
nohup gunzip -c expdat.dmp.gz > pipeImp &
 
imp userid=system/manager file=pipeImp full=yes ignore=yes log=importDBSID.log
 
# +-------------------------------------------------------+
# | Rimuovere la pipe.                                    |
# +-------------------------------------------------------+
rm -f pipeImp