제목: How to Relink Oracle Database Software on UNIX
  문서 ID: NOTE:131321.1 유형: BULLETIN
  마지막 개정 날짜: 04-JUL-2008 상태: PUBLISHED

PURPOSE
-------

Provide relinking instructions for Oracle Database software
on UNIX platforms.

 
SCOPE & APPLICATION
-------------------

Anyone who maintains Oracle RDBMS software on a UNIX platform.


Relinking Oracle
================

Background:
Applications for UNIX are generally not distributed as complete executables.  
Oracle, like many application vendors who create products for UNIX, distribute 
individual object files, library archives of object files, and some source 
files which then get "relinked" at the operating system level during 
installation to create usable executables.  This guarantees a reliable
integration with functions provided by the OS system libraries.

Relinking occurs automatically under these circumstances:

 - An Oracle product has been installed with an Oracle provided installer.
 - An Oracle patch set has been applied via an Oracle provided installer.  

The following information has been added to the 'Certify' section of Metalink:

   General Notes For Oracle Database - Enterprise Edition:
   O/S Information: 
   The vendors guarantee operating system binary compatibility; therefore, no 
   reinstall or relink of the Oracle software is required when upgrading these
   operating systems unless specifically stated otherwise.

Relinking Oracle manually is suggested under the following circumstances
(even though the OS vendor may not require it):

 - An OS upgrade has occurred.
 - A change has been made to the OS system libraries.  This can occur during 
   the application of an OS patch.
 - A new install failed during the relinking phase.
 - Individual Oracle executables core dump during initial startup.
 - An individual Oracle patch has been applied (however, explicit relink 
   instructions are usually either included in the README or integrated into 
   the patch install script) 

Customers who want to (or have been advised to) manually relink should follow 
the procedure below.

[Step 1] Log into the UNIX system as the Oracle software owner
==============================================================================
Typically this is the user 'oracle'.
 

[STEP 2] Verify that your $ORACLE_HOME is set correctly:
===============================================================================
For all Oracle Versions and Platforms, perform this basic environment check 
first:
 
 % cd $ORACLE_HOME
 % pwd    

 ...Doing this will ensure that $ORACLE_HOME is set correctly in your current 
    environment.
 

[Step 3] Verify and/or Configure the UNIX Environment for Proper Relinking:
===============================================================================
For all Oracle Versions and UNIX Platforms:
 The Platform specific environment variables LIBPATH, LD_LIBRARY_PATH, & 
 SHLIB_PATH typically are already set to include system library locations like
 '/usr/lib'.  In most cases, you need only check what they are set to first, 
 then add the $ORACLE_HOME/lib directory to them where appropriate.
 i.e.:  % setenv LD_LIBRARY_PATH ${ORACLE_HOME}/lib:${LD_LIBRARY_PATH}
 (see Note 131207.1 How to Set UNIX Environment Variables for help with 
 setting UNIX environment variables)

If on AIX with:
--------------
    
    NOTE: Before relinking, after stopping all required processes, issue the
    following as root to detach all files from memory that are not attached 
    to an active process:

         # /usr/sbin/slibclean

    Oracle 7.3.X:
       - Set LIBPATH to include $ORACLE_HOME/lib
    
    Oracle 8.0.X:
       - Set LIBPATH to include $ORACLE_HOME/lib
       - Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib and 
         $ORACLE_HOME/network/lib (Required when using Oracle products that 
         use Java)
       - Set LINK_CNTRL to L_PTHREADS_D7 if using AIX 4.3. ('oslevel' verifies 
         OS version)
    
    Oracle 8.1.X, 9.X.X, 10.X.X or 11.x.x:
       - For 8.1.5, set LINK_CNTRL to L_PTHREADS_D7
       - If not 8.1.5, ensure that LINK_CNTRL is not set
       - Set LIBPATH to include $ORACLE_HOME/lib
      

If on DATA GENERAL AVIION (DG) with:
-----------------------------------

    Oracle 7.3.X or 8.0.X:
       - Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib
       - ensure TARGET_BINARY_INTERFACE is unset
    
    Oracle 8.1.X:
       - Set LD_LIBRARY_PATH to include 
         $ORACLE_HOME/lib:$ORACLE_HOME/JRE/lib/PentiumPro/native_threads

If on HP-UX with:
----------------

    Oracle 7.3.X, 8.0.X, 8.1.X;
       - Set SHLIB_PATH to $ORACLE_HOME/lib
       If using 64bit 8i Oracle, also
       - Set LD_LIBRARY_PATH to $ORACLE_HOME/lib64
       - ensure LPATH is unset
 
    Oracle 9.X.X, 10.X.X or 11.x.x;
       - ensure LPATH is unset

If on NCR with:
--------------

    Oracle 7.3.X, 8.0.X or 8.1.X:
       - Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib:/usr/ccs/lib

If on SCO UNIXware with:
-----------------------

    Oracle 7.3.X or 8.0.X:
       - Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib
    
    Oracle 8.1.X:
       - Set LD_LIBRARY_PATH to include 
         $ORACLE_HOME/lib:$ORACLE_HOME/JRE/lib/x86at/native_threads

If on SGI with:
--------------

    32bit Oracle 7.3.X or 8.0.X:
       - Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib
       - Set SGI_ABI to -32  

    64bit Oracle 8.0.X or 8.1.X (8i is only available in 64bit):
       - Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib
       - Set SGI_ABI to -64
       - If one does not already exist, create the file compiler.defaults and 
         set the COMPILER_DEFAULTS_PATH variable:

     In the Oracle software owner's $HOME directory, create a file called
     'compiler.defaults':
  
        % cd $HOME
        % echo "-DEFAULT:abi=64:isa=mips3:proc=r10k" > compiler.defaults

     Then set the environment variable COMPILER_DEFAULTS_PATH to point to the
     $HOME directory.
  
        % setenv COMPILER_DEFAULTS_PATH $HOME
  
     If this is not set, relinking will fail because the compiler defaults to
     MIPS4 objects although Oracle requires MIPS3.
       - Set LD_LIBRARY64_PATH to include the $ORACLE_HOME/lib and the 
         $ORACLE_HOME/javavm/admin directories. 
       - Set LD_LIBRARYN32_PATH to include the $ORACLE_HOME/lib32 directory. 
         NOTE: LD_LIBRARY64_PATH & LD_LIBRARYN32_PATH must be undefined when 
         installing software with Oracle Universal Installer. 

If on SOLARIS (Sparc or Intel) with:
------------------------------------

    Oracle 7.3.X, 8.0.X, or 8.1.X:
       - Ensure that /usr/ccs/bin is before /usr/ucb in $PATH  
         % which ld   ....should return '/usr/ccs/bin/ld'

       If using 32bit(pre 9i) Oracle, 
       - Set LD_LIBRARY_PATH=$ORACLE_HOME/lib

       If using 64bit(pre 9i) Oracle, 
       - Set LD_LIBRARY_PATH=$ORACLE_HOME/lib
       - Set LD_LIBRARY_PATH_64=$ORACLE_HOME/lib64

    Oracle 9.X.X or higher:
       - LD_LIBRARY_PATH & LD_LIBRARY_PATH_64 do not need to be set to include
         a reference to $ORACLE_HOME/lib or $ORACLE_HOME/lib64 for a generic database
         software installation. 
         (However they should not contain a reference to the ORACLE_HOME of another Oracle version)

If on Digital/Tru64, IBM/Sequent PTX, Linux or any other UNIX Platform not 
mentioned above with:
------------------------------------------------------------------------------

    Oracle 7.3.X, 8.0.X, 8.1.X, 9.X.X, 10.X.X or 11.x.x:
       - Set LD_LIBRARY_PATH to include $ORACLE_HOME/lib


[Step 4] For all Oracle Versions and UNIX Platforms: 
===============================================================================
Verify that you performed Step 2 correctly:

 % env|pg  ....make sure that you see the correct absolute path for 
   $ORACLE_HOME in the variable definitions.
 

[Step 5] For all Oracle Versions and UNIX Platforms: 
===============================================================================
Verify umask is set correctly:

 % umask

This must return 022.  If it does not, set umask to 022.

 % umask 022
 % umask

[Step 6] Run the OS Commands to Relink Oracle: 
===============================================================================
Important Note:  Before relinking Oracle, shut down both the database and the 
                 listener.
Important Note:  The following commands will output a lot of text to your 
                 session window.  To capture this output for upload to support,
                 redirect the output to a file.
Important Note:  If relinking a client installation, it's expected that some 
                 aspects of the following commands will fail if the components
                 were not originally installed.

For all UNIX platforms:

Oracle 7.3.x 
------------
 For executables:  oracle, exp, imp, sqlldr, tkprof 

      % cd $ORACLE_HOME/rdbms/lib 
      % make -f ins_rdbms.mk install

 For executables:  svrmgrl, svrmgrm 

      % cd $ORACLE_HOME/svrmgr/lib 
      % make -f ins_svrmgr.mk linstall minstall      <- linstall is for svrmgrl, 
                                                        minstall is for svrmgrm

 For executables:  sqlplus 

      % cd $ORACLE_HOME/sqlplus/lib 
      % make -f ins_sqlplus.mk install

 For executables:  dbsnmp, oemevent, oratclsh 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_agent.mk install

 For executables:  names, namesctl 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_names.mk install

 For executables:  tnslsnr, lsnrctl, tnsping, csmnl, trceval, trcroute 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_network.mk install


Oracle 8.0.x 
------------
 For executables:  oracle, exp, imp, sqlldr, tkprof, mig, dbv, orapwd, rman, 
                   svrmgrl, ogms, ogmsctl 

      % cd $ORACLE_HOME/rdbms/lib 
      % make -f ins_rdbms.mk install

 For executables:  sqlplus 

      % cd $ORACLE_HOME/sqlplus/lib 
      % make -f ins_sqlplus.mk install

 For executables:  dbsnmp, oemevent, oratclsh, libosm.so 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_oemagent.mk install

 For executables:  tnslsnr, lsnrctl, namesctl, names, osslogin, trcasst, 
                   trcroute 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_network.mk install


Oracle 8.1.X, 9.X.X, 10.X.X or 11.x.x
-------------------------------------
  *** NEW IN 8i AND ABOVE ***

   A 'relink' script is provided in the $ORACLE_HOME/bin directory.
     % cd $ORACLE_HOME/bin
     % relink      ...this will display all of the command's options.
       usage: relink <parameter>
       accepted values for parameter: all, oracle, network, client, 
       client_sharedlib, interMedia, precomp, utilities, oemagent, ldap 
  
  Note: ldap option is available only from 9i. In 8i, you would have to manually relink
  ldap.

  You can relink most of the executables associated with an Oracle Server Installation
  by running the following command:
     % relink all    
  This will not relink every single executable Oracle provides(you can
  discern which executables were relinked by checking their timestamp with
  'ls -l' in the $ORACLE_HOME/bin directory).  However, 'relink all' will 
  recreate the shared libraries that most executables rely on and thereby
  resolve most issues that require a proper relink. 

 
 -or-

  Since the 'relink' command merely calls the traditional 'make' commands, you 
  still have the option of running the 'make' commands independently:

 For executables:  oracle, exp, imp, sqlldr, tkprof, mig, dbv, orapwd, rman, 
                   svrmgrl, ogms, ogmsctl 

      % cd $ORACLE_HOME/rdbms/lib 
      % make -f ins_rdbms.mk install

      NOTE: After relinking the oracle executable, make sure that the 
      permissions on the executable are 6751 (-rwsr-s--x). If they are
      not, run the following command as the Oracle software owner:

      % cd $ORACLE_HOME/bin
      % chmod 6751 oracle

 For executables:  sqlplus 

      % cd $ORACLE_HOME/sqlplus/lib 
      % make -f ins_sqlplus.mk install

 For executables:  isqlplus   (Oracle9i and higher versions)

      % cd $ORACLE_HOME/sqlplus/lib 
      % make -f ins_sqlplus.mk install_isqlplus

 For executables:  dbsnmp, oemevent, oratclsh 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_oemagent.mk install

      NOTE: After relinking the dbsnmp executable, it is necessary to run
      the following commands as root (so that the ownership/permissions on
      the executable are correct):

      # cd $ORACLE_HOME/bin
      # chown root dbsnmp
      # chmod 6750 dbsnmp

      @ References: Note 233559.1 and Bug 2858326

 For executables:  names, namesctl 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_names.mk install

 For executables:  osslogin, trcasst, trcroute, onrsd, tnsping 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_net_client.mk install

 For executables:  tnslsnr, lsnrctl 

      % cd $ORACLE_HOME/network/lib 
      % make -f ins_net_server.mk install

 For executables related to ldap (for example Oracle Internet Directory):

      % cd $ORACLE_HOME/ldap/lib
      % make -f ins_ldap.mk install

How to Tell if Relinking Was Successful:
===============================================================================
If relinking was successful, the make command will eventually return to the OS 
prompt without an error. There will NOT be a 'Relinking Successful' type
message.


If You Receive an Error Message During Relinking:
===============================================================================
Confirm that the message you received is an actual fatal error and not a 
warning. Relinking errors usually terminate the relinking process and contain 
verbage similar to the following:
'Fatal error', 'Ld: fatal', 'Exit Code 1'
While warnings will look similar to: 'ld: warning: option -YP appears more than
once, first setting taken' and can most often be ignored.

If you receive an error that terminates the relinking process, your first step 
should be to extract the relevant information about the error from the make 
output:

This can be broken down into three basic steps:
 1. Identify the OS utility that is returning the error.
    'ld', 'make', 'cc', 'mv', 'cp', 'ar' are common sources.
 2. Identify the type of error:
    'Permission Denied', 'Undefined Symbol', 'File Not Found' are common types.
 3. Identify the files or symbols involved.

Using the information from above as keywords, search Oracle's Metalink 
repository ( http://metaLink.oracle.com ) for previous occurrences of the same 
error. If no previous occurances are found or a solution is not provided, 
generate an iTAR that includes the complete error text.

Help setting environment variables.
==============================================================================
See Note 131207.1 How to Set UNIX Environment Variables 
for help with setting UNIX environment variables.


Relinking with Orainst:
===============================================================================
For Oracle7 & Oracle8 only, the following document illustrates how to relink 
with the 'orainst' utility:
   Note 1032747.6 HOW TO RELINK ORACLE USING THE 7.3.X INSTALLER
While 'orainst' will run the same commands as [Step 4], performing [Step 4] 
manually from a UNIX shell is the preferred approach.


RELATED DOCUMENTS
-----------------

Note 131207.1   How to Set UNIX Environment Variables
Note 109621.1   HP/UX: LD_LIBRARY_PATH and SHLIB_PATH
Note 1032747.6  HOW TO RELINK ORACLE USING THE 7.3.X INSTALLER
Bug 1337908     THE $ORACLE_HOME/BIN/RELINK SCRIPT DOES NOT RELINK EXP, IMP 
                  SQLLOADER



relink 하는 경우

OS 업그레이드 후,
OS system libraries에 변경이 일어난 경우,
Os Patch를 한 경우, 설치중 자동 Relink 단계에서 실패한 경우,
Oracle startup 수행중 Oracle 실행 모듈이 core dump를 발생한 경우,
oracle 개별 patch가 적용된 후

relink는 디비를 내리고 RAC의 경우 따로 작업




한층 강화된 엑스포트/임포트: Oracle Data Pump

Oracle Database 10g 유틸리티로 크게 향상된 데이타 이동 기능

지금까지 엑스포트/임포트 툴세트는 열악한 속도에 대한 불만에도 불구하고 최소한의 노력으로 여러 플랫폼에 데이타를 전송하기 위해 사용해 온 유틸리티였습니다. 임포트는 단순히 엑스포트 덤프 파일에서 각 레코드를 읽고 이를 일반적인 INSERT INTO 명령을 사용해 대상 테이블에 삽입하기만 하므로 임포트 프로세스가 느린 것은 그리 놀랄만한 일이 아닙니다.

이제 프로세스 속도가 월등히 향상된 Oracle Database 10g의 보다 새롭고 빠른 엑스포트/임포트 툴킷인 Oracle Data Pump, the newer and faster sibling of the export/import toolkit in Oracle Database 10g를 사용해 보십시오.

Data Pump는 엑스포트/임포트 프로세스의 전체 구성을 나타냅니다. 일반적인 SQL 문을 사용하는 대신 독점 API로 데이타를 현저하게 빠른 속도로 로드 및 언로드합니다. 제가 테스트해본 결과, 직접 모드의 엑스포트보다 성능이 10-15배 향상되었으며, 임포트 프로세스 성능도 5배 이상 증가했습니다. 또한 엑스포트 유틸리티와 달리 프로시저 같은 특정 유형의 객체만 추출할 수 있습니다.

Data Pump Export

이 새로운 유틸리티는 원래의 엑스포트인 exp와 구분하기 위해 expdp라고 합니다. 이 예에서는 Data Pump를 사용해 약 3GB 크기의 대형 테이블인 CASES를 엑스포트합니다. Data Pump는 서버 측에서 파일 조작을 사용하여 파일을 생성하고 읽으므로 디렉토리를 위치로 사용합니다. 여기서는 filesystem /u02/dpdata1을 사용해 덤프 파일을 유지할 예정입니다.


create directory dpdata1 as '/u02/dpdata1';
grant read, write on directory dpdata1 to ananda;


그리고 다음과 같이 데이타를 엑스포트합니다.


expdp ananda/abc123 tables=CASES directory=DPDATA1
  dumpfile=expCASES.dmp job_name=CASES_EXPORT


이제 이 명령의 각 부분을 분석해 보겠습니다. 사용자 ID/암호 조합, 테이블 및 덤프 파일 매개변수는 말 그대로이므로 설명이 필요 없습니다. 원래의 엑스포트와 달리 파일이 클라이언트가 아닌 서버에 생성됩니다. 위치는 디렉토리 매개변수 값 DPDATA1로 지정되며, 이는 이전에 생성된 /u02/dpdata1을 가리킵니다. 또한 프로세스를 실행하면 서버의 디렉토리 매개변수로 지정된 위치에 로그 파일이 생성됩니다. 이 프로세스에는 기본적으로 DPUMP_DIR로 명명된 디렉토리가 사용되므로 DPDATA1 대신 생성할 수 있습니다.

위의 job_name 매개변수를 보면 원래의 엑스포트에 없는 특별한 항목이 하나 있습니다. 모든 Data Pump 작업은 작업(job)을 통해 이뤄집니다. Data Pump 작업은 DBMS 작업과 달리 주 프로세스를 대신해 데이타를 처리하는 단순한 서버 프로세스입니다. 마스터 제어 프로세스라고 하는 이 주 프로세스는 Advanced Queuing을 통해 이러한 작업 노력을 조정하는데, 이는 마스터 테이블이라고 하는 런타임 시 생성된 특수 테이블을 통해 이뤄집니다. 제시한 예에서 expdp를 실행하면서 사용자 ANANDA의 스키마를 검사하면 job_name 매개변수에 해당되는 CASES_EXPORT 테이블이 있음을 알 수 있습니다. expdp가 종료되면 이 테이블은 삭제됩니다.

엑스포트 모니터링

DPE(Data Pump Export)를 실행하면서 Control-C를 누르면 화면상에 메시지 표시를 중지하지만 프로세스 자체를 엑스포트하지는 않습니다. 대신 다음과 같이 DPE 프롬프트를 표시합니다. 이제 프로세스는 소위 “대화식” 모드에 들어갑니다.


Export>


이 접근방법에서는 DPE 작업에 여러 명령을 입력할 수 있습니다. 요약을 확인하려면 다음과 같이 프롬프트에 STATUS 명령을 사용합니다.


Export> status
Job: CASES_EXPORT
  Operation: EXPORT                        
  Mode: TABLE                         
  State: EXECUTING                     
  Degree: 1
  Job Error Count: 0
  Dump file:  /u02/dpdata1/expCASES.dmp
      bytes written =  2048

Worker 1 Status:
  State: EXECUTING                     
  Object Schema: DWOWNER
  Object Name: CASES
  Object Type: TABLE_EXPORT/TBL_TABLE_DATA/TABLE/TABLE_DATA
  Completed Objects: 1
  Total Objects: 1
  Completed Rows: 4687818


하지만 이것은 상태 표시일 뿐이며 엑스포트는 백그라운드에서 실행되고 있습니다. 화면의 메시지를 계속 확인하려면 Export> 프롬프트에서 CONTINUE_CLIENT 명령을 사용합니다.

병렬 작업

PARALLEL 매개변수를 통해 엑스포트시 하나 이상의 스레드를 사용하면 작업 속도를 크게 개선할 수 있습니다. 스레드마다 개별 덤프 파일을 생성하므로 매개변수 dumpfile은 병렬화 만큼 많은 여러 항목을 갖게 됩니다. 또한 하나씩 명시적으로 입력하는 대신 다음과 같이 대체 문자를 파일 이름으로 지정할 수 있습니다.


expdp ananda/abc123 tables=CASES directory=DPDATA1
  dumpfile=expCASES_%U.dmp parallel=4 job_name=Cases_Export


여기서 dumpfile 매개변수에 어떻게 대체 문자 %U가 생기는지 주목합니다. 이 대체 문자는 파일이 필요에 따라 생성되고 형식은 expCASES_nn.dmp이 됨을 나타내는데, 여기서 nn은 01에서 시작하며 필요에 따라 증가하게 됩니다.

병렬 모드에서는 상태 화면에 네 개의 작업자 프로세스가 표시됩니다. (기본 모드에서는 프로세스가 한 개만 표시됩니다.) 모든 작업자 프로세스가 데이타를 동시에 추출하며 진행률을 상태 화면에 표시합니다.

데이타베이스 파일 및 덤프 파일 디렉토리 파일 시스템에 액세스하려면 I/O 채널을 반드시 구분해야 합니다. 그렇지 않으면 Data Pump 작업의 유지와 관련된 오버헤드가 병렬 스레드의 이점을 뛰어넘어 성능을 저하시킬 수 있습니다. 병렬화는 테이블 수가 병렬 값보다 크고 테이블이 대규모인 경우에만 적용됩니다.

데이타베이스 모니터링

데이타베이스 뷰에서 실행되는 Data Pump 작업에 관해서도 자세한 정보를 확인할 수 있습니다. 작업을 모니터링하는 기본 뷰는 DBA_DATAPUMP_JOBS로 작업에서 실행되는 작업자 프로세스(DEGREE 열)의 수를 알려줍니다. 그 밖의 중요한 뷰에는 DBA_DATAPUMP_SESSIONS가 있는데, 이전 뷰 및 V$SESSION과 조인하면 주 포그라운드(Foreground) 프로세스 세션의 SID를 확인할 수 있습니다.

select sid, serial#
from v$session s, dba_datapump_sessions d
where s.saddr = d.saddr;


이 명령에는 포그라운드 프로세스의 세션이 표시됩니다. 경고 로그에서는 보다 유용한 정보를 얻을 수 있습니다. 프로세스가 시작되면 MCP 및 작업자 프로세스가 다음과 같이 경고 로그에 나타납니다.

kupprdp: master process DM00 started with pid=23, OS id=20530 to execute -
  SYS.KUPM$MCP.MAIN('CASES_EXPORT', 'ANANDA');

kupprdp: worker process DW01 started with worker id=1, pid=24, OS id=20532 to execute -
  SYS.KUPW$WORKER.MAIN('CASES_EXPORT', 'ANANDA');

kupprdp: worker process DW03 started with worker id=2, pid=25, OS id=20534 to execute -
  SYS.KUPW$WORKER.MAIN('CASES_EXPORT', 'ANANDA');


경고 로그에는 Data Pump 작업을 위해 시작된 세션의 PID가 표시됩니다. 실제 SID는 이 질의를 사용해 확인합니다.

select sid, program from v$session where paddr in
 (select addr from v$process where pid in (23,24,25));


PROGRAM 열에는 경고 로그 파일의 이름에 해당되는 프로세스 DM(마스터 프로세스) 또는 DW(작업자 프로세스)가 표시됩니다. SID 23 같은 작업자 프로세스에서 병렬 질의를 사용하는 경우, V$PX_SESSION 뷰에서 확인할 수 있습니다. 이 뷰에는 SID 23으로 표시된 작업자 프로세스에서 실행되는 모든 병렬 질의 세션이 나타납니다.

select sid from v$px_session where qcsid = 23;


V$SESSION_LONGOPS 뷰에서는 작업 완료에 걸리는 시간을 예측하는 또 다른 유용한 정보를 얻을 수 있습니다.

select sid, serial#, sofar, totalwork
from v$session_longops
where opname = 'CASES_EXPORT'
and sofar != totalwork;


totalwork 열에는 총 작업량이 표시되는데, 이 중 현재까지 sofar 작업량을 완료했으므로 이를 통해 얼마나 더 시간이 걸릴지 예측할 수 있습니다.

Data Pump Import

하지만 Data Pump에서 가장 눈에 잘 띄는 부분은 데이타 임포트 성능입니다. 이전에 엑스포트된 데이타를 임포트하려면 다음을 사용합니다.

impdp ananda/abc123 directory=dpdata1 dumpfile=expCASES.dmp job_name=cases_import


임포트 프로세스의 기본 작업 방식은 테이블 및 연관된 모든 객체를 생성하고 테이블이 있는 상태에서 오류를 만들어 내는 것입니다. 기존 테이블에 데이타를 추가해야 하는 경우 위의 명령행에 TABLE_EXISTS_ACTION=APPEND를 사용할 수 있습니다.

DPE와 마찬가지로 프로세스 도중 Control-C를 누르면 DPI(Date Pump Import)의 대화식 모드를 표시하며 Import>가 프롬프트됩니다.

특정 객체 작업

한 사용자에서 특정 프로시저만 엑스포트하여 다른 데이타베이스나 사용자에 다시 생성해야 했던 경험이 있습니까? 기존의 엑스포트 유틸리티와 달리 Data Pump는 특정 유형의 객체만 엑스포트할 수 있습니다. 예를 들어, 다음 명령을 실행하면 테이블, 뷰 또는 함수 등은 제외하고 오로지 프로시저만 엑스포트할 수 있습니다.

expdp ananda/iclaim directory=DPDATA1 dumpfile=expprocs.dmp include=PROCEDURE


To export only a few specific objects--say, function FUNC1 and procedure PROC1--you could use

expdp ananda/iclaim directory=DPDATA1 dumpfile=expprocs.dmp
  include=PROCEDURE:\"=\'PROC1\'\",FUNCTION:\"=\'FUNC1\'\"


이 덤프 파일은 소스의 백업으로 사용됩니다. 때로는 이를 사용해 DDL 스크립트를 생성하여 나중에 사용할 수도 있습니다. DDL 스크립트 파일을 생성하려면 SQLFILE이라고 하는 특수 매개변수를 사용합니다.

impdp ananda/iclaim directory=DPDATA1 dumpfile=expprocs.dmp sqlfile=procs.sql


이 명령은 DPDATA1로 지정된 디렉토리에 procs.sql로 명명된 파일을 생성하며 엑스포트 덤프 파일 내의 객체 스크립트가 들어 있습니다. 이 접근방법을 사용하면 다른 스키마에 원본을 보다 신속하게 생성할 수 있습니다.

INCLUDE 매개변수를 사용하면 객체가 덤프 파일에서 포함 또는 제외되도록 정의할 수 있습니다. 예를 들어, INCLUDE=TABLE:"LIKE 'TAB%'" 절을 사용하면 이름이 TAB로 시작하는 테이블만 엑스포트할 수 있습니다. 마찬가지로 INCLUDE=TABLE:"NOT LIKE 'TAB%'" 구문을 사용하면 TAB으로 시작하는 모든 테이블을 제외시킬 수 있습니다. 아니면 EXCLUDE 매개변수를 사용해 특정 객체를 제외시킬 수 있습니다.

Data Pump를 사용하면 외부 테이블로 테이블스페이스를 이동할 수도 있는데, 이렇게 하면 진행 중인 병렬화를 다시 정의하고 기존 프로세스에 테이블을 추가하는 등의 작업에 매우 효과적입니다(이는 본 문서의 범위를 벗어난 내용이므로 자세한 내용은 Oracle Database Utilities 10g Release 1 10.1을 참조하십시오). 다음 명령을 실행하면 Data Pump 엑스포트 유틸리티에서 사용 가능한 매개변수 목록이 생성됩니다.

expdp help=y


마찬가지로 impdp help=y 명령을 실행하면 DPI의 모든 매개변수가 표시됩니다.

Data Pump 작업을 실행하는 동안 DPE 또는 DPI 프롬프트에 STOP_JOB을 실행하여 작업을 일시 중지한 다음 START_JOB으로 다시 시작할 수 있습니다. 이 기능은 공간이 부족하여 계속하기 전에 정정해야 하는 경우 유용하게 사용할 수 있습니다.

자세한 내용은 Oracle Database Utilities 10g Release 1 10.1 설명서 1부를 참조하십시오.

[출처] http://cafe.naver.com/prodba/106

'OraclE' 카테고리의 다른 글

archive file 자동 삭제 스크립트-window  (0) 2008.10.07
data file size 줄이기  (0) 2008.10.07
ASSM에서 Freelist 관리  (0) 2008.09.25
DBA Table / View 정리  (0) 2008.09.17
오라클에서 시퀀스(SEQUENCE) 사용하기  (0) 2008.09.17

Bulletin No: 18489

Product: ORACLE SERVER

Subject: Automatic Space Segment Management (BMB:BitMap Blocks)에 대해서 (9i)

Automatic Space Segment Management (BMB:BitMap Blocks)에 대해서 (9i)

====================================================================

 

PURPOSE

-------

기존에 freelist로 관리되던 segment내의 free block에 대해서, 9i부터 새로 소개된 automatic space segment 관리에 대해서 살펴본다.

 

Explanation & Example

----------------------

1. freelist를 통한 free block관리

 

8i까지에서, segment의 free block들은 항상 freelist를 통해 관리된다. PCTUSED아래로 채워진 block들이 freelist로 연결되어 있어서, insert가 필요하면 이 freelist를 segment header에서부터 뒤지면서 블럭내의 빈 공간에 insert를 하게 되는것이다.

 

같은 table에 대해서 insert 트랜잭션이 동시에 많은 경우 table storage의 freelists 값을 증가시켜야 하고, OPS의 경우 node갯수를 고려하여 freelist groups을 지정해야 하는 등 freelist와 관련하여 DB Admin이 고려하여야 할 tuning point가 존재하여 왔다.

 

또한 이 freelist내의 free block에 대한 정보가 segment header내에 전체 정보를 가지고 있거나 dictionary table에 정보를 가지고 있는 것이 아니고, linked list 형태로 free block이 다음 free block을 지정하는 형태라 쉽게 freelist에 대한 정보를 확인하는 것도 불가능하다.

 

이렇게 전체 freelist에 대한 정보를 쉽게 확인하지 못하는 이유로, table에 대한 reorganization을 결정하는 기준을 정하기도 쉽지 않았고, db내에서 space 활용도 최적이 되지 못한다.

 

이러한 space관리에 대한 문제점을 극복하기 위해 9i에서 제시된 것이 ASSM (automatic space segment management)이다.

2. Automatic Space Segment Management

 

9i에서 제시된 이 ASSM방식은 segment에 할당된 space를 bitmap으로 관리한다.

 

ASSM 방식을 이용하려면 반드시 locally managed tablespace여야 하며, 다음과 같이 'segment space management auto'를 지정하면된다.

 

SQL>CREATE TABLESPACE test_tbs

DATAFILE '/oracle/data/data01.dbf' SIZE 50M

EXTENT MANAGEMENT LOCAL

SEGMENT SPACE MANAGEMENT AUTO;

 

auto가 아닌 manual로 지정되게 되면 이전과 같이 freelist방식을 사용하게 되며, DBA_TABLESPACES view의 SEGMENT_SPACE_MANAGEMENT column을 통해 AUTO인지 MANUAL방식인지 확인 가능하다.

이렇게 생성된 tablespace내에 table이나 index를 생성하게 되면 segment header 외에 추가적인 BMB (BitMap Blocks)라는 것이 생기게 된다. 이 BMB에는 할당된 block들의 space정보를 4 bit를 이용하여 다음 6가지 상태를 나타내는 bitmap 정보를 가진다.

 

(1) 75% 이상의 free space를 가지는 block

(2) 50% 이상 75% 미만의 free space를 가지는 block

(3) 25% 이상 50% 미만의 free space를 가지는 block

(4) 25% 미만의 free space를 가지는 block

(5) 꽉 찬 block

(6) 한번도 사용하지 않아 format 되지 않은 block

 

이렇게 ASSM 방법을 이용하여 space를 관리하게 되면 free block에 대해서 좀 더 상세한 정보를 바탕으로 space utilization도 높아지고, freelist를 타고 다음다음 block을 access하는대신 BMB를 참고로 적당한 block들을 선택하기 때문에 space에 관한 성능도 좋아진다.

 

또한 ASSM의 경우 해당 tablespace에 생성된 segment들은 freelists, freelist groups, pctused등은 지정하여도 무시되는데, 이것은 space관리 작업을 단순화시킬뿐 아니라, 특히 freelist groups 지정이 성능에 영향을 미쳤던 RAC에서 큰 도움이 된다. 그외에도 BMB를 동시에 다른 트랜잭션이 다른 part를 access 하는 것 또한 성능에 도움을 준다. 오라클은 internal benchmark 자료에 따르면 RAC에서 최적화된 freelist 관련 parameter를 지정한 상태에서 3백만건 데이타 insert 작업에 대해서, ASSM과 일반 manual 방법을 비교해 본 결과 35 % 정도 ASSM사용이 성능향상에 도움이 되었다.

 

이때 주의할 점은, locally managed tablespace와 이 ASSM 방식간에 혼동을 일으키는 경우가 종종 있다. 이것은 locally managed tablespace와 ASSM이 둘 다 bitmap방식을 통해 space를 관리한다는 측면때문 일 것으로 보인다.

ASSM방식을 사용하려면 미리 이야기한대로 locally managed tablespace에서만 사용가능한데, 기본적으로 locally managed tablespace는 dba_free_space에서 확인되는 할당되지 않은 space에 대한 관리이고, ASSM은 일단 segment내에 할당된 extent안에서 block내의 free space에 관한 것이다.

locally managed tablespace에 관한 좀 더 자세한 사항은 <Bulletin No: 11860>이나 <Bulletin No: 18261>를 참조하도록 한다.

 

3. space정보 확인 방법

 

ASSM방식을 사용하지 않고 freelist방법을 사용하는 경우 segment에 할당된 extent 내에 free block을 확인하는 방법은, table analyze후 DBA_TABLES의 EMPTY_BLOCK를 확인하거나 DBMS_SPACE.UNUSED_SPACE procedure를 이용하는 방법이 존재한다. 그리고 이 두 가지는 같은 정보를 보여준다.

 

ASSM으로 관리되는 table이나 index에 대해서는 DBA_TABLES의 EMPTY_BLOCKS와 DBMS_SPACE.UNUSED_SPACE가 다른 값을 나타낼 뿐 아니라, ASSM의 정확한 정보를 모두 나타내지 못하므로 새로이 소개된 DBMS_SPACE.SPACE_USAGE procedure를 이용하면 된다.

이 세가지 방법이 나타내는 각 정보에 대해서 자세히 살펴본다.

 

먼저 DBMS_SPACE.SPACE_USAGE의 사용방법이다. 아래에 예로 SCOTT user의 TEST table에 대해서 예로 들었다. TEST table은 ASSM 방식으로 관리되는 table이다.

 

SQL> declare

2 v_unformatted_blocks number;

3 v_unformatted_bytes number;

4 v_fs1_blocks number;

5 v_fs1_bytes number;

6 v_fs2_blocks number;

7 v_fs2_bytes number;

8 v_fs3_blocks number;

9 v_fs3_bytes number;

10 v_fs4_blocks number;

11 v_fs4_bytes number;

12 v_full_blocks number;

13 v_full_bytes number;

14 begin

15 dbms_space.space_usage ('SCOTT', 'TEST', 'TABLE', v_unformatted_blocks,

16 v_unformatted_bytes, v_fs1_blocks, v_fs1_bytes, v_fs2_blocks,

17 v_fs2_bytes, v_fs3_blocks, v_fs3_bytes, v_fs4_blocks,

18 v_fs4_bytes, v_full_blocks, v_full_bytes);

19 dbms_output.put_line('Unformatted Blocks = '||v_unformatted_blocks);

20 dbms_output.put_line('FS1 Blocks = '||v_fs1_blocks);

21 dbms_output.put_line('FS2 Blocks = '||v_fs2_blocks);

22 dbms_output.put_line('FS3 Blocks = '||v_fs3_blocks);

23 dbms_output.put_line('FS4 Blocks = '||v_fs4_blocks);

24 dbms_output.put_line('Full Blocks = '||v_full_blocks);

25 end;

26 /

 

Unformatted Blocks = 0

FS1 Blocks = 0

FS2 Blocks = 0

FS3 Blocks = 0

FS4 Blocks = 1

Full Blocks = 9

 

PL/SQL procedure successfully completed.

 

이때, FS1 ~ FS4가 의미하는것은 다음과 같다.

FS1 : 0-25%의 free space를 가진 block

FS2 : 25-50%의 free space를 가진 block

FS3 : 50-75%의 free space를 가진 block

FS4 : 75-100%의 free space를 가진 block

 

이예에서 SCOTT user의 TEST table에 data를 insert시키고 analyze후 조회하니 다음과 같은 결과가 나왔다. (단, DBMS_SPACE.SPACE_USAGE사용을 위해서는 analyze를 수행할 필요가 없다.)

 

아래의 예에서 보면 첫번째로 DBA_TABLES의 EMPTY_BLOCKS와 DBMS_SPACE.UNUSED_SPACE에서 보여주는 값이 서로 다르다. 그리고 정확한 정보를 주는 DBMS_SPACE_SPACE_USAGE에서는 75%이상 비어있는 block이 한개, full인 block이 9개로 나타난다. 그럼 전체 13개의 block중 3개의 block은 어떠한 block 일까? 이 3개의 BLOCK을 DBA_TALES에서는 EMPTY_BLOCK로 분류하였다.

 

이 세개의 block는 바로 space를 bitmap으로 관리하는 BMB 들이다.

 

DBA_TABLES DBMS_SPACE.UNUSED_SPACE DBMS_SPACE.SPACE_USAGE

--------------------- ---------------------------- ------------------------

BLOCKS | EMPTY_BLOCKS TOTAL_BLOCKS | UNUSED_BLOCKS FS4 Blocks | Full Blocks

--------------------- ---------------------------- ------------------------

10 3 13 0 1 9

 

Reference Documents

-------------------

 

<Note:180608.1> Automatic Space Segment Management in RAC Environments

<Note:149516.1> BMB versus Freelist Segment: DBMS_SPACE.UNUSED_SPACE

and DBA_TABLES.EMPTY_BLOCKS


'OraclE' 카테고리의 다른 글

data file size 줄이기  (0) 2008.10.07
Oracle Data Pump(Oracle 10g)  (0) 2008.10.01
DBA Table / View 정리  (0) 2008.09.17
오라클에서 시퀀스(SEQUENCE) 사용하기  (0) 2008.09.17
Windows 32bit OS 에서 Oracle Memory Sizing  (0) 2008.08.13

+ Recent posts