반응형
하야...

뭐 이런게 다있지...

암튼.. 어려버... ㅋㅋ;

이 프로그램 GUI 환경에서 SQLITE를 쓰게 해주는 프로그램임...

explain 정보를 보기 좋게 뜨기 위해서 사용


반응형

'Database' 카테고리의 다른 글

무료 DB 접근 툴  (0) 2019.08.19
무료 ERD 툴 ERMASTER  (0) 2019.08.08
damo 암호화 컬럼 복원시 주의사항  (0) 2017.08.20
Sybase IQ Administrator 사용 Script  (0) 2012.10.18
JNDI Log4SQL 적용 예...  (0) 2011.04.21
반응형

--- Arup Nanda 의 사이트에 자주 들어가봅니다. DBA 로서의 장애 Case 를 대응하는 절차가 비교적 자세히 나와있더군요. 요즘 일이 많아서 빠르게 쓰다보니 오역과 중간중간 빼먹는게 많은건 이해해주시길...아래는 실제로 DMA (direct memory access)를 사용해서 처리한 사례더군요..

  

Diagnosing Library Cache Latch Contention: A Real Case Study

 

어느날 DW 서버가 갑자기 다운됐다. 그래서 데이타베이스를 올리고 다시 구동했지만 모든 접속을 시도하면
hang 이 걸리는 것이였다. 따라서 접속은 실패하고 DBA는 접속된 세션들이 구동되고 있는지 어떤지를 확인할 수 조차도
없었다. DBA 는 WAIT 이벤트를 체크했다 (그러나 로긴조차도 안되기 때문에 실행할수 없었다)
흥미롭게도 CPU는 70% 정도의 수준이였고 이는 낮시간대의 일반적인 수치이다. 그리고 I/O또한 약 90%로서 이또한
일반적인 수치였다.

따라서 전형적인 방법인 system 관리자에게 보고하고 재부팅을 하는 방법을 사용했다. 재부팅은 30분정도
소요되었고 그 후로 10여분간은 모든것이 정상적으로 보였다. 그러나 얼마되지 않아 아까와같은 똑같은 문제에 부딪쳤다- 데이타베이스가 먹통이 되어버린 것이였다.

이것 때문에 DBA가 나에게 도움을 요청하였다. 이 블로그에서는 내가 이후의 30분동안에 어떻게 수행했고 문제를
해결했는지에 대해서 기술해보도록 하겠다.

 

증상


(1) 데이타베이스 접속 Hanging
(2) SQL*PLUS AS SYSDBA 로 접속해도 동일한 HANGING 현상: 증상을 확인할 수도 없는 상태
(3) 시스템은 아무때나 리부팅할 수 없는 상태

 

Action

 

여기서 접속이 불가능할 때 데이타베이스 인스턴스에서 바로 써먹을 수 있는 꼼수가 존재한다.
대부분의 사람들은 SQL*Plus 에서 "prelim" 이라고 불리는 옵션을 잘알지 못한다. 이 옵션은 세션을 열지 않고
SGA에 바로 접속한수 있는 옵션이다. (10g 이상에서만 가능) 

 

(1) 먼저 SQL*plus 를 실행시키고 아래의 명령문을 실행했다.

 

$ sqlplus -prelim / AS SYSDBA
SQL>

 

명심하라. "Oracle Database 10.2.0.3 에 접속" 과 다르다. 지금 보이는 SQL> 프롬프트는 실제로는
데이타베이스에 접속한 상태가 아니다.

 

(2) 그다음 SGA 를 분석하기 위한 "oradebug" 를 사용하였다.

 

SQL> oradebug setmypid
SQL> oradebug hanganalyze 12

 

이 명령은 USER_DUMP_DEST 에 trace파일을 생성한다. 이 파일을 가장 최근에 생겨났기 때문에
쉽게 찾을 수 있다. 심지어는 내가 파일을 찾지 못해도 process ID를 사용해서 파일을 찾을 수 있다.
내가 찾은 파일은 프로세스ID 가 13392인 crmprd1_ora_13392.trc 였다.

(3) 파일을 조사하니 다음과 같았다.

 

*** 2008-08-23 01:21:44.200
==============
HANG ANALYSIS:
==============
Found 163 objects waiting for
<0/226/17/0x1502dab8/16108/no>
Open chains found:
Chain 1 : :
<0/226/17/0x1502dab8/16108/no>
<0/146/1/0x1503e898/19923/latch:>

이 파일을 많은 것을 말해준다. SID 146 에 Serial# 1 이 library cache latch 를 대기하고 있는 것을 보여준다.(맨마지막줄)
그리고 blocking 세션은 SID 226 Serial# 17 로 나와있다. 

나는 일단 이 OS process ID 인 16108 과 19923 을 기록해두었다.

 

(4) 다음으로 위의 두개의 OS PID 명으로 되어 있는 TRACE 파일을 체크했다.

 

crmprd1_ora_16108.trc
crmprd1_ora_19923.trc

 

(5) 먼저 BLOCKER인 첫번째 파일을 열었다. 다음 몇줄의 예이다.

 

*** 2008-08-23 01:08:18.840
*** SERVICE NAME:(SYS$USERS) 2008-08-23 01:08:18.781
*** SESSION ID:(226.17) 2008-08-23 01:08:18.781
LIBRARY OBJECT HANDLE: handle=c0000008dc703810 mtx=c0000008dc703940(8000) cdp=32737
name=UPDATE DW_ETL.FRRS_PROFILER SET CONSUMER_LINK = :"SYS_B_0", ADDRESS_LINK = :"SYS_B_1", ADDRESS_MATCH = :"SYS_B_2", PROC
ESSED=:"SYS_B_3" WHERE RNUM = :"SYS_B_4"
hash=a029fce7bb89655493e7e51a544592a4 timestamp=08-23-2008 00:10:23
namespace=CRSR flags=RON/KGHP/TIM/OBS/PN0/MED/KST/DBN/MTX/[504100d0]
kkkk-dddd-llll=0000-0001-0001 lock=N pin=0 latch#=10 hpc=0058 hlc=0058
lwt=c0000008dc7038b8[c0000008dc7038b8,c0000008dc7038b8] ltm=c0000008dc7038c8[c0000008dc7038c8,c0000008dc7038c8]
pwt=c0000008dc703880[c0000008dc703880,c0000008dc703880] ptm=c0000008dc703890[c0000008dc703890,c0000008dc703890]
ref=c0000008dc7038e8[c0000008dc7038e8,c0000008dc7038e8] lnd=c0000008dc703900[c0000008dc703900,c0000008dc703900]
LOCK OWNERS:
lock user session count mode flags
---------------- ---------------- ---------------- ----- ---- ------------------------
c0000008d079f1b8 c0000006151744d8 c0000006151744d8 16 N [00]
c0000008d4e90c40 c0000006151bcb58 c0000006151bcb58 16 N [00]
c0000008d0812c40 c0000008151a0438 c0000008151a0438 16 N [00]

 
(6) 이것은 디버깅을 위해 보물과 같았다. 첫번째에 SID와 Serial#(226,17) 를 확인할수 있다.
이를 사용해서 정확한 SQL문장을 볼수 있다. 또한 락에 대한 전체적인 상황을 볼 수 있다. 락의 자세한 사항은 신경쓰지 않아도 되지만 SID 226 이 전체 세션의 대기를 유발시키는 것이라는 충분한 정보를 제공해주었다.

 

(7) 나의 조사는 여기서 그치지 않고  이 대기를 유발하는 세션을 찾기를 시도했다. 따라서 나는 파일의 "PROCESS STATE" 이라는 섹션을 조사했다. 다음은 이 파일의 일부분이다.

 

PROCESS STATE
-------------
Process global information:
process: c00000081502dab8, call: c000000817167890, xact: 0000000000000000, curses: c00000081519ef88, usrses: c000000815
19ef88
----------------------------------------
SO: c00000081502dab8, type: 2, owner: 0000000000000000, flag: INIT/-/-/0x00
(process) Oracle pid=370, calls cur/top: c000000817167890/c000000817167890, flag: (0) -
int error: 0, call error: 0, sess error: 0, txn error 0
(post info) last post received: 115 0 4
last post received-location: kslpsr
last process to post me: c000000615002038 1 6
last post sent: 0 0 24
last post sent-location: ksasnd
last process posted by me: c000000615002038 1 6
(latch info) wait_event=0 bits=20
holding (efd=4) c0000008d7b69598 Child library cache level=5 child#=10
Location from where latch is held: kglhdgc: child:: latch
Context saved from call: 13
state=busy, wlstate=free
waiters [orapid (seconds since: put on list, posted, alive check)]:
291 (197, 1219468295, 197)
279 (197, 1219468295, 197)
374 (197, 1219468295, 197)
267 (197, 1219468295, 197)
372 (197, 1219468295, 197)
... several lines sniped ...
307 (15, 1219468295, 15)
181 (6, 1219468295, 6)
waiter count=58
Process Group: DEFAULT, pseudo proc: c0000008e03150d8
O/S info: user: oracrmp, term: UNKNOWN, ospid: 16108
OSD pid info: Unix process pid: 16108, image: oracle@sdwhpdb1


 

 

(8) 이파일은 내가 알기를 원하는 것을 모두 말해준다. 여기에 SID 226 에 의해서 발생하는 CACHE LATCH
로 인해서 대기하는 58 session들이 있다. 여기서 OS PROCESS ID 와 BLOCKING 세션의 SQL 문장을 알 수 있다.

 

 

(9) 나는 application 사용자가 어떠한 것을 실행했는지를 조사해봤더니 사용자는 loop를 돌면서 처리하는
update 문장을 실행시킨 것이였다. 그리고 그게 다가 아니라 다른 8개의 thread 에서 실행을 하였다.(역: 아마도 화면상에서 처리 가 되지 않으니 화면을 새로고쳐서 계속해서 8번을 처리 버튼을 누른것으로 생각됨)
의심할 여지가 없이 library cache latch 경합에 걸렸다. 모든 세션은 각각의 덤프 정보를 남겼다.
그리고 나는 같은 문장을 실행한 파일을 디렉토리에서 조사해보기로 했다.

 

$ grep “UPDATE DW_ETL” *.trc

 

(10) 나는 9개 이상의 세션(프로세스) 파일을 찾았다. 이중 한개의 파일의 일부분이다.

 

350 (167, 1219470122, 167)
197 (167, 1219470122, 167)
waiter count=185
Process Group: DEFAULT, pseudo proc: c0000008e03150d8
O/S info: user: oracrmp, term: UNKNOWN, ospid: 16114

 

이 프로세스 한개가 185개 waiter 를 가졌다!!!


 

$ kill -9

 

(12) 위의 명령으로 몇개의 프로세스를 죽인 후에야 데이타베이스는 응답하기 시작했다. 모든 프로세스를 죽인 후에는 데이타베이스 wait event 가 완벽히 정상적으로 돌아왔다.

 

참고사항


(1) Hang 이라고 생각되면 너무 그것에 대해 불안해하지 마라. 세션은 언제나 어떤것을 대기한다. 드물게 행을 만날 뿐이다.

v$session (10g) 이나  v$session_wait 의 EVENT 컬럼을 조회해서 대기하는 것이 무엇인지를 먼저 체크하라.

(2) 데이타베이스에 로긴하지 못해 정보를 얻을 수 없을 때는 oradebug 명령을 사용한다.

(3) oradebug 를 사용할때 SQL*Plus 를 이용한다. 로긴하지 못할때 "sqlplus -prelim " 로 SQL prompt 를 얻을 수 있을 것이다.

(4) oradebug setmypid  이용해서 oradebug 세션을 시작하고 oradebug hanganalyze  로 모든 hang 과 관련되어 있는

문제에 대한 덤프를 생성한다.

(5) oradebug help 를 사용해서 oradebug 커맨드의 모든것을 볼 수 있다.

 

 

반응형
반응형

Oradebug 사용법
- 적절한 권한을 가진 DB USER 로 sqlplus 로 접속
- 반드시 덤프할 오라클 프로세스를 지정한 후 사용

- SYNTAX : SQL>oradebug command <option>

일반 유저도 Try

SQL> show user
USER is "SCOTT"
SQL> oradebug setmypid
ORA-01031: insufficient privileges

 

SQL> conn / as sysdba
Connected.
SQL> show user
USER is "SYS"
SQL> oradebug setmypid
Statement processed.

==> 자신의 process ID 지정 해서 dump

 

일반 유저를 찾아서 지정 해보기

보통은[AIX 환경] ps aux | sort -k3 으로 cpu 과도 사용 Unix process ID 를 찾은 후

지정 해서 dump 를 떨군 후 분석을 하면 될듯

 

## Scott User 의 Process ID 찾기
SQL> select username, sid, serial#,PADDR from v$session where username ='SCOTT';

USERNAME                              SID    SERIAL# PADDR
------------------------------ ---------- ---------- --------
SCOTT                                  28         54 46CB5768

SQL> select * from v$process where addr = '46CB5768';

ADDR            PID SPID      USERNAME           SERIAL#
-------- ---------- --------- --------------- ----------
TERMINAL                       PROGRAM
------------------------------ ------------------------------------------------
TRACEID
--------------------------------------------------------------------------------
B LATCHWAI LATCHSPI
- -------- --------
46CB5768         29 283314    oracle                   2
pts/8                          oracle@seldw (TNS V1-V3)

 

## Unix 환경에서 파악

[CRAFT]seldw:/app/oracle/tg> ps -ef| grep 283314
  oracle 282448 290026   0 10:45:26  pts/7  0:00 grep 283314
  oracle 283314 284036   0 10:42:54      -  0:00 oracleCRAFT (DESCRIPTION=(LOCAL=YES)(ADDRESS=(PROTOCOL=beq)))

 

SQL> oradebug unlimit
Statement processed.
==> Dump 화일 무제한으로 설정
SQL> oradebug setospid 283314
Oracle pid: 29, Unix process pid: 283314, image: oracle@seldw (TNS V1-V3)

==> Scott Process ID 를 지정 해서 dump
SQL> oradebug tracefile_name
Statement processed.
==> dump 화일명 체크

==> 나오지 않는다.

SQL> oradebug dump errorstack 3
Statement processed.
==> dump 화일에 실제 Write 되도록 command 를 날리기

SQL> oradebug tracefile_name
/app/oracle/admin/CRAFT/udump/ora_283314_craft.trc
==> 이제 화일명이 보임

 

# Event 로 Trace 걸기
SQL> oradebug setospid 283314
Oracle pid: 29, Unix process pid: 283314, image: oracle@seldw (TNS V1-V3)

# 10046 Event 에 대해서 Trace 생성도록 설정 하기
SQL> oradebug event 10046 trace name context forever, level 12
Statement processed.
SQL> oradebug event 10046 trace name context off
Statement processed.
SQL> oradebug tracefile_name
/app/oracle/admin/CRAFT/udump/ora_283314_craft.trc

 

CASE 1 : 특정 프로세스가 SPIN 또는 HANG
SQL> oradebug dump errorstack 3 .. 3분단위 3번수행
SQL> oradebug dump processstate 10 .. 비교1
SQL> oradebug event 942 errorstack 10 .. 비교2

 

CASE 1 은 특정 프로세스가 SPIN 또는 HANG 으로 보이는 경우입니다.
(1) Oradebug setospid 해당 프로세스를 덤프대상으로 지정하고
(2) Oradebug dump errorstack 3 으로 ERRORSTACK 을 2-3번 떠서
(3) CALL STACK 부분이 변하고 있는지 비교해봅니다.
변하고 있으면 SPIN 이고, 변하지 않고 있으면 HANG 이라고 결론 내릴 수 있습니다.
ERRORSTACK LEVEL 3 에 PROCESSSTATE DUMP 가 포함되므로
PROCESSSTATE DUMP 를 별도로 수행할 필요가 없습니다.
EVENT Command 에서 ERRORSTACK 를 설정할 때와 비교해보면, EVENT Command 는 해당 에러가 발생하는
시점에 에러스택이 생성되는 것이고, DUMP Command 는 Oradebug Command 를 수행하자마자 에러스택이
생성됩니다.

 

CASE 2 : 데이터베이스 SPIN 또는 HANG
SQL> oradebug dump systemstate 10 .. 3분간격 3번수행
= alter session set events 'immediate trace name SYSTEMSTATE level 10';


케이스 두번째, 드디어 SYSTEMSTATE DUMP 입니다.
이 Command 는 아마도 oradebug 에서 가장 많이 사용되는 명령어로
alter session set events 'immediate trace name SYSTEMSTATE level 10'; 과 같습니다.
보시다시피 Oradebug Command 가 훨씬 간단하고 Rule 만 알면 외울 필요도 없습니다.
인스턴스 HANG 시 3분 간격으로 3번을 수행한 결과가 있어야 Slow Performance 인지,

진짜 HANG 이였는지 판단할 수 있습니다.


SQL> oradebug dump systemstate 10
ORA-00074: no process has been specified
SQL> alter session set events 'immediate trace name systemstate level 10';

Session altered.

 

CASE 3 : 프로세스 메모리가 비정상 증가하는 경우
SQL> oradebug dump heapdump 5 .. PGA+UGA


CASE 4 : SGA 부족으로 ORA-4031 가 발생하는 경우
SQL> oradebug dump heapdump 2 .. SGA
event="4031 trace name HEAPDUMP level 2" in initSID.ora

 

CASE 6 : 리커버리시 데이터파일 상태 불일치 에러시
SQL> oradebug dump controlf 10
SQL> oradebug dump file_hdrs 10
==>테스트시  임의의 프로세스 지정을 해야 trace 화일이 생성 된다.

SQL> oradebug dump controlf 10
ORA-00074: no process has been specified
SQL> oradebug setospid 283314
Oracle pid: 29, Unix process pid: 283314, image: oracle@seldw (TNS V1-V3)
SQL> oradebug dump controlf 10
Statement processed.
SQL> oradebug tracefile_name
/app/oracle/admin/CRAFT/udump/ora_283314_craft.trc
SQL> oradebug dump file_hdrs 10
Statement processed.
SQL> exit

 

SQL> oradebug hanganalyze 3
Hang Analysis in /app/oracle/admin/CRAFT/udump/ora_89222_craft.trc
프로세스 또는 인스턴스 HANG 진단 및 분석시 유용
HANGANALYZE [level]
1-2 Only HANGANALYZE output, no process dump
3 Level 2 + HANG 으로 추정되는 프로세스 덤프
4 Level 3 + WAIT CHAIN 의 BLOCKER 프로세스
5 Level 4 + WAIT CHAIN 의 모든 프로세스
10 모든 프로세스 덤프

SQL> oradebug hanganalyze 3 .. 권장레벨, 또는 1
Hang Analysis in /home/ora920/ora920_1190.trc
HANGANALYZE TRACEFILE SECTIONS 설명
 CYCLES : Deadlock 관계 세션들의 CHAIN
 BLOCKER OF MANY SESSIONS : 10개 이상의 세션을 blocking 하는 BLOCKER 제시
 OPEN CHAINS : 1개 이상의 타 세션들을 blocking 하는 세션이 포함된 WAIT CHAIN
 OTHER CHAINS : OPEN CHAIN 의 세션들과 간접적으로 관련있는 프로세스 리스트

EXTRA INFORMATION : 덤프 레벨에 따른 프로세스 Errorstack 등의 추가 정보
STATE OF NODES : 모든 세션들 DEPENDENCY GRAPH
  IN_HANG - HANG
  IGN - IGNORE
  LEAF - A waiting leaf node
  LEAF_NW - A running leaf node
  NLEAF - STUCK
세션 STATE 설명입니다.
IN_HANG : 심각한 상태로, 이 상태의 세션은 DEADLOCK 가능성이 있습니다 .
IGN and IGN_DMP : IDLE 상태이므로 무시하셔도 됩니다.
LEAF and LEAF_NW : 이 상태로 Wait Chain 의 가장 앞에 있으면,

                             바로 이 세션이 Blocker 세션입니다.
NLEAF : STUCK 세션으로, 다른 세션이 리소스를 잡고 안 놓아 주는 상태

           로 Performance 이슈일가능성이 높습니다.
 
DB HANG 이것만은 알아두세요!!!
데이터베이스 HANG : DB 연결될 때
SQL> oradebug setmypid

자신의 Process ID 지정 아마도, trace file 생성을 위해서 임의로 지정하는 듯
SQL> oradebug unlimit

Trace file 무한으로 설정
SQL> oradebug hanganalyze 1 

빨리 Blocker 찾으세요

Trace 화일을 통해서 문제의 Process ID 를 서치

심도 있게 더 깊이 분석시 아마도 setospid를 통해서 Blocker ID 를 찾은수

다시 trace 를 시도 하면 될듯
SQL> oradebug dump systemstate 10 ..

다른세션에서 3분3번

 

데이터베이스 HANG : DB 연결안 될 때
$ dbx .a PID $ORACLE_HOME/bin/oracle .. Oracle PID
dbx) call ksudss(10) or print ksudss(10)
dbx) detach



RAC에서 다른 Instance와의 연관된 내용까지 분석하려면 다음과 같은 명령문을 사용해야 한다.

SQL> oradebug setinst all
SQL> oradebug --g def hanganalyze 1

 

SQL> oradebug hanganalyze <level> -- 예: oradebug hanganalyze 3
Level에 따른 출력 내용은 다음과 같다.

    * 10 - Dump all processes (IGN state)
    * 5 - Level 4 + Dump all processes involved in wait chains (NLEAF state)
    * 4 - Level 3 + Dump leaf nodes (blockers) in wait chains (LEAF,LEAF_NW,IGN_DMP state)
    * 3 - Level 2 + Dump only processes thought to be in a hang (IN_HANG state)
    * 1-2 - Only HANGANALYZE output, no process dump at all


[출처] Oradebug Command|작성자 타락천사

반응형
반응형

오라플에서 에러가 발생했을 때, 어떤 SQL문이 문제인가를 찾아낼 필요가 있습니다. 예를 들어, Alert.log 파일에 다음과 같은 에러 메시지가 기록되어 있습니다.
1 Fri Mar 05 09:47:53 2010
2 ORA-1652: unable to extend temp segment by 128 in tablespace                 VERY_SMALL_TBS
어떤 SQL문이 범인인가를 알지 못하면, 해결하기가 쉽지 않습니다.

이런 경우에 시도해 볼 수 있는 것이 ErrorStack 덤프입니다. ErrorStack 덤프를 진단 이벤트와 함께 사용하면 에러를 일으키는 SQL 문장이 트레이스 파일에 기록되도록 할 수 있습니다.

간단한 예를 설명해 보겠습니다. 우선 작은 크기(10m)의 테이블스페이를 만듭니다.

1 UKJA@ukja1021> create tablespace very_small_tbs
2   2  datafile size 10m;
3   
4 Tablespace created.
ORA-01652 에러가 발생하면, ErrorStack 덤프를 실행하도록 진단 이벤트를 겁니다.
1 UKJA@ukja1021> alter system set events '1652 trace name errorstack level 1, forever';
2   
3 Session altered.
10m보다 큰 테이블을 만들면 ORA-01652 에러가 발생합니다.
01 UKJA@ukja1021> create table tbig(c1)
02   2  tablespace very_small_tbs
03   as
04   select rpad('x',1000) from dual
05   connect by level <= 10000
06   6  ;
07 select rpad('x',1000) from dual
08                            *
09 ERROR at line 4:
10 ORA-01652: unable to extend temp segment by 128 in tablespace VERY_SMALL_TBS
11   
12 UKJA@ukja1021> alter system set events '1652 trace name context off';
13   
14 Session altered.
Alert.log 파일에는 다음과 에러 메시지가 남습니다.
1 Fri Mar 05 09:47:53 2010
2 ORA-1652: unable to extend temp segment by 128 in tablespace                 VERY_SMALL_TBS
프로세스의 트레이스 파일에는 에러 발생시의 SQL문과 CallStack 트레이스가 기록되어 있습니다.
01 ORA-01652: unable to extend temp segment by 128 in tablespace VERY_SMALL_TBS
02 Current SQL statement for this session:
03 create table tbig(c1)
04 tablespace very_small_tbs
05 as
06 select rpad('x',1000) from dual
07 connect by level <= 10000
08 ----- Call Stack Trace -----
09 calling              call     entry                argument values in hex      
10 location             type     point                (? means dubious value)     
11 -------------------- -------- -------------------- ----------------------------
12 _ksedst+38           CALLrel  _ksedst1+0           0 1
13 _ksedmp+898          CALLrel  _ksedst+0            0
14 _ksddoa+2088         CALLreg  00000000             1
15 _ksdpcg+238          CALLrel  _ksddoa+0            A9615C0 93C78C0
16 _ksdpec+230          CALLrel  _ksdpcg+0            674 C04A478 1
17 __PGOSF89__ksfpec+1  CALLrel  _ksdpec+0            674
18 18                                                 
19 _kgesev+88           CALLreg  00000000             A0C6760 674
20 _ksesec2+39          CALLrel  _kgesev+0            A0C6760 93C0020 674 2 C04A4E4
21 _ktsxterr+316        CALLrel  _ksesec2+0           674 0 80 0 1 E C04A55E
22 _ktfbtgex1+969       CALLrel  _ktsxterr+0          792DE5C 80 0
23 _ktsxs_add+1766      CALLrel  _ktfbtgex1+0         C04AD8C 3D C04AA50 80 18 A 3
24                                                    0 0 C04AD50 37B3EE88
25 _ktsxssr_sadd+1409   CALLrel  _ktsxs_add+0         C04B048 C04AD8C 80 A 3 0 18 1
26                                                    C04B11C C04AE08 C04ADC0 0
27                                                    C04AD50
28 _ktrsexec+372        CALL???  00000000             C04B0D8
29 _ktelwbl+770         CALLrel  _ktrsexec+0          C04B0D8
30 _kdblba+168          CALLrel  _ktelwbl+0           792DE5C 1
31 _kdblGetBlockDba+58  CALLrel  _kdblba+0            
32 _kdblgb+26           CALLrel  _kdblGetBlockDba+0   C04B3C8 792DD9C
33 _kdblailb+2101       CALLrel  _kdblgb+0            
34 _kdblai+1560         CALLrel  _kdblailb+0          C04B3C8 792DC9C 792DD9C 0 1 1
35 _klclil1r+187        CALLrel  _kdblai+0            
36 _qerltRop+514        CALLrel  _klclil1r+0          792DBEC
37 _qercbiFetch+935     CALLreg  00000000             34C4F034 7FFF
38 _rwsfcd+95           CALL???  00000000             34C4F384 1C72EB4 34C4F034
39                                                    7FFF
40 _qerltFetch+368      CALL???  00000000             34C4F148 1C72EB4 34C4F034
41                                                    7FFF
42 _ctcdrv+7674         CALL???  00000000             34C4F034 1D28394 C04CE30 1
43 _opiexe+12257        CALLrel  _ctcdrv+0            34EE5F50 C04D548 C04D510
44 _opiosq0+6088        CALLrel  _opiexe+0            4 0 C04D8C0
45 _kpooprx+232         CALLrel  _opiosq0+0           3 E C04D9D8 A4
46 _kpoal8+775          CALLrel  _kpooprx+0           C04F6F8 C04E224 6D 1 0 A4
47 _opiodr+1099         CALLreg  00000000             5E 17 C04F6F4
48 _ttcpip+1273         CALLreg  00000000             5E 17 C04F6F4 0
49 _opitsk+1017         CALL???  00000000             
50 _opiino+1087         CALLrel  _opitsk+0            0 0
51 _opiodr+1099         CALLreg  00000000             3C 4 C04FC8C
52 _opidrv+819          CALLrel  _opiodr+0            3C 4 C04FC8C 0
53 _sou2o+45            CALLrel  _opidrv+0            3C 4 C04FC8C
54 _opimai_real+112     CALLrel  _sou2o+0             C04FC80 3C 4 C04FC8C
55 _opimai+92           CALLrel  _opimai_real+0       2 C04FCB8
56 _OracleThreadStart@  CALLrel  _opimai+0            
57 4+708                                              
58 7C80B710             CALLreg  00000000
ErrorStack 덤프는 그 레벨에 따라 다양한 유용한 정보를 제공해줍니다. 아래 아티클에서 상세한 정보를 얻을 수 있습니다.

출처 : http://ukja.tistory.com/307

반응형
반응형

고객사에서 아래의 작업이 매 주 일어납니다.

 

1. 운영 DB서버의 컨트롤/리두로그/데이터 파일 부분을 테스트 DB서버로 이미지카피를 합니다.

   (DB 엔진부분이나 설정파일은 복사하지 않습니다.)

2. 테스트 DB의 SID를 테스트에 맞게 변경해줍니다.

 

예전같으면 벌벌떨면서 진행했던 SID 변경 작업이지만,

10.x 이상의 버젼에서 nid라는 도구가 도입되면서 아주 간단한(실수를 하지 않는다면) 작업으로 변했습니다.

 

아래는 변경 절차입니다.

운영 DB서버의 SID는 PROD, 테스트 DB서버의 SID는 TEST라고 하겠습니다.

 

##########################################################################

이미지 카피가 정상적으로 되어 DB가 정상적으로 올라오는지 확인하는 부분

##########################################################################

 

1) 이미지카피가 완료된 후....

 

2) .profile에 설정되어 있는 SID를 PROD로 변경합니다.

 

3) . .profile로 변경된 사항을 적용합니다.

 

4) cp inittest.ora initprod.ora 명령으로 기 존재하는 파라메터 파일을 이용하여 초기화 파라메터 파일을 생성합니다.

 

5) 생성한 initprod.ora 파일을 열어서, controlfile의 위치를 실제 파일이 위치하는 곳으로 변경하고..

   db_name 파라메터를 prod로 변경하고..

   local listener 파라메터 설정 부분을 remark 합니다.

 

6) 패스워드 파일 사용중이라면 orapwd 명령으로 패스워드 파일을 생성합니다. 

 

7) sqlplus 에 로그인하고, startup 명령으로 DB를 살려서 정상적으로 올라오는지 확인합니다.

 

##########################################################################

SID을 바꾸고 DB가 정상적으로 올라오는지 확인하는 부분

##########################################################################

8) DB가 정상이라면 shutdown 명령으로 DB를 내립니다.

 

9) DB를 Mount 단계까지 올립니다.

 

10) 다른 창을 하나 띄워서 아래의 명령어로 SID를 변경합니다.

    nid target=sys/<패스워드> dbname=TEST setname=yes

    (nid가 실행되면 nid가 Mount되어 있는 DB를 shutdown 시킵니다.)

    <실제 수행 화면>

[oracle@sbiztdb1:prod:/sks1/oracle]nid target=sys/<패스워드> dbname=TEST setname=y

DBNEWID: Release 10.2.0.4.0 - Production on Sat Jun 13 22:53:29 2009

Copyright (c) 1982, 2007, Oracle.  All rights reserved.

Connected to database PROD (DBID=3426403114)

Connected to server version 10.2.0

Control Files in database:
    /dev/hdvg21/rlvol_0500M0001
    /dev/hdvg22/rlvol_0500M0006
    /dev/hdvg23/rlvol_0500M0011

Change database name of database PROD to TEST? (Y/[N]) => Y

Proceeding with operation
Changing database name from PROD to TEST
    Control File /dev/hdvg21/rlvol_0500M0001 - modified
    Control File /dev/hdvg22/rlvol_0500M0006 - modified
    Control File /dev/hdvg23/rlvol_0500M0011 - modified
    Datafile /dev/hdvg21/rlvol_4000M0001 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0002 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0008 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0042 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0009 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0003 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0004 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0005 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0006 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0007 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0008 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0009 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0011 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0012 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0013 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0014 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0015 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0016 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0017 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0018 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0019 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0020 - wrote new name
    Datafile /dev/hdvg23/rlvol_8000M0021 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0022 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0023 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0024 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0025 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0026 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0027 - wrote new name
    Datafile /dev/hdvg24/rlvol_8000M0028 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0030 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0031 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0032 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0034 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0035 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0036 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0037 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0038 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0002 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0003 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0004 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0005 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0007 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0008 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0009 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0010 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0011 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0013 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0015 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0040 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0041 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0042 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0043 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0044 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0047 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0049 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0050 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0051 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0017 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0001 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0003 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0010 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0012 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0014 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0016 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0018 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0019 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0020 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0021 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0019 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0020 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0022 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0022 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0023 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0054 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0053 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0055 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0056 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0023 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0024 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0026 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0027 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0028 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0029 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0030 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0031 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0033 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0034 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0035 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0036 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0024 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0025 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0005 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0058 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0059 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0060 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0061 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0062 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0063 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0064 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0038 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0039 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0040 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0041 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0047 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0048 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0049 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0050 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0001 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0002 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0026 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0027 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0003 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0004 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0006 - wrote new name
    Datafile /dev/hdvg24/rlvol_2000M0028 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0029 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0066 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0067 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0005 - wrote new name
    Datafile /dev/hdvg21/rlvol_1000M0006 - wrote new name
    Datafile /dev/hdvg21/rlvol_4000M0006 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0044 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0052 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0069 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0070 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0048 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0054 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0055 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0043 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0070 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0033 - wrote new name
    Datafile /dev/hdvg25/rlvol_8000M0029 - wrote new name
    Datafile /dev/hdvg26/rlvol_8000M0039 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0018 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0021 - wrote new name
    Datafile /dev/hdvg24/rlvol_4000M0025 - wrote new name
    Datafile /dev/hdvg26/rlvol_4000M0037 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_4000M0046 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0030 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0032 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0033 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0056 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0057 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0058 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0059 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0060 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0061 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0062 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0012 - wrote new name
    Datafile /dev/hdvg22/rlvol_4000M0014 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0002 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0051 - wrote new name
    Datafile /dev/hdvg29/rlvol_4000M0063 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0004 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0034 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0035 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0036 - wrote new name
    Datafile /dev/hdvg23/rlvol_4000M0016 - wrote new name
    Datafile /dev/hdvg22/rlvol_1000M0007 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0037 - wrote new name
    Datafile /dev/hdvg22/rlvol_8000M0010 - wrote new name
    Datafile /dev/hdvg21/rlvol_2000M0007 - wrote new name
    Datafile /dev/hdvg25/rlvol_4000M0032 - wrote new name
    Datafile /dev/hdvg28/rlvol_4000M0053 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0011 - wrote new name
    Datafile /dev/hdvg22/rlvol_2000M0013 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0015 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0064 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0065 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0066 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0067 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0069 - wrote new name
    Datafile /dev/hdvg30/rlvol_4000M0068 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0038 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0039 - wrote new name
    Datafile /dev/hdvg23/rlvol_2000M0017 - wrote new name
    Datafile /dev/hdvg25/rlvol_2000M0031 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0040 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0041 - wrote new name
    Datafile /dev/hdvg26/rlvol_2000M0042 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0043 - wrote new name
    Datafile /dev/hdvg28/rlvol_1000M0044 - wrote new name
    Datafile /dev/hdvg28/rlvol_1000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0044 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0045 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0046 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0047 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0048 - wrote new name
    Datafile /dev/hdvg27/rlvol_2000M0049 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0050 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0051 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0052 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0053 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0054 - wrote new name
    Datafile /dev/hdvg28/rlvol_2000M0055 - wrote new name
    Datafile /dev/hdvg21/rlvol_8000M0001 - wrote new name
    Datafile /dev/hdvg27/rlvol_8000M0046 - wrote new name
    Datafile /dev/hdvg28/rlvol_8000M0052 - wrote new name
    Datafile /dev/hdvg29/rlvol_8000M0057 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0065 - wrote new name
    Datafile /dev/hdvg30/rlvol_8000M0068 - wrote new name
    Control File /dev/hdvg21/rlvol_0500M0001 - wrote new name
    Control File /dev/hdvg22/rlvol_0500M0006 - wrote new name
    Control File /dev/hdvg23/rlvol_0500M0011 - wrote new name
    Instance shut down

Database name changed to TEST.
Modify parameter file and generate a new password file before restarting.
Succesfully changed database name.
DBNEWID - Completed succesfully.

 

11) .profile에 설정되어 있는 SID를 TEST로 변경합니다.   

 

12) sqlplus 에 로그인하고, startup 명령으로 DB를 살려서 정상적으로 올라오는지 확인합니다.

    (pfile을 가지고 spfile을 생성한 후 다시 startup하여 spfile로 DB가 운영되도록 수정합니다.)

   SQL>startup pfile=inittbizdb.ora
   SQL>create spfile from pfile;
   SQL>shutdown immediate
   SQL>startup

 

13) 아무런 문제가 없다면 작업 종료...

 

일반적으로 SID만 변경하시는 분들은 8)부터만 수행하시면 됩니다. 1)~7)까지는 이미지카피 후 정합성 확인하는 부분입니다.

 

좀 더 자세한 내용은 nid로 오라클 사이트에서 검색하시면 찾으실 수 있을 겁니다....

 

업무에 도움이 되셨길 빕니다....^^

반응형

'Database > ORACLE' 카테고리의 다른 글

Oradebug 사용법  (0) 2010.03.26
ErrorStack 덤프를 이용해 문제 SQL 찾아내기  (0) 2010.03.26
Oracle SID error  (0) 2010.02.09
rman Tool  (0) 2010.02.01
WS1-2-ch18. Data Pump (expdp/impdp) overview  (0) 2010.02.01
반응형
현상 : 로컬에서
sqlplus tiger/scott  정상적으로 접속되나
sqlplus tiger/scott@orcl 으로 접속하면 안되는 현상 발생...

이유는 SID가 대소문자를 가리기 때문 !

확인 파일(check file)
로그인 파일 : .profile (ORACLE_SID 변수값)
리스터 파일 : listener.ora (SID 변수값)

[hiway:/home/user] sqlplus test8/test8

SQL*Plus: Release 9.2.0.4.0 - Production on Wed Jul 6 16:13:27 2005

Copyright (c) 1982, 2002, Oracle Corporation.  All rights reserved.

ERROR:
ORA-01034: ORACLE not available
ORA-27101: shared memory realm does not exist
Linux Error: 2: No such file or directory

답변 : >>>>>>>>> tnsname.ora 에 SID 에 대소문자 구분을 확인해서
환경변수와 똑같이 설정해야한다
.....
export ORACLE_SID=ORA9
.....


출처 : http://myweb.bcpark.net/~hosuck/gnu3/?doc=bbs/gnuboard.php&bo_table=PG_ORACLE&page=8&wr_id=6
반응형
반응형

복구 관리자 (recovery manager:rman)는 데이터베이스의 백업과 복구에 관련된 정보를 저장하고 필요한 경우 백업과 복구 절차를 수행해 주는 유틸리티이다. 데이터베이스, 테이블스페이스, 데이터파일, 컨트롤 파일, 아카이브 파일별로 백업할 수 있으며, 백업 시 사용되지 않는 블록을 제외하고 백업할 수 도 있다. 또한 백업 시 손상된 블록의 사용 가능 여부를 확인해 주기도 한다.

rman 툴은 자체적인 스크립트 해석 인터프리터를 가진 명령언어 인터프리터(command language interpreter)이므로 입력된 명령을 해석하여 실행하게 된다. 예를 들어, backup, restore, copy, recover와 같은 명령을 rman 툴에서 실행할 수 있는 것이다.

rman의 형식은 다음과 같다.

형식

RMAN  [TARGET connectStringSpec
      ¦ { CATALOG connectStringSpec }
      ¦ LOG ['] filename ['] [APPEND ]
      ......
      ]...
      
connectStringSpec::=
  ['] [userid] [/ [password]] [@net_service_name] ['] 




rman 구성

RMAN 시작과 DB에 연결
다음 예제는 간단하게 rman에 접속하고 접속해지 하는 과정이다.
【예제】 ☜ rman 시각과 끝
$ rman

RMAN> exit

$ 
SQL*Plus로 데이터베이스에 접속하듯이 RMAN으로도 데이터베이스에 접속하는데,
그 차이점은 RMAN은 SYSDBA 권한을 가지고 타킷과 보조 데이터베이스에 접속해야 하는데 AS SYSDBA 키워드는 사용하지 않아도 묵시적으로 가진 것으로 간주하기 때문에 의도적으로 표시하지 않아도 된다는 점만 다르다.

RMAN에 연결되면 CONNECT TARGET을 실행해야 타킷 데이터베이스에 접속이 이루어진다.

【예제】☜ target DB에 관리자로 접속 
$ rman

RMAN> connect target /

connected to target database: ORCL (DBID=1204356616)

RMAN> exit

Recovery Manager complete.
$
다음 예는 RMAN 세션중에 출력되는 텍스트 파일을 로그 파일(/tmp/msglog.log)에 추가하도록 하는 예제이다.
【예제】☜ log 파일을 지정하면서 접속 
$ rman TARGET / LOG /tmp/msglog.log APPEND
RMAN> exit
$
이처럼 rman 툴을 이용하여 rman 클라이언트로 들어간 다음에, rman> 프롬프트에서 입력되는 명령은 그 문장의 끝에 세미콜론(;)을 붙여야 하는데, 다만 예외로 STARTUP, SHUTDOWN, CONNECT 명령은 세미콜론을 붙여도 되고 안 붙여도 된다

【예제】

RMAN> CONNECT TARGET
RMAN> BACKUP DATABASE;

RMAN> BACKUP DATABASE
2>  INCLUDE CURRENT
3>  CONTROLFILE
4>  ;
디폴트 RMAN configuration 보기

RMAN이 백업과 복구를 실행하는 구성을 미리 작성한 디폴트 configure가 준비되어 적용된다.
configure란 백업장치를 지정하고, 백업 장치에 접속(이를 channel이라 부름)의 구성을 설정하는 것이다.
현재 작성된 configure를 다음과 같이 확인할 수 있다.

1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET /

2) SHOW ALL 명령을 실행한다.
RMAN> SHOW ALL;


$ rman TARGET /
RMAN> show all;

using target database control file instead of recovery catalog
RMAN configuration parameters for database with db_unique_name ORCL are:
CONFIGURE RETENTION POLICY TO REDUNDANCY 1; # default
CONFIGURE BACKUP OPTIMIZATION OFF; # default
CONFIGURE DEFAULT DEVICE TYPE TO DISK; # default
CONFIGURE CONTROLFILE AUTOBACKUP OFF; # default
CONFIGURE CONTROLFILE AUTOBACKUP FORMAT FOR DEVICE TYPE DISK TO '%F'; # default
CONFIGURE DEVICE TYPE DISK PARALLELISM 1 BACKUP TYPE TO BACKUPSET; # default
CONFIGURE DATAFILE BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE ARCHIVELOG BACKUP COPIES FOR DEVICE TYPE DISK TO 1; # default
CONFIGURE MAXSETSIZE TO UNLIMITED; # default
CONFIGURE ENCRYPTION FOR DATABASE OFF; # default
CONFIGURE ENCRYPTION ALGORITHM 'AES128'; # default
CONFIGURE COMPRESSION ALGORITHM 'BZIP2'; # default
CONFIGURE ARCHIVELOG DELETION POLICY TO NONE; # default
CONFIGURE SNAPSHOT CONTROLFILE NAME TO '/export/home/oracle/app/oracle/product/110.1/dbs/snapcf_orcl.f'; # default

RMAN> 

나열되는 항목은 CONFIGURE 명령으로 재작성할 수 있으며, 다음은 channel를 configure하는 예시이다.

CONFIGURE DEFAULT DEVICE TYPE TO DISK; # backup goes to disk
CONFIGURE DEVICE TYPE sbt PARALLELISM 2; # 2 channels used in in channel
CONFIGURE CHANNEL 1 DEVICE TYPE DISK FORMAT '/disk1/%U' # 1st channel to disk1
CONFIGURE CHANNEL 2 DEVICE TYPE DISK FORMAT '/disk2/%U' # 2nd channel to disk2
BACKUP DATABASE; # backup - 1st channel goes to disk1 and 2nd to disk2

데이터베이스 백업

BACKUP 명령으로 파일을 백업한다. RMAN은 configure로 설정된 장치에 데이터를 백업하는데, 디폴트는 disk이다.
flash recovery가 가능하고 FORMAT 매개변수를 지정하지 않은 경우라면, RMAN은 recovery 영역에 unique한 이름으로 자동적으로 백업을 생성한다.
RMAN은 디폴트로 image copy보다는 백업 셋을 생성하는데, 여기서 image copy란 유닉스의 cp 명령어로 복사하는 것을 image copy 라 한다.
backup set은 하나 이상의 backup piece로 RMAN으로만 억세스할 수 있도록 물리적 파일을 복사하는 것을 뜻한다.

BACKUP AS COPY 명령은 데이터베이스 파일을 디스크에 bit-for-bit로 image copy를 수행하는데 이는 RMAN에서만 이용할 수 있다.

option 예제 설명
FORMAT
BACKUP
 FORMAT 'AL_%d/%t/%s/%p'
 ARCHIVELOG LIKE '%arc_dest%';
백업할 조각의 위치와 이름을 지정함
%U : 유일한 이름
%d : DB_NAME
%t : timestamp를 가짐
%s : number를 가짐
%p : backup piece number
TAG
BACKUP
 TAG 'weekly_full_db-bkup'
 DATABASE MAXSETSIZE 10M;
백업 라벨에 사용자 정의 문자로 지정하지만,
TAG을 지정하지 않으면 date와 time이 디촐트임

【예제】☜ 데이터베이스를 백업

ARCHIVELOG 모드
1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET / 2) BACKUP DATABASE 명령을 실행한다.
RMAN> BACKUP DATABASE PLUS ARCHIVELOG;
NOARCHIVELOG 모드
데이터베이스는 반드시 mount 상태이어야 한다.

1) RMAN을 시작하고 타킷 DB에 접속한다.
$ rman TARGET / 2) shutdown하고 mount한다.
RMAN> SHUTDOWN IMMEDIATE
RMAN> STARTUP FORCE DBA;
RMAN> SHUTDOWN IMMEDIATE
RMAN> STARTUP MOUNT; 3) BACKUP DATABASE를 실행한다.(아래 둘 중 하나)
RMAN> BACKUP DATABASE;
RMAN> BACKUP AS COPY DATABASE; 4) 데이터베이스를 open한다.
RMAN> ALTER DATABASE OPEN;

앞 예제에서와 같이 archive mode와 noarchive mode을 예제로 익혔다.

incremental backup

incremental backup은 BACKUP INCREMENTAL 명령을 사용하여 실행하는데, 이는 full database backup보다 더 빠르다.
그러므로 recovery도 redo logs만 사용하는 경우보다 더 신속하게 복구할 수 있다.
incremental backup이나 full backup 모두 level 0의 내용은 동일하지만, full backup과 달리 level 0 backup은 incremental backup에 관한 사항이 담겨있다.
level 1 incremental backup은 이전의 incremental backup 이후의 변경된 내용만 담긴다.
그래서 level 1 백업을 cumulative incremental backup이라하고, level 0 백업을 differential incremental backup이라하는데, differential이 디폴트이다.

【예제】☜ 데이터베이스의 incremental 백업
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) BACKUP INCREMENTAL 명령을 실행한다.
다음은 level 0 incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 0 DATABASE;

다음은 level 1 cumulative incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 1 CUMULATIVE DATABASE;

다음은 level 1 differential incremental 백업인 경우

RMAN> BACKUP INCREMENTAL LEVEL 1 DATABASE;

incrementally updated backup

incrementally updated 백업은 BACKUP FOR RECOVER OF COPY 명령을 사용한다.
FOR RECOVER OF COPY 문의 옵션은 다음과 같다.

option 예제
FOR RECOVER OF COPY WITH TAG 'tag_name' BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY WITH TAG 'incr_update' DATABASE;
FOR RECOVER OF COPY DATAFILECOPY FORMAT 'format' BACKUP INCREMENTAL LEVEL 1 FOR RECOVER OF COPY DATAFILECOPY FORMAT 'disk2/df1.cpy' DATABASE;

【예제】☜ 데이터베이스의 incrementally updated 백업
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) RECOVER COPY와 BACKUP INCREMENTAL 명령을 실행한다.
다음 스크립트를 실행한다.


     RECOVER COPY OF DATABASE
       WITH TAG 'incr_update';
     BACKUP
       INCREMENTAL LEVEL 1
       FOR RECOVER OF COPY WITH TAG 'incr_update'
       DATABASE;

database 파일과 백업의 validating

VALIDATE 명령을 사용하여 모든 데이터베이스 파일이 존재를 확인하고, 바른 위치에 있는지 확인하며, 또한 물리적 오류의 여지를 확인한다.
CHECK LOGICAL옵션을 사용하여 논리적 오류도 확인할 수 있다.

【예제】☜ 데이터베이스 파일의 유효성 확인
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) VALIDATE 명령을 해당파일에 실행한다.

   BACKUP VALIDATE CHECK LOGICAL
     DATABASE ARCHIVELOG ALL;
만약 각각의 블럭에 대한 유효성 체크는 다음과 같이 할 수 있다.

VALIDATE DATAFILE 4 BLOCK 10 TO 13;

다음은 백업셋에 대한 유효성 체크의 예이며, 백업셋은 LIST BACKUP를 실행하여 확인할 수 있다.

VALIDATE BACKUPSET 3;

RMAN에 동작하는 명령어로 구성된 파일

데이터베이스를 주기적으로 반복하여 백업한다는 것은 실증하기 때문에 이러한 동작을 RMAN 명령으로 작성한 명령 파일을 하나의 스크립트로 작성하여 @아규먼트와 파일이름을 지정하여 실행 시키면 편리하다.

【예제】☜ RMAN에서 동작할 스크립트 생성과 실행
1) vi와 같은 문서편집기로 RMAN 명령문으로 구성된 파일을 작성한다.


    #my_commnad_file.txt
    BACKUP DATABASE PLUS ARCHIVELOG;
    LIST BACKUP;
    EXIT;

2) RMAN을 구동하고 작성한 스크립트를 @ 아규먼트로 실행시킨다.

구 분 명령어 실행 실행 결과
방법1 $ rman TARGET / @my_command_file.txt 실행이 완료되면 RMAN에서 exit함
방법2 RMAN> @my_command_file.txt **end-of-file** 메시지가 출력되며 RMAN에서 exit하지 않음

작성되는 명령문 스크립트에서 비실행문은 #으로 시작되고 또한 중간에 #을 넣으면 #이하는 비실행으로 처리한다.
rman 프롬프트에서 명령을 입력할 때도 #이하는 비실행문으로 처리한다

【예제】☜
RMAN> BACKUP # 이 부분부터 줄 끝까지는 비실행임
2> SPFILE;

Starting backup at 04-JAN-10
using channel ORA_DISK_1
channel ORA_DISK_1: starting full datafile backup set
channel ORA_DISK_1: specifying datafile(s) in backup set
including current SPFILE in backup set
channel ORA_DISK_1: starting piece 1 at 04-JAN-10
channel ORA_DISK_1: finished piece 1 at 04-JAN-10
piece handle=/export/home/oracle/flash_recovery_area/ORCL/backupset/2010_01_04/o1_mf_nnsnf_TAG20100104T130430_5n2t6gt7_.bkp tag=TAG20100104T130430 comment=NONE
channel ORA_DISK_1: backup set complete, elapsed time: 00:00:01
Finished backup at 04-JAN-10

RMAN>

RMAN 동작의 레포트

RMAN의 LISTREPORT 문을 사용하여 RMAN을 사용한 백업 상태에 대한 정보를 알 수 있고, SHOW ALL 문을 사용하여 configuration에 대한 정보를 확인할 수 있다.

백업정보 list

LIST BACKUPLIST COPY 문을 사용하여 백업과 데이터파일에 대한 정보를 나타낸다.
다음 표는 백업에 대한 LIST 문의 옵션이다.

option 예제 설명
BY BACKUP LIST BACKUP OF DATABASE BY BACKUP 백업셋의 출력으로 디폴트임
BY FILE LIST BACKUP BY FILE 백업된 파일에 대한 정보
SUMMARY LIST BACKUP SUMMARY 요약이 출력되는데 디폴트이며 출력은 VERBOSE임
EXPIRED LIST EXPIRED COPY RMAN에의 해 기록된 백업에 관한 목록이지만, 최근 CROSSCHECK 문에 의한 것은 제외함
RECOVERABLE LIST BACKUP RECOVERABLE AVAILABLE 상태에 있는 datafile이 backup, copy된 사항이 나열됨

【예제】☜ LIST BACKUP/COPY 실행
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) LIST 문을 실행한다.

RMAN> LIST BACKUP OF DATABASE;
RMAN> LIST COPY OF DATAFILE 1,2;
RMAN> LIST BACKUP OF ARCHIVELOG FROM SEQUENCE 10;
RMAN> LIST BACKUPSET OF DATAFILE;

데이터베이스 파일과 백업에 관한 REPORT

REPORT 문을 실행하여 LIST 문보다 더 다양한 정보를 알 수 있다.
다음은 REPORT 문의 옵션이다.

option 예제 설명
NEED BACKUP REPORT NEED BACKUP DATABASE 백업해야할 파일을 보임, 추가적으로 REDUNDANCY, RECOVERY WINDOW 를 사용할 수 있음
OBSOLETE REPORT OBSOLETE backup retention policy로 구성된 쓸모없는(폐기된) 백업을 나열함
SCHEMA REPORT SCHEMA 데이터베이스 내의 테이블스페이스와 데이터파일을 출력
UNRECOVERABLE REPORT UNRECOVERABLE 최근의 데이터파일 백업에서 복구될수 없는 데이터파일을 출력

【예제】☜
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) REPORT 문을 실행한다.

RMAN> REPORT SCHEMA;
RMAN> REPORT OBSOLETE;

RMAN 백업 Maintaining

타킷 데이터베이스의 control 파일에 저장된 RMAN의 정보가 RMAN maintence command에 의해 사용된다.

Crosschecking backup

CROSSCHECK 명령에 의해 RMAN에 의해 백업된 논리적 기록물과 저장매체에 있는 파일을 동기화한다.

【예제】☜ crosscheck all backups & copies on disk
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) CROSSCHECK 문을 실행한다.

RMAN> CROSSCHECK BACKUP;
RMAN> CROSSCHECK COPY;

Delete Obsolete Backups

DELETE 명령으로 RMAN으로 디스크나 테이프에 백업하였지만 쓸모없는 백업이나 파일을 삭제하게 된다.

control 파일의 파일 상태를 DELETED로 갱신하고, NOPROMPT를 지정하지 않으면 삭제할 때 의지를 묻게된다.
DELETE OBSOLETE 명령은 더 이상 필요없는 백업이나 복사된 파일을 지울 때 사용된다.

【예제】☜ delete obsolete backups & copies
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) DELETE OBSOLETE 문을 실행한다.

RMAN> DELETE OBSOLETE;

Diagnosing & Repairing Failures with Data Recovery Advisor

data recovery advisor를 이용하여 간단하게 데이터베이스의 문제점을 진단하고 수리할 수 있다.

Listing Failures & Determing Repair Options

Failure란 데이터의 오염(corruption)을 의미한다. failure에는 fail priorityfailure status가 있는데, priority에는 CRITICAL, HIGH, LOW가 있으며, 상태는 OPEN이나 CLOSED일 수 있다.

LIST FAILURE : 모든 종류의 failure를 출력
ADVISE FAILURE : repair option으로 수동과 자동을 결정

【예제】☜ LIST FAILURE & ADVISE FAILURE
RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

RMAN> LIST FAILURE;
RMAN> ADVISE FAILURE;

Repairing Failures

앞의 LIST FAILURE나 ADVISE FAILURE를 실행하고 나서 REPAIR FAILURE 명령으로 수리할 수 있다.

【예제】☜ REPAIR FAILURE
RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

RMAN> REPAIR FAILURE;

Flashback Database

데이터베이스를 과거 어느 시점으로 되돌리는 것으로 이는 미디어 복구와 달리데이터파일을 restore할 필요가 없다.
FLASHBACK DATABASE 명령을 사용하면 과거 어느 시점으로 되돌릴 수 있는데, 이 기능은 반드시 데이터베이스가 mount 되어 있어야 한다.

【예제】☜ Flashback database
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 데이터베이스가 mount 되어 있어야 한다.

RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;

3) FLASHBACK DATABASE를 다음중 하나를 실행한다.


SQL> select name,scn, time, database_incarnation#,
  2  guarantee_flashback_database
  3  from v$restore_point
  4  where guarantee_flashback_database='YES';

RMAN> FLASHBACK DATABASE TO SCN 86115;
RMAN> FLASHBACK DATABASE TO RESTORE POINT BEFORE_CHANGE;
RMAN> FLASHBACK DATABASE TO TIME "TO_DATE('11/20/10','MM/DD/YY')";

4) 데이터베이스를 SQL*Plus에서 검증하기 위해 open한다.

RMAN> SQL "ALTER DATABASE OPEN READ ONLY";

5) 데이터베이스를 open한다.

RMAN> SHUTDOWN IMMEDIATE;
RMAN> STARTUP MOUNT;
RMAN> ALTER DATABASE OPEN RESETLOGS;

Restore & Recover Database Files

RESTORE나 RECOVER 명령으로 데이터베이스 파일을 복구할 수 있다.

데이터베이스 파일 복구 준비

RESTORE ... PREVIEW 명령으로 사전에 미리보기를 하지만 RESTORE는 실행되지 않는다.

【예제】☜ Preview a database restore & recovery
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 필요한 경우라면 테이블스페이스와 데이터파일을 확인한다.

RMAN> REPORT SCHEMA;

3) RESTORE DATABASE 명령에 PREVIEW 옵션을 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

데이터베이스 전체를 recover

RESTORE DATABASE와 RECOVER DATABASE 명령을 사용하여 데이터베이스 전체를 복구할 수 있다.

【예제】☜ Recover whole database
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 파일 복구 준비를 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

3) 데이터베이스를 mount 상태로 만든다.

RMAN> STARTUP FORCE MOUNT;

4) 데이터베이스를 restore한다.

RMAN> RESTORE DATABASE;

5) 데이터베이스를 recover한다.

RMAN> RECOVER DATABASE;

6) 데이터베이스를 open한다.

RMAN> ALTER DATABASE OPEN;

테이블스페이스만 recover

RESTORE TABLESPACE와 RECOVER TABLESPACE 명령을 사용하여 필요한 테이블스페이스만 복구할 수 있다.
데이터파일을 새 위치에 restore할 수 없다면, SET NEWNAME 명령을 RUN하고 SWITCH DATAFILE 명령이나 또는 ALTER DATABASE RENAME FILE 문으로 control file을 갱신할 수 있다.

【예제】☜ Recover tablespace when the database is open
1) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

2) 파일 복구 준비를 실행한다.

RMAN> RESTORE DATABASE PREVIEW SUMMARY;

3) OFFLINE 복구를 준비한다.(예: 테이블스페이스 이름::=users)

RMAN> SQL 'ALTER TABLESPACE users OFFLINE';

4) 테이블스페이스를 restore와 recover 한다.

RMAN>

     RUN 
        {
         SET NEWNAME FOR DATAFILE '/disk1/oradata/prod/users01.dbf'
           TO '/disk2/users01.dbf';
         RESTORE TABLESPACE users;
         SWITCH DATAFILE ALL;
         RECOVER TABLESPACE users;
        }

5) 테이블스페이스를 ONLINE한다.

RMAN> SQL 'ALTER TABLESPACE users ONLINE';

이 방법외에 RESTORE DATAFILERECOVER DATAFILE을 사용하여 데이터파일 레벨로 복구할 수 도 있다.

데이터 블럭(block)별로 recover

잘못된 데이터파일 블럭 단위로 복구도 가능한데, v$database_block_corruption 뷰에서 오류된 데이터 파일 블럭을 확인할 수 있다.

【예제】☜ Recover data blocks
1) SQLPlus에서 오류된 데이터블럭 번호를 확인한다.

SQL> SELECT NAME, VALUE FROM V$DIAG_INFO

2) RMAN을 시작하고 타킷 DB에 접속한다.

$ rman TARGET /

3) RECOVER 명령을 실행하여 블럭을 수리한다.

RMAN> RECOVER CORRUPTION LIST;

개별 블럭을 수리하려면 다음과 같이 실행한다.

RMAN> RECOVER DATAFILE 1 BLOCK 233, 235 DATAFILE 2 BLOCK 100 TO 200;


출처 : http://radiocom.kunsan.ac.kr/lecture/oracle/backup_restore/rman.html

반응형
반응형

1. 오라클 10g 의 신기능 Data Pump 의 소개

1) 개요

DB에 있는 데이터를 운영체제의 파일시스템으로 내보내는 과정을 export 라 하고, 반대로 파일 시스템을 DataBase로 들여오는 것을 Import 라고 한다. 기존의 방식을 Export/Import 라고 하고

오라클 10g에서는 이를 Data Pump 라고 통칭한다.

오라클 Data Pump는 export/import에 대한 강력한 기능들을 추가한 Utility 이다.

 

[ Data Pump 사용시  주의사항]

export/import 와 Data Pump는 서로 호화되지 않습니다.

즉 Export 유틸리티를 이용하여 백업 받은 파일은 Data Pump를 통해 Import 할 수 없으며, 마찬가지로

Data Pump 를 통해 export 된 데이터는 Import 유틸리티를 통해 Import 할 수 없습니다.

 

2) Data Pump export/Import 의 이점

JOB 콘트롤 기능 : Interactive mode를 통하여 Data Pump작업을 통제 할 수 있습니다. 작업을

                                중단시키고 재 시작할 수 있으며 동적으로 dump file을 할당 할 수 있습니다.

                                에러가 나더라도 작업이 중지될 뿐 언제든지 원인을 수정하고 재수행 할 수

                                있습니다.

병렬수행지원 : Parallel 파라미터를 이용하여 프로세스의 Data Pump 작업의 프로세스를 병렬화

                          할 수 있습니다. 병렬화 된 프로세스는 여러개의 데이터 파일에 각각 데이터를

                          쓰거나 여러개의 데이터 파일로 부터 데이터를 읽어 데이터베이스에 저장합니다.

                          병렬수행이 가능함으로 이전 보다 훨씬 강력한 기능을 제공합니다.

작업에 필요한 디스크 공간을 미리 예상 : Estimate 파라미터를 이용하여 작업 시작전에 필요한

                          물리적인 공간을 미리 예측 할 수 있다.

원격지 수행 : DB Link 를 통하여 원격지 데이터에 대한 Data Pump export/import 를 수행 할 수

                      있다

Remapping 지원 : 유저 스키마, 테이블스페이스, 데이터파일 등과 같은 정보들이 Data Pump

                                export/import 시에 변경 할 수 있습니다. 이러한 기능은 데이터 마이그레이션

                                시에 보다 많은 유연성을 제공하는데 큰 역활을 합니다

 

3) Data Access 방법

Direct-path : Direct I/O를 사용하여 OS영역의 메모리를 사용하지 않고 데이터 파일에 direct로

                        쓰게 되는 방법입니다. 메모리 사용이 적고 속도가 빠르며, 데이터 컨버전에 시간이

                        걸리지 않습니다.

[ Direct-path 가 되지 않는 경우 ]

- 클러스터 테이블인 경우

- 테이블에 활성화된 트리거가 존재할 경우

- 글로벌 인덱스를 가진 테이블이 하나의 파티션에 존재 할 경우

- LOB컬럼에 있는 도메인 인덱스

- insert 모드에서 fine_grained access control 이 enable인 경우

- BFILE을 가진 테이블인 경우

 

External Tables : 메타 데이터를 데이터베이스 내에 저장하고 데이터는 파일시스템 존재하게

                       만들어 데이터를 저장하는 방법이며 대용량 데이터를 export/import 할때

                       사용합니다.

 

[ External Table이란? ]

- Create TABLE ~~ ORGANIZATION EXTERNAL 문을 통해 만들어진 테이블

- 실질적인 데이터베이스 내에 존재하는 것이 아니라 물리적 디스크 공간에 논리적 공간을 할당 받아 데이터를 저장하며, 파일 형태로 존재합니다.

- 저장되는 데이터는 READ ONLY 데이터이며 인덱스를 생성할 수 없습니다.

- DML 작업을 수행 할 수 없습니다.

- META-DATA in DATABASE, DATA in OS라고 압축 설명 할 수있습니다.

 

3) Data Pump 의 권한설정

- 시스템에 설정된 EXP_FULL_DATABASE, IMP_FULL_DATABASE 롤을 부여함으로써 가능함

   (1) 사용자 생성 : create 문을 사용하여 사용자를 생성합니다. 패스워드는 imsi00 으로 하며,

        default tablespace는 USERS 테이블스페이스로 합니다.

        create user zoom identified by imsi00

        default tablespace users

        temporary tablespace temp

        /

   (2) 권한부여 : grant 문을 이용하여 zoom 유저에 접속(connect) 과 자원사용(resource) 에

        대한 권한을 부여한다

        grant connect, resource to zoom;

   (3) 모든 테이블에 대한 select 권한부여

        grant select any table to zoom;

   (4) zoom유저에 EXP_FULL_DATABASE, IMP_FULL_DATABASE 권한 부여

        grant EXP_FULL_DATABASE, IMP_FULL_DATABASE to zoom;

 

4) Data Pump 파일 오브젝트

4-1) Data Pump 가 사용하는 파일의 종류

■ Dump File : 테이블로 부터 데이터 또는 메터 데이터를 로드하여 저장된 파일

■ Log File : Data Pump 작업 중에 발생하는 메시지나 결과를 기록하는 파일

■ SQL File : Data Pump는 SQLFILE 이라는 옵션을 사용합니다. 이옵션을 사용 할 경우

                  Data Pump Import 작업이 수행되는 동안 DDL문을 수행 할 수있게 해줍니다

 

4-2) Data Pump 디렉토리 오브젝트

Data Pump는 사용자별 디렉토리 접근 권한을 설정할 수 있다

 

디렉토리 권한설정

(1) 사용중인 디렉토리 오브젝토 조회

      SQL> select * from dba_directories;

(2) 디렉토리 오브젝트 추가

      SQL> create directory datapump_dir1 as '/temporary/ora_tmp';

(3) 디렉토리 오브젝트 권한추가(zoom 유저에게 datapump_dir1 디렉토리 read, write 권한부여)

      SQL> grant read, write on directory datapump_dir1 to zoom;

(4) Export Pump 실행

     $expdp zoom/imsi00 directory=datapump_dir1 Tables=EMP dumpfile=zoom_dump01.dmp

 

* Data Dump 시 마다 디렉토리 오브젝트를 추가하지 않고 묵시적으로 추가

$DATA_DUMP_DIR=datapump_dir1;

$export DATA_DUMP_DIR;

 

2. Data Pump Export

1) Data Pump Export 사용하기

Command-line 이용하기

   $expdp zoom/imsi00 directory=datapump_dir1 Tables=EMP dumpfile=zoom_dump01.dmp

    - 비교적 작은 수의 옵션들이 사용되거나 간단한 구문일 때 사용합니다

    - 복잡하고 옵션이 많게 되면 수정하거나 잘못 타이핑 할때 시간이 많이 걸리게 됩니다

파라미터 파일 이용하기

    zoom.par 파일을 생성하여 다음과 같이 설정합니다

    SCHEMAS = SCOTT

    DIRECTORY=datapump_dir

    DUMPFILE=zoom01.dmp

    LOGFILE=zoom_dump.log

   

    $expdp zoom/imsi00 PARFILE=zoom.par

 

2) Data Pump Export 모드

Full Export 모드 : Full 파라미터를 사용합니다. 데이터베이스 전체를 export 받을 수 있습니다.

                            한가지 주의 할 점은 EXPORT_FULL_DATABASE 롤이 Full Export 받고자 하는

                            사용자에게 부여되어 있어야 한다는 점입니다

스키마 모드 : Schemas 파라미터를 사용합니다.

                           하나의 유저가 소유하고 있는 데이터 및 오브젝트 전체를 export 받고자 할때

                          사용할 수있는 모드입니다.

테이블스페이스 모드 : TableSpace 파라메터를 사용합니다. 하나 이상의 테이블스페이스에

                           대해 해당 테이블스페이스에 속한 모든 테이블을 받을 수 있습니다.

                           만약 TRANSPORT_TABLESPACES 파라미터를 이용한다면, 테이블 뿐 아니라

                           테이블스페이스의 메터데이터 까지 export 받게 되어 다른 서버에 dump 파일을

                           카피 한 후 import 하게 되면 테이블스페이스 및 테이블이 자동으로 생성됩니다.

테이블 모드 : TABLES 파라미터를 사용합니다.

                       하나 이상의 테이블을 export 받을 때 사용합니다

 

 

3) Data Pump Export 파라미터

파일 및 디렉토리 관련 파라미터

- DIRECTORY : 디렉토리 오브젝트를 참조하는 DIRECTORY 파라미터를 이용하여 덤프파일의

                      위치 및 로그파일의 위치를 지정 할 수 있습니다.

                      DIRECTORY=directory_object_name 형식으로 사용 할 수있습니다.

- DUMPFILE : Export를 받아 파일시스템에 저장될 덤프파일의 이름을 지정하는 파라미터이빈다.

                    파라메터를 사용할때 다음을 기억하시고 사용하시면 됩니다.

                    + %U 를 사용하여  여러개의 덤프 파일을 구분 할 수 있습니다

                       DUMPFILE=ZOOM_DUMO_%U.DMP라고 파라메터를 정의합니다.  만약 덤프

                       파일이 10개가 생성된다고 가정하면 ZOOM_DUMO_01.dmp 부터

                       ZOOM_DUMO_10.dmp 까지 %U 부분이 자동 증가하여 파일을 구분하여 줍니다.

                       %U의 범위는 01 ~ 99 까지 입니다

                   + ',' 를 이용하여 여러개의 파일명을 구분할 수 있습니다.

                      예를들어 다음과 같이

                      DUMPFILE=ZOOM_DUMO_01.dmp, ZOOM_DUMO_02.dmp,ZOOM_DUMO_03.dmp

                   + 만약 DUMPFILE 파라메터를 지정하지 않는다면 expdat.dmp 라는 파일명으로

                      오라클이 자동 선언하게 됩니다.                 

- FILESIZE  : export 받는 1개 파일의 최대크기를 지정하는 파라미터 입니다.

                   만약 export 받을 총 데이터량이 10GB이고 FILESIZE를 1GB로 지정하였다면 1GB

                   크기의 dump file이 10개 만들어 지게 됩니다.

                   FILESIZE=N [ BYTES | KILOBYTES | MEGABYTES | GIGABYTES ] 입니다.

- PARFILE : 파일에 파라메터들을 저장해 두고 Data Pump를 이용할때 마다 참조하여 작업을

                 수행하고 싶을때 PARFILE 파라메터를 사용할 수 있습니다

                  PARFILE=filename.par 형식으로 사용할 수 있으며, 파일 확장자는 아무런 영향을

                  미치지 않습니다

- LOGFILE & NOLOGFILE : 로그 파일명을 지정하는 파라메터 입니다

                  LOGFILE=logfile_name 형식으로 사용 하시면 됩니다. 파라미터를 설정하지 않는다면

                  export.log 라는 파일명으로 로그가 자동으로 실행한 위치의 디렉토리에 남게 됩니다.

                  로그파일을 남기고 싶지 않을때는 NOLOGFILE 파라미터를 사용하시면 됩니다.

- COMPRESSION : 오라클에서 EXPORT 시에 메타데이터는 압축을 하여 파일에 저장하게 됩니다.

                  COMPRESSION 파라메터를 사용하지 않을 경우에는 덤프파일 내에 메타데이터가

                  압축되어 보관됩니다.

                  COMPRESSION 파라메터에는 METADATA_ONLY, NONE 두개의 옵션이 있으며,

                  METADATA_ONLY는 파라메터를 사용하지 않으면 디폴트로 인식되는 옵션입니다.

                  COMPRESSION=option_name 으로 사용하면 됩니다.

                  #expdp zoom/imsi00 DIRECTORY=/oracle/expdir DUMPFILE=dump.dmp

                                                COMPRESSION=NONE

 

Export 모드 관련 파라미터

- FULL

- SCHEMAS

- TABLES

- TABLESPACES

- TRANSPORT_FULL_CHECK : TRANSPORT_FULL_CHECK 파라메터는 export 작업 시에

                          테이블스페이스 내에 존재하는 테이블과 인덱스의 의존선을 검사 할 것인지

                          하지 않을 것인지를 설정하는 파라미터로 'Y' 또는 'N' 두개이 값만을 허용하는

                          파라메터 입니다.

(1) 'Y' 일 경우, TABLESPACE 내에 테이블만 있고, 인덱스가 없다면 작업은 실패한다.

      반드시 INDEX도 같은 테이블스페이스내에 존재 해야 합니다.

(2) 'Y' 일 경우, TABLESPACE내에 인덱스만 존재하고 테이블이 없다면 작업은 실패합니다.

       반드시 TABLE 또한 존재해야 합니다

(3) 'N' 일 경우, TABLESPACE내에 테이블만 있고 인덱스가 없다면 작업은 성공합니다.

(4) 'N' 일 경우, TABLESPACE내에 인덱스만 있고 테이블이 없다면 작업은 성공합니다.

 

Export 필터링 관련 파라미터

- CONTENT : 3개의 옵션을 가질 수 있으며 옵션들은 다음과 같습니다

 

   + ALL : 테이블과 메터데이터를 포함한 모든것을 포함시키겠다는 옵션

      # expdp zoom/imsi00 DUMPFILE=datadump.dmp CONTENT=ALL

 

   + DATA_ONLY : 테이블 데이터만 포함 시키겠다는 옵션

     #  expdp zoom/imsi00 DUMPFILE=datadump.dmp CONTENT=DATA_ONLY

 

   + METADATA_ONLY : 메타데이터 만을 포함하겠다는 옵션

     #  expdp zoom/imsi00 DUMPFILE=datadump.dmp CONTENT=METADATA_ONLY

 

- EXCLUDE & INCLUDE : 원하는 오브젝트를 선택하여 받을 수 있습니다.

                                     오라클에서 오브젝트란 유저스키마, 테이블, 인덱스, 프로시져 등을

                                     통칭해서 오브젝트라고 부릅니다.

                                     [exclude | include]=object_name 조건 형식으로 사용 할 수 있음

                                     파라미터 사용방법은 아래와 같습니다.

        + SCOTT 유저와 관련된 모든것을 export 받고 싶은데, BONUS 테이블은 제외하고 받고

          싶은 경우

          #expdp zoom/imsi00 dumfile=ex_dump.dmp schemas=scott exclude=TABLE:"='BONUS'"

 

        + SCOTT 유저와 관련된 모든것을 export 받고 싶은데 EMP 테이블의 인덱스는 받고

          싶지 않은경우

         #expdp zoom/imsi00 dumfile=ex_dump.dmp schemas=scott exclude=INDEX:\"='EMP%'\"

         

- QUERY : 테이블 내에 있는 데이터 중 특정 조건에 만족하는 데이터만을 export 받고자 할때

                사용하는 파라메터 입니다.

                사용방법은 다음과 같습니다

                QUERY=SCHEMA.TABLE:"조건" 이며 다음과  같은 예입니다.

                # expdp zoom/imsi00 dumpfile=ex_dump.dmp table=emp

                                               QUERY=SCOTT.EMP:'where sal > 1200'

- SAMPLE : 오라클 10g에서 새롭게 지원하는 기능 중 하나로써 테이블의 데이터를 export 할때

                  퍼센트를 정하여 지정된 퍼센트 만큼의 데이터를 샘플링해서 뽑을때 사용하는

                  옵션입니다

               # expdp zoom/imsi00 DIRECTORY=datadump_dir1 DUMPFILE=ex_dump.dmp

                                              SAMPLE=scott.emp:20

                  //scott 유저의 EMP테이블의 데이터중 20%만을 export 하게 됩니다

                     입력 가능한 퍼센트의 범위는 0.000001 ~ 100 까지 입니다.

 

네트워크 링크 파라미터

- 원격지 데이터베이스에 있는 데이터에 접근하여 로컬 데이터베이스 머신에 export 된 덤프파일을

   저장하고자 할때 사용하는 파라메터

- 먼저, 원격지 데이터베이스의 테이블에 대한 DB_LINK 를 만들어 놓아야 함

  # expdp zoom/imsi00 DIRECTORY=datadump_dir1 DUMPFILE=ex_dump.dmp

                                 NETWORK_LINK=EMP@link_b_scott LOGFILE=datapump.log

 

암호화 관련 파라미터

- export 되는 데이터 중 일부 컬럼이 암호화 되어 있고, 중요한 데이터 일 경우 사용하는 파라미터

- export 시에 암호를 설정하여 export된 데이터가 위변조 되지 못하게 설정할 수 있음

  # expdp zoom/imsi00 TABLES=EMP DUMPFILE=ex_dump.dmp

                                 ENCRYPTION_PASSWORD=******

 

JOB관련 파라미터

- JOB : JOB파라미터를 설정하면 Data Dump 작업을 오라클에서 자동 할당하지 않고

           JOB파라메터에서 주어진 이름으로 등록 되게 됩니다. 작업 마스터 테이블에 작업명이

           등록되어 작업에 대한 정보들을 JOB 파라미터에 등록된 이름으로 조회 할 수있습니다.

- STATUS : STATUS파라미터는 Data Pump Export 시에 작업의 갱신 된 내용을 STATUS에

                 설정된 크기의 시간 간격으로 진행상태를 보고 받고자 할때 사용하는 파라메터 입니다.

                 STATUS = 30 이면 30초 간격으로 작업결과를 갱신하여 보여주게 됩니다.

                 만약 이 파라미터를 설정하지 않으면 디폴트는 0입니다. 디폴트로 설정하게 되면

                 거의 실시간으로 작업정보를 보여주게 됩니다.

- FLASHBACK_SCN : System Change Number(SCN) 은 시스템의 테이블이나 오브젝트가

                변경되었을때 변경되는 SCN값을 가집니다. FLASHBACK_SCN 파라메터를 이용하여

                SCN 값을 지정할 경우에 파라미터에서 설정한 SCN 기준 이전까지의상태를 받게 됩니다

                # expdp zoom/imsi00 DIRECTORY=datadump_dir DUMPFILE=ex_dump.dmp

                                               FLASHBACK_SCN=120001

- FLASHBACK_TIME : FLASHBACK_TIME은 번호 대신 시간값을 가집니다.

                FLASHBACK_TIME 파라미터를 사용하면 파라미터에 지정된 시간까지의 변경

                사항만을 Export 합니다.FLASHBACK_TIME 의 값은 TIMESTAMP 형식의 값을 가지며

                TO_TIMESTAMP 함수를 사용하여 설정 할 수 있습니다.

- PARALLEL : PARALLEL 파라메터를 사용할 경우 export 작업 시에 프로세스를 설정된

                숫자만큼 만들어 수행함으로써 작업의 속도를 향상 시킬 수 있습니다. 디폴트 값은 1로

                설정되어 있으며 주의할점은 parallel 이 지정된 갯수 만틈의 dumpfile 을 지정해 주어야

                한다. 앞서 본 %U를 사용하면 지정된 갯수만큼 자동으로 파일을 만들어 줍니다

                # expdp zoom/imsi00 DIRECTORY=datadump_dir DUMPFILE=ex_dump%U.dmp

                                               PARALLEL=3

                위와 같이 설정하게되면 ex_dump01.dmp, ex_dump02.dmp, ex_dump03.dmp 3개의

                덤프파일이 생성됩니다.

                # expdp zoom/imsi00 DIRECTORY=datadump_dir

                  DUMPFILE=(ex_dump01.dmp, ex_dump02.dmp, ex_dump03.dmp) PARALLEL=3

                 위와 같이 %U를 사용하지 않고, 사용자가 직접 3개의 파일명을 ',' 구분하여 입력해도

                 상관 없습니다.

- ATTACH : ATTACH 파라미터를 이용하여 interactive mode 로 들어 갈 수 있습니다.

                 오라클에서는 작업을 제어하고 모니터링 하기 위해 interactive mode를 제공합니다.

                 interactive mode로 들어가는 방법은 두가지가 있으며 다음과 같습니다.

                 + Crtl + C 를 누름으로써 들어가는 방법

                   # expdp zoom/imsi00 directory=datadump_dir  table=scott.emp

                                                 dumpfile=datadump.dmp logfile=datapump.log

                                                 jobname=myjob            

                                                작업로그.....

                                                .................==> 작업에 대한 로그가 떨어졌을때 Crtl + C

                   export>                  ==> 이와 같이 프롬프트 상태로 떨어지게 됩니다.

                   로그가 멈춘다고 해서 작업이 중단된게 아니라 이상태에서 interactive mode 명령을

                   사용하여 작업을 모니터링 하고 제어 할 수 있습니다

                   # expdp zoom/imsi00 attach=schema.jobname 형식으로 원하는 작업의

                   interactive mode로 들어갈 수 있습니다.

                   < InterActive Mode 명령어 >            

 

3. Data Pump Import

파일 및 디렉토리 관련 파라미터
    #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott
     - directory : 디렉토리 오브젝트를 받는 파라미터
     - dumpfile : imprt 될 파일명
     - schemas : 작업 수행동안 수행될 DDL문을 저장하는 파일이름
 

필터링 관련 파라미터

- CONTENT : CONTENT 파라미터는 DATA_ONLY, METADATA_ONLY, ALL 3개의 값을 가짐

   #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott

                                CONTENT=DATA_ONLY

- INCLUDE : INCLUDE=OBJECT_NAME:"='조건'" 형식으로 사용할 수 있으며 오브젝트의

                  종류에는 앞서 본것처럼 TABLE, INDEX, PROCEDURE, FUNCTION 등이 있습니다.

   #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott

                                INCLUDE=TABLE:"='SAL'"

     ==>SCOTT 유저의 테이블을 import 하되 SAL테이블 만 포함 시키라는 옵션명령이 됩니다.

 

- EXCLUDE : EXCLUDE=OBJECT_NAME:"='조건'" 형식으로 사용할 수 있으며 오브젝트의

                  종류에는 앞서 본것처럼 TABLE, INDEX, PROCEDURE, FUNCTION 등이 있습니다.

   #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott

                                 EXCLUDE=TABLE:"='SAL'"

     ==> SCOTT 유저의 테이블을 import 하되 SAL테이블을 제외한 나머지 테이블을 import 하라는

           명령

- TABLE_EXISTS_ACTION : imprt 시에 중요한 명령입니다

                                       우리가 Data Pump를 통해 작업하게 될 경우 같은 이름의 테이블이

                                       존재할 때가 있습니다. 만약 테이블이 존재 하더라도 import 하고자 하는

                                       데이터의 row수가 다를수도 있고 같을 수도있습니다. 즉 테이블은 존재

                                       하더라고 데이터의 내용은 차이가 나는거죠.

                                       이러한 경우 사용할 수 있는 유용한 파라메터가

                                       TABLE_EXISTES_ACTION 입니다. TABLE_EXISTES_ACTION파라메터

                                       는 SKIP, APPEND, TRUNCATE, REPLACE 의 값을 가질 수 있으며

                                       각값의 의미는 다음과 같습니다.

                                       + SKIP : 같은 테이블을 만나면 지나치고, 다음 테이블을 import 합니다

                                       + APPEND : 같은 테이블을 만나면 기존테이블에 추가하여 import

                                       + TRUNCATE : 같은 테이블을 만나면 기존테이블을 truncate하고

                                                             새로운 데이터를 import

                                       + REPLACE : 같은 테이블을 만날 경우 기존 테이블을 drop 하고

                                                           테이블을 재생성 한 후 import 합니다

   #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott

                                 TABLE_EXISTS_ACTION=SKIP

 

JOB 관련 파라미터

- JOB_NAME, STATUS, PARALLEL 파라메터를 export와 같은 방법으로 사용

- PARALLEL 작업시에 dumpfile 갯수를 %U 사용하여 지정하여 주거나 명시적으로 ','를 사용하여

   PARALLEL 갯수만큼 파일을 지정해야 함

 

리맵핑 관련 파라미터

- REMAP_SCHEMA : A 유저 스키마로 export 받은 데이터를 B 유저 스키마로 import 하고자 할때

                              사용합니다.

   #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott

                                REMAP_SCHEMA=SCOTT:ZOOM

    ==> 위와 같이 수행한후 TABLE 의 OWNER 를 조회한다면 ZOOM 유저의 소유로 테이블이

          등록되었음을 확인 할 수 있다.

 

- REMAP_DATAFILE : 전체 데이터베이스 시스템을 Data Pump를 통하여 옮기고자 할때

                               Export 된 dumpfile에는 DataFile 정보까지 포함하게 됩니다. 하지만 서로다른

                              시스템 경로상에 존재하지 않는 경로이기 때문에 Import 에 실패하게 됩니다.

                              이러한 경우 사용할 수 있는 파라미터가 REMAP_DATAFILE 입니다. export 된

                              dumpfile이 datafile 정보를 포함할 경우에만 해당합니다.

   #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott

                              REMAP_DATAFILE='/db1/data/lvol01':'/db2/data/lvol01',

                                                          '/db1/data/lvol02':'/db2/data/lvol02'

 

- REMAP_TABLESPACE : export 받은 데이터 속한 tablespace 에서 다른 tablespace로

                                     remapping하고자 하는 경우 사용할 수 있는 파라메터 입니다.

   #impdp zoom/imsi00 directory=datapump_dir dumpfile=datapump.dmp schemas=scott

                              REMAP_TABLESPACE='SCOTT_TSB':'ZOOM_TSB'

 

네트워크 링크 파라미터

export 와 마찬가지로 DBLINK를 이용하여 원격지 데이터베이스에 대해 import 작업을 수행 할 수있습니다.

 

InterActive Mode 파라미터

export 와 마찬가지로 Ctrl+C를 통해 interActive Mode로 진입 할 수 있으며 작업을 통제 할 수있습니다

 

4. Data Pump 모니터링 하기

1) Data Pump 모니터링 하기 관련조회 테이블 및 VIEW

DBA_DATAPUMP_JOBS 현재 실행중인 작업의 속성들

   SQL> SELECT * FROM DBA_DATAPUMP_JODS;

            OWNER_NAME = DB작업계정

            JOB_NAME = 작업의 명칭

            JOB_MODE = FULL, TABLE, INDEX, TABLESPACE 등이 있음

            STATE = EXECUTING(수행중), DEFINING, UNDEFINING, NOT RUNNING 의 값을 가짐

PUMP Session 확인

Data Pump의 모니터링

    SQL> SELECT OPNAME, TARGET_DESC, SOFAR, TOTALWORK,

             (SOFAR/TOTALWORK*100) PER

              FROM V$SESSION_LONGOPS; 로 조회하면 Data Pump 의 모니터링을 할 수 있습니다

              OPNAME = JOBNAME 과 같음

              TOTALWORK = 총 수행하여야 할 용량을 가리키며, 단위는 Megabytes

              SOFAR = 현재 수행한 용량을 가리키며 단위는 Megabytes

              TARGET_DESC = 작업의 종류를 말함

                                       import/export  값이 될 수 있음

 

출처 : http://cafe.naver.com/ocmkorea.cafe?iframe_url=/ArticleRead.nhn%3Farticleid=1388

반응형

'Database > ORACLE' 카테고리의 다른 글

Oracle SID error  (0) 2010.02.09
rman Tool  (0) 2010.02.01
Grant 관련 상세 설명  (0) 2010.01.25
`BIN$+......==$0` 알수 없는 테이블..  (0) 2010.01.14
sqlplus 환경 설정  (0) 2010.01.08
반응형

출처 : 오라클 사이트

http://download.oracle.com/docs/cd/B19306_01/server.102/b14200/statements_9013.htm#SQLRF01603

GRANT

Purpose

Use the GRANT statement to grant:

  • System privileges to users and roles.

  • Roles to users and roles. Both privileges and roles are either local, global, or external. Table 18-1 lists the system privileges (organized by the database object operated upon). Table 18-2 lists Oracle Database predefined roles.

  • Object privileges for a particular object to users, roles, and PUBLIC. Table 18-3 summarizes the object privileges that you can grant on each type of object. Table 18-4 lists object privileges and the operations that they authorize.

Notes on Authorizing Database Users You can authorize database users through means other than the database and the GRANT statement.

  • Many Oracle Database privileges are granted through supplied PL/SQL and Java packages. For information on those privileges, please refer to the documentation for the appropriate package.

  • Some operating systems have facilities that let you grant roles to Oracle Database users with the initialization parameter OS_ROLES. If you choose to grant roles to users through operating system facilities, then you cannot also grant roles to users with the GRANT statement, although you can use the GRANT statement to grant system privileges to users and system privileges and roles to other roles.

See Also:

Additional Topics

Prerequisites

To grant a system privilege, you must either have been granted the system privilege with the ADMIN OPTION or have been granted the GRANT ANY PRIVILEGE system privilege.

To grant a role, you must either have been granted the role with the ADMIN OPTION or have been granted the GRANT ANY ROLE system privilege, or you must have created the role.

To grant an object privilege, you must own the object, or the owner of the object must have granted you the object privileges with the GRANT OPTION, or you must have been granted the GRANT ANY OBJECT PRIVILEGE system privilege. If you have the GRANT ANY OBJECT PRIVILEGE, then you can grant the object privilege only if the object owner could have granted the same object privilege. In this case, the GRANTOR column of the DBA_TAB_PRIVS view displays the object owner rather than the user who issued the GRANT statement.

Syntax

grant::=

Description of grant.gif follows
Description of the illustration grant.gif

(grant_system_privileges::=, grant_object_privileges::=)

grant_system_privileges::=

Description of grant_system_privileges.gif follows
Description of the illustration grant_system_privileges.gif

(grantee_clause ::=)

grant_object_privileges::=

Description of grant_object_privileges.gif follows
Description of the illustration grant_object_privileges.gif

(on_object_clause ::=, grantee_clause ::=)

on_object_clause ::=

Description of on_object_clause.gif follows
Description of the illustration on_object_clause.gif

grantee_clause ::=

Description of grantee_clause.gif follows
Description of the illustration grantee_clause.gif

Semantics

grant_system_privileges

Use these clauses to grant system privileges.

system_privilege

Specify the system privilege you want to grant. Table 18-1 lists the system privileges, organized by the database object operated upon.

  • If you grant a privilege to a user, then the database adds the privilege to the user's privilege domain. The user can immediately exercise the privilege.

  • If you grant a privilege to a role, then the database adds the privilege to the privilege domain of the role. Users who have been granted and have enabled the role can immediately exercise the privilege. Other users who have been granted the role can enable the role and exercise the privilege.

  • If you grant a privilege to PUBLIC, then the database adds the privilege to the privilege domains of each user. All users can immediately perform operations authorized by the privilege.

Oracle Database provides the ALL PRIVILEGES shortcut for granting all the system privileges listed in Table 18-1, except the SELECT ANY DICTIONARY privilege.

role

Specify the role you want to grant. You can grant an Oracle Database predefined role or a user-defined role. Table 18-2 lists the predefined roles.

  • If you grant a role to a user, then the database makes the role available to the user. The user can immediately enable the role and exercise the privileges in the privilege domain of the role.

  • If you grant a role to another role, then the database adds the privilege domain of the granted role to the privilege domain of the grantee role. Users who have been granted the grantee role can enable it and exercise the privileges in the granted role's privilege domain.

  • If you grant a role to PUBLIC, then the database makes the role available to all users. All users can immediately enable the role and exercise the privileges in the privilege domain of the role.

    See Also:

    "Granting a Role to a Role: Example" and CREATE ROLE for information on creating a user-defined role

IDENTIFIED BY Clause

Use the IDENTIFIED BY clause to specifically identify an existing user by password or to create a nonexistent user. This clause is not valid if the grantee is a role or PUBLIC. If the user specified in the grantee_clause does not exist, then the database creates the user with the password and with the privileges and roles specified in this clause.

See Also:

CREATE USER for restrictions on usernames and passwords

WITH ADMIN OPTION

Specify WITH ADMIN OPTION to enable the grantee to:

  • Grant the role to another user or role, unless the role is a GLOBAL role

  • Revoke the role from another user or role

  • Alter the role to change the authorization needed to access it

  • Drop the role

If you grant a system privilege or role to a user without specifying WITH ADMIN OPTION, and then subsequently grant the privilege or role to the user WITH ADMIN OPTION, then the user has the ADMIN OPTION on the privilege or role.

To revoke the ADMIN OPTION on a system privilege or role from a user, you must revoke the privilege or role from the user altogether and then grant the privilege or role to the user without the ADMIN OPTION.

grantee_clause

TO grantee_clause identifies users or roles to which the system privilege, role, or object privilege is granted.

Restriction on Grantees A user, role, or PUBLIC cannot appear more than once in TO grantee_clause.

PUBLIC Specify PUBLIC to grant the privileges to all users.

Restrictions on Granting System Privileges and Roles Privileges and roles are subject to the following restrictions:

  • A privilege or role cannot appear more than once in the list of privileges and roles to be granted.

  • You cannot grant a role to itself.

  • You cannot grant a role IDENTIFIED GLOBALLY to anything.

  • You cannot grant a role IDENTIFIED EXTERNALLY to a global user or global role.

  • You cannot grant roles circularly. For example, if you grant the role banker to the role teller, then you cannot subsequently grant teller to banker.

grant_object_privileges

Use these clauses to grant object privileges.

object_privilege

Specify the object privilege you want to grant. You can specify any of the values shown in Table 18-3. See also Table 18-4.

Restriction on Object Privileges A privilege cannot appear more than once in the list of privileges to be granted.

ALL [PRIVILEGES]

Specify ALL to grant all the privileges for the object that you have been granted with the GRANT OPTION. The user who owns the schema containing an object automatically has all privileges on the object with the GRANT OPTION. The keyword PRIVILEGES is provided for semantic clarity and is optional.

column

Specify the table or view column on which privileges are to be granted. You can specify columns only when granting the INSERT, REFERENCES, or UPDATE privilege. If you do not list columns, then the grantee has the specified privilege on all columns in the table or view.

For information on existing column object grants, query the USER_, ALL_, or DBA_COL_PRIVS data dictionary view.

on_object_clause

The on_object_clause identifies the object on which the privileges are granted. Directory schema objects and Java source and resource schema objects are identified separately because they reside in separate namespaces.

If you can make this grant only because you have the GRANT ANY OBJECT PRIVILEGE system privilege--that is, you are not the owner of object, nor do you have object_privilege on object WITH GRANT OPTION--then the effect of this grant is that you are acting on behalf of the object owner. The *_TAB_PRIVS data dictionary views will reflect that this grant was made by the owner of object.

See Also:

WITH GRANT OPTION

Specify WITH GRANT OPTION to enable the grantee to grant the object privileges to other users and roles.

Restriction on Granting WITH GRANT OPTION You can specify WITH GRANT OPTION only when granting to a user or to PUBLIC, not when granting to a role.

WITH HIERARCHY OPTION

Specify WITH HIERARCHY OPTION to grant the specified object privilege on all subobjects of object, such as subviews created under a view, including subobjects created subsequent to this statement.

This clause is meaningful only in combination with the SELECT object privilege.

object Specify the schema object on which the privileges are to be granted. If you do not qualify object with schema, then the database assumes the object is in your own schema. The object can be one of the following types:

  • Table, view, or materialized view

  • Sequence

  • Procedure, function, or package

  • User-defined type

  • Synonym for any of the preceding items

  • Directory, library, operator, or indextype

  • Java source, class, or resource

You cannot grant privileges directly to a single partition of a partitioned table.

DIRECTORY directory_name Specify a directory schema object on which privileges are to be granted. You cannot qualify directory_name with a schema name.

JAVA SOURCE | RESOURCE The JAVA clause lets you specify a Java source or resource schema object on which privileges are to be granted.

See Also:

CREATE JAVA

Listings of System and Object Privileges

Note:

When you grant a privilege on ANY object, such as CREATE ANY CLUSTER, the result is determined by the value of the O7_DICTIONARY_ACCESSIBILITY initialization parameter. By default, this parameter is set to FALSE, so that ANY privileges give the grantee access to that type of object in all schemas except the SYS schema. If you set O7_DICTIONARY_ACCESSIBILITY to TRUE, then the ANY privileges also give the grantee access, in the SYS schema, to all objects except Oracle Scheduler objects. For security reasons, Oracle recommends that you use this setting only with great caution.

Table 18-1 System Privileges

System Privilege Name Operations Authorized

Advisor Framework Privileges: All of the advisor framework privileges are part of the DBA role.

--

ADVISOR

Access the advisor framework through PL/SQL packages such as DBMS_ADVISOR and DBMS_SQLTUNE.

Please refer to PL/SQL Packages and Types Reference for information on these packages.

ADMINISTER SQL TUNING SET

Create, drop, select (read), load (write), and delete a SQL tuning set owned by the grantee through the DBMS_SQLTUNE package.

ADMINISTER ANY SQL TUNING SET

Create, drop, select (read), load (write), and delete a SQL tuning set owned by any user through the DBMS_SQLTUNE package.

CREATE ANY SQL PROFILE

Accept a SQL Profile recommended by the SQL Tuning Advisor, which is accessed through Enterprise Manager or by the DBMS_SQLTUNE package.

DROP ANY SQL PROFILE

Drop an existing SQL Profile.

ALTER ANY SQL PROFILE

Alter the attributes of an existing SQL Profile.

CLUSTERS:

--

CREATE CLUSTER

Create clusters in the grantee's schema.

CREATE ANY CLUSTER

Create a cluster in any schema. Behaves similarly to CREATE ANY TABLE.

ALTER ANY CLUSTER

Alter clusters in any schema.

DROP ANY CLUSTER

Drop clusters in any schema.

CONTEXTS:

--

CREATE ANY CONTEXT

Create any context namespace.

DROP ANY CONTEXT

Drop any context namespace.

DATABASE:

--

ALTER DATABASE

Alter the database.

ALTER SYSTEM

Issue ALTER SYSTEM statements.

AUDIT SYSTEM

Issue AUDIT statements.

DATABASE LINKS:

--

CREATE DATABASE LINK

Create private database links in the grantee's schema.

CREATE PUBLIC DATABASE LINK

Create public database links.

DROP PUBLIC DATABASE LINK

Drop public database links.

DEBUGGING:

--

DEBUG CONNECT SESSION

Connect the current session to a debugger.

DEBUG ANY PROCEDURE

Debug all PL/SQL and Java code in any database object. Display information on all SQL statements executed by the application.

Note: Granting this privilege is equivalent to granting the DEBUG object privilege on all applicable objects in the database.

DIMENSIONS:

--

CREATE DIMENSION

Create dimensions in the grantee's schema.

CREATE ANY DIMENSION

Create dimensions in any schema.

ALTER ANY DIMENSION

Alter dimensions in any schema.

DROP ANY DIMENSION

Drop dimensions in any schema.

DIRECTORIES:

--

CREATE ANY DIRECTORY

Create directory database objects.

DROP ANY DIRECTORY

Drop directory database objects.

INDEXTYPES:

--

CREATE INDEXTYPE

Create an indextype in the grantee's schema.

CREATE ANY INDEXTYPE

Create an indextype in any schema and create a comment on an indextype in any schema.

ALTER ANY INDEXTYPE

Modify indextypes in any schema.

DROP ANY INDEXTYPE

Drop an indextype in any schema.

EXECUTE ANY INDEXTYPE

Reference an indextype in any schema.

INDEXES:

--

CREATE ANY INDEX

Create in any schema a domain index or an index on any table in any schema.

ALTER ANY INDEX

Alter indexes in any schema.

DROP ANY INDEX

Drop indexes in any schema.

JOB SCHEDULER OBJECTS:

The following privileges are needed to execute procedures in the DBMS_SCHEDULER package.

CREATE JOB

Create jobs, schedules, or programs in the grantee's schema.

CREATE ANY JOB

Create, alter, or drop jobs, schedules, or programs in any schema.

Note: This extremely powerful privilege allows the grantee to execute code as any other user. It should be granted with caution.

CREATE EXTERNAL JOB

Create in the grantee's schema an executable scheduler job that runs on the operating system.

EXECUTE ANY PROGRAM

Use any program in a job in the grantee's schema.

EXECUTE ANY CLASS

Specify any job class in a job in the grantee's schema.

MANAGE SCHEDULER

Create, alter, or drop any job class, window, or window group.

LIBRARIES:

--

CREATE LIBRARY

Create external procedure or function libraries in the grantee's schema.

CREATE ANY LIBRARY

Create external procedure or function libraries in any schema.

DROP ANY LIBRARY

Drop external procedure or function libraries in any schema.

MATERIALIZED VIEWS:

--

CREATE MATERIALIZED VIEW

Create a materialized view in the grantee's schema.

CREATE ANY MATERIALIZED VIEW

Create materialized views in any schema.

ALTER ANY MATERIALIZED VIEW

Alter materialized views in any schema.

DROP ANY MATERIALIZED VIEW

Drop materialized views in any schema.

QUERY REWRITE

This privilege has been deprecated. No privileges are needed for a user to enable rewrite for a materialized view that references tables or views in the user's own schema.

GLOBAL QUERY REWRITE

Enable rewrite using a materialized view when that materialized view references tables or views in any schema.

ON COMMIT REFRESH

Create a refresh-on-commit materialized view on any table in the database.

Alter a refresh-on-demand materialized on any table in the database to refresh-on-commit.

FLASHBACK ANY TABLE

Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures.

OPERATORS:

--

CREATE OPERATOR

Create an operator and its bindings in the grantee's schema.

CREATE ANY OPERATOR

Create an operator and its bindings in any schema and create a comment on an operator in any schema.

ALTER ANY OPERATOR

Modify an operator in any schema.

DROP ANY OPERATOR

Drop an operator in any schema.

EXECUTE ANY OPERATOR

Reference an operator in any schema.

OUTLINES:

--

CREATE ANY OUTLINE

Create public outlines that can be used in any schema that uses outlines.

ALTER ANY OUTLINE

Modify outlines.

DROP ANY OUTLINE

Drop outlines.

PROCEDURES:

--

CREATE PROCEDURE

Create stored procedures, functions, and packages in the grantee's schema.

CREATE ANY PROCEDURE

Create stored procedures, functions, and packages in any schema.

ALTER ANY PROCEDURE

Alter stored procedures, functions, or packages in any schema.

DROP ANY PROCEDURE

Drop stored procedures, functions, or packages in any schema.

EXECUTE ANY PROCEDURE

Execute procedures or functions, either standalone or packaged.

Reference public package variables in any schema.

PROFILES:

--

CREATE PROFILE

Create profiles.

ALTER PROFILE

Alter profiles.

DROP PROFILE

Drop profiles.

ROLES:

--

CREATE ROLE

Create roles.

ALTER ANY ROLE

Alter any role in the database.

DROP ANY ROLE

Drop roles.

GRANT ANY ROLE

Grant any role in the database.

ROLLBACK SEGMENTS:

--

CREATE ROLLBACK SEGMENT

Create rollback segments.

ALTER ROLLBACK SEGMENT

Alter rollback segments.

DROP ROLLBACK SEGMENT

Drop rollback segments.

SEQUENCES:

--

CREATE SEQUENCE

Create sequences in the grantee's schema.

CREATE ANY SEQUENCE

Create sequences in any schema.

ALTER ANY SEQUENCE

Alter any sequence in the database.

DROP ANY SEQUENCE

Drop sequences in any schema.

SELECT ANY SEQUENCE

Reference sequences in any schema.

SESSIONS:

--

CREATE SESSION

Connect to the database.

ALTER RESOURCE COST

Set costs for session resources.

ALTER SESSION

Issue ALTER SESSION statements.

RESTRICTED SESSION

Logon after the instance is started using the SQL*Plus STARTUP RESTRICT statement.

SNAPSHOTS:

See MATERIALIZED VIEWS

SYNONYMS:

--

CREATE SYNONYM

Create synonyms in the grantee's schema.

CREATE ANY SYNONYM

Create private synonyms in any schema.

CREATE PUBLIC SYNONYM

Create public synonyms.

DROP ANY SYNONYM

Drop private synonyms in any schema.

DROP PUBLIC SYNONYM

Drop public synonyms.

TABLES:

Note: For external tables, the only valid privileges are CREATE ANY TABLE, ALTER ANY TABLE, DROP ANY TABLE, and SELECT ANY TABLE.

CREATE TABLE

Create tables in the grantee's schema.

CREATE ANY TABLE

Create tables in any schema. The owner of the schema containing the table must have space quota on the tablespace to contain the table.

ALTER ANY TABLE

Alter any table or view in any schema.

BACKUP ANY TABLE

Use the Export utility to incrementally export objects from the schema of other users.

DELETE ANY TABLE

Delete rows from tables, table partitions, or views in any schema.

DROP ANY TABLE

Drop or truncate tables or table partitions in any schema.

INSERT ANY TABLE

Insert rows into tables and views in any schema.

LOCK ANY TABLE

Lock tables and views in any schema.

SELECT ANY TABLE

Query tables, views, or materialized views in any schema.

FLASHBACK ANY TABLE

Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures.

UPDATE ANY TABLE

Update rows in tables and views in any schema.

TABLESPACES:

--

CREATE TABLESPACE

Create tablespaces.

ALTER TABLESPACE

Alter tablespaces.

DROP TABLESPACE

Drop tablespaces.

MANAGE TABLESPACE

Take tablespaces offline and online and begin and end tablespace backups.

UNLIMITED TABLESPACE

Use an unlimited amount of any tablespace. This privilege overrides any specific quotas assigned. If you revoke this privilege from a user, then the user's schema objects remain but further tablespace allocation is denied unless authorized by specific tablespace quotas. You cannot grant this system privilege to roles.

TRIGGERS:

--

CREATE TRIGGER

Create a database trigger in the grantee's schema.

CREATE ANY TRIGGER

Create database triggers in any schema.

ALTER ANY TRIGGER

Enable, disable, or compile database triggers in any schema.

DROP ANY TRIGGER

Drop database triggers in any schema.

ADMINISTER DATABASE TRIGGER

Create a trigger on DATABASE. You must also have the CREATE TRIGGER or CREATE ANY TRIGGER system privilege.

TYPES:

--

CREATE TYPE

Create object types and object type bodies in the grantee's schema.

CREATE ANY TYPE

Create object types and object type bodies in any schema.

ALTER ANY TYPE

Alter object types in any schema.

DROP ANY TYPE

Drop object types and object type bodies in any schema.

EXECUTE ANY TYPE

Use and reference object types and collection types in any schema, and invoke methods of an object type in any schema if you make the grant to a specific user. If you grant EXECUTE ANY TYPE to a role, then users holding the enabled role will not be able to invoke methods of an object type in any schema.

UNDER ANY TYPE

Create subtypes under any nonfinal object types.

USERS:

--

CREATE USER

Create users. This privilege also allows the creator to:

  • Assign quotas on any tablespace.

  • Set default and temporary tablespaces.

  • Assign a profile as part of a CREATE USER statement.

ALTER USER

Alter any user. This privilege authorizes the grantee to:

  • Change another user's password or authentication method.

  • Assign quotas on any tablespace.

  • Set default and temporary tablespaces.

  • Assign a profile and default roles.

DROP USER

Drop users

VIEWS:

--

CREATE VIEW

Create views in the grantee's schema.

CREATE ANY VIEW

Create views in any schema.

DROP ANY VIEW

Drop views in any schema.

UNDER ANY VIEW

Create subviews under any object views.

FLASHBACK ANY TABLE

Issue a SQL Flashback Query on any table, view, or materialized view in any schema. This privilege is not needed to execute the DBMS_FLASHBACK procedures.

MERGE ANY VIEW

If a user has been granted the MERGE ANY VIEW privilege, then for any query issued by that user, the optimizer can use view merging to improve query performance without performing the checks that would otherwise be performed to ensure that view merging does not violate any security intentions of the view creator. See also Oracle Database Reference for information on the OPTIMIZER_SECURE_VIEW_MERGING parameter and Oracle Database Performance Tuning Guide for information on view merging.

MISCELLANEOUS:

--

ANALYZE ANY

Analyze any table, cluster, or index in any schema.

AUDIT ANY

Audit any object in any schema using AUDIT schema_objects statements.

CHANGE NOTIFICATION

Create a registration on queries and receive database change notifications in response to DML or DDL changes to the objects associated with the registered queries. Please refer to Oracle Database Application Developer's Guide - Fundamentals for more information on database change notification.

COMMENT ANY TABLE

Comment on any table, view, or column in any schema.

EXEMPT ACCESS POLICY

Bypass fine-grained access control.

Caution: This is a very powerful system privilege, as it lets the grantee bypass application-driven security policies. Database administrators should use caution when granting this privilege.

FORCE ANY TRANSACTION

Force the commit or rollback of any in-doubt distributed transaction in the local database.

Induce the failure of a distributed transaction.

FORCE TRANSACTION

Force the commit or rollback of the grantee's in-doubt distributed transactions in the local database.

GRANT ANY OBJECT PRIVILEGE

Grant any object privilege that the object owner is permitted to to grant.

Revoke any object privilege that was granted by the object owner or by some other user with the GRANT ANY OBJECT PRIVILEGE privilege.

GRANT ANY PRIVILEGE

Grant any system privilege.

RESUMABLE

Enable resumable space allocation.

SELECT ANY DICTIONARY

Query any data dictionary object in the SYS schema. This privilege lets you selectively override the default FALSE setting of the O7_DICTIONARY_ACCESSIBILITY initialization parameter.

SELECT ANY TRANSACTION

Query the contents of the FLASHBACK_TRANSACTION_QUERY view.

Caution: This is a very powerful system privilege, as it lets the grantee view all data in the database, including past data. This privilege should be granted only to users who need to use the Oracle Flashback Transaction Query feature.

SYSDBA

Perform STARTUP and SHUTDOWN operations.

ALTER DATABASE: open, mount, back up, or change character set.

CREATE DATABASE.

ARCHIVELOG and RECOVERY.

CREATE SPFILE.

Includes the RESTRICTED SESSION privilege.

SYSOPER

Perform STARTUP and SHUTDOWN operations.

ALTER DATABASE: open, mount, or back up.

ARCHIVELOG and RECOVERY.

CREATE SPFILE.

Includes the RESTRICTED SESSION privilege.

CONNECT, RESOURCE, and DBA

These roles are provided for compatibility with previous versions of Oracle Database. You can determine the privileges encompassed by these roles by querying the DBA_SYS_PRIVS data dictionary view.

Note: Oracle recommends that you design your own roles for database security rather than relying on these roles. These roles may not be created automatically by future versions of Oracle Database.

See Also: Oracle Database Reference for a description of the DBA_SYS_PRIVS view

DELETE_CATALOG_ROLE EXECUTE_CATALOG_ROLE SELECT_CATALOG_ROLE

These roles are provided for accessing data dictionary views and packages.

See Also: Oracle Database Administrator's Guide for more information on these roles

EXP_FULL_DATABASE

IMP_FULL_DATABASE

These roles are provided for convenience in using the import and export utilities.

See Also: Oracle Database Utilities for more information on these roles

AQ_USER_ROLE

AQ_ADMINISTRATOR_ROLE

You need these roles to use Oracle Advanced Queuing.

See Also: Oracle Streams Advanced Queuing User's Guide and Reference for more information on these roles

SNMPAGENT

This role is used by the Enterprise Manager Intelligent Agent.

See Also: Oracle Enterprise Manager Administrator's Guide

RECOVERY_CATALOG_OWNER

You need this role to create a user who owns a recovery catalog.

See Also: Oracle Database Backup and Recovery Advanced User's Guide for more information on recovery catalogs


Table 18-2 Oracle Database Predefined Roles

Predefined Role Purpose

HS_ADMIN_ROLE

A DBA using Oracle Database heterogeneous services needs this role to access appropriate tables in the data dictionary.

See Also: Oracle Database Heterogeneous Connectivity Administrator's Guide for more information

SCHEDULER_ADMIN

This role allows the grantee to execute the procedures of the DBMS_SCHEDULER package. It includes all of the job scheduler system privileges and is included in the DBA role.

See Also: Oracle Database Administrator's Guide for more information on the DBMS_SCHEDULER package


Table 18-3 Object Privileges Available for Particular Objects

Object Privilege Table View Sequence Procedure, Function, Package (Note 1) Material-ized View Directory Library User- defined Type Operator Indextype

ALTER (Note 2)

X

--

X

--

--

--

--

--

--

--

DELETE

X

X

--

--

X

(Note 3)

--

--

--

--

--

EXECUTE

--

--

--

X

(Note 2)

--

--

X

(Note 2)

X

(Note 2)

X

(Note 2)

X

(Note 2)

DEBUG

X

X

--

X

--

--

--

X

--

--

FLASHBACK

X

X

--

--

X

--

--

--

--

--

INDEX

X

--

--

--

--

--

--

--

--

--

INSERT

X

X

--

--

X

(Note 3)

--

--

--

--

--

ON COMMIT REFRESH

X

--

--

--

--

--

--

--

--

--

QUERY REWRITE

X

--

--

--

--

--

--

--

--

--

READ

--

--

--

--

--

X

--

--

--

--

REFERENCES

X

X

--

--

--

--

--

--

--

--

SELECT

X

X

X

--

X

--

--

--

--

--

UNDER

--

X

--

--

--

--

--

X

--

--

UPDATE

X

X

--

--

X (Note 3)

--

--

--

--

--

WRITE

--

--

--

--

--

X

--

--

--

--


Note 1: Oracle Database treats a Java class, source, or resource as if it were a procedure for purposes of granting object privileges.

Note 2: Job scheduler objects are created using the DBMS_SCHEDULER package. After these objects are created, you can grant the EXECUTE object privilege on job scheduler classes and programs. You can grant ALTER privilege on job scheduler jobs, programs, and schedules.

Note 3: The DELETE, INSERT, and UPDATE privileges can be granted only to updatable materialized views.

Table 18-4 Object Privileges and the Operations They Authorize

Object Privilege Operations Authorized

TABLE PRIVILEGES

The following table privileges authorize operations on a table. Any one of following object privileges allows the grantee to lock the table in any lock mode with the LOCK TABLE statement.

Note: For external tables, the only valid object privileges are ALTER and SELECT.

ALTER

Change the table definition with the ALTER TABLE statement.

DELETE

Remove rows from the table with the DELETE statement.

Note: You must grant the SELECT privilege on the table along with the DELETE privilege if the table is on a remote database.

DEBUG

Access, through a debugger:

  • PL/SQL code in the body of any triggers defined on the table

  • Information on SQL statements that reference the table directly

INDEX

Create an index on the table with the CREATE INDEX statement.

INSERT

Add new rows to the table with the INSERT statement.

REFERENCES

Create a constraint that refers to the table. You cannot grant this privilege to a role.

SELECT

Query the table with the SELECT statement.

UPDATE

Change data in the table with the UPDATE statement.

Note: You must grant the SELECT privilege on the table along with the UPDATE privilege if the table is on a remote database.

VIEW PRIVILEGES

The following view privileges authorize operations on a view. Any one of the following object privileges allows the grantee to lock the view in any lock mode with the LOCK TABLE statement.

To grant a privilege on a view, you must have that privilege with the GRANT OPTION on all of the base tables of the view.

DEBUG

Access, through a debugger:

  • PL/SQL code in the body of any triggers defined on the view

  • Information on SQL statements that reference the view directly

DELETE

Remove rows from the view with the DELETE statement.

INSERT

Add new rows to the view with the INSERT statement.

REFERENCES

Define foreign key constraints on the view.

SELECT

Query the view with the SELECT statement.

UNDER

Create a subview under this view. You can grant this object privilege only if you have the UNDER ANY VIEW privilege WITH GRANT OPTION on the immediate superview of this view.

UPDATE

Change data in the view with the UPDATE statement.

SEQUENCE PRIVILEGES

The following sequence privileges authorize operations on a sequence.

ALTER

Change the sequence definition with the ALTER SEQUENCE statement.

SELECT

Examine and increment values of the sequence with the CURRVAL and NEXTVAL pseudocolumns.

PROCEDURE, FUNCTION, PACKAGE PRIVILEGES

The following procedure, function, and package privileges authorize operations on procedures, functions, and packages. These privileges also apply to Java sources, classes, and resources, which Oracle Database treats as though they were procedures for purposes of granting object privileges.

DEBUG

Access, through a debugger, all public and nonpublic variables, methods, and types defined on the object.

Place a breakpoint or stop at a line or instruction boundary within the procedure, function, or package. This privilege grants access to the declarations in the method or package specification and body.

EXECUTE

Execute the procedure or function directly, or access any program object declared in the specification of a package, or compile the object implicitly during a call to a currently invalid or uncompiled function or procedure. This privilege does not allow the grantee to explicitly compile using ALTER PROCEDURE or ALTER FUNCTION. For explicit compilation you need the appropriate ALTER system privilege.

Access, through a debugger, public variables, types, and methods defined on the procedure, function, or package. This privilege grants access to the declarations in the method or package specification only.

Note: Users do not need this privilege to execute a procedure, function, or package indirectly.

See Also: Oracle Database Concepts and Oracle Database Application Developer's Guide - Fundamentals

MATERIALIZED VIEW PRIVILEGES

The following materialized view privileges authorize operations on a materialized view.

ON COMMIT REFRESH

Create a refresh-on-commit materialized view on the specified table.

QUERY REWRITE

Create a materialized view for query rewrite using the specified table.

SELECT

Query the materialized view with the SELECT statement.

SYNONYM PRIVILEGES

Synonym privileges are the same as the privileges for the base object. Granting a privilege on a synonym is equivalent to granting the privilege on the base object. Similarly, granting a privilege on a base object is equivalent to granting the privilege on all synonyms for the object. If you grant to a user a privilege on a synonym, then the user can use either the synonym name or the base object name in the SQL statement that exercises the privilege.

DIRECTORY PRIVILEGES

The following directory privileges provide secured access to the files stored in the operating system directory to which the directory object serves as a pointer. The directory object contains the full path name of the operating system directory where the files reside. Because the files are actually stored outside the database, Oracle Database server processes also need to have appropriate file permissions on the file system server. Granting object privileges on the directory database object to individual database users, rather than on the operating system, allows the database to enforce security during file operations.

READ

Read files in the directory.

WRITE

Write files in the directory. This privilege is useful only in connection with external tables. It allows the grantee to determine whether the external table agent can write a log file or a bad file to the directory.

Restriction: This privilege does not allow the grantee to write to a BFILE.

LIBRARY PRIVILEGE

The following library privilege authorizes operations on a library.

EXECUTE

Use and reference the specified object and invoke its methods.

OBJECT TYPE PRIVILEGES

The following object type privileges authorize operations on a database object type.

DEBUG

Access, through a debugger, all public and nonpublic variables, methods, and types defined on the object type.

Place a breakpoint or stop at a line or instruction boundary within the type body.

EXECUTE

Use and reference the specified object and invoke its methods.

Access, through a debugger, public variables, types, and methods defined on the object type.

UNDER

Create a subtype under this type. You can grant this object privilege only if you have the UNDER ANY TYPE privilege WITH GRANT OPTION on the immediate supertype of this type.

INDEXTYPE PRIVILEGE

The following indextype privilege authorizes operations on indextypes.

EXECUTE

Reference an indextype.

OPERATOR PRIVILEGE

The following operator privilege authorizes operations on user-defined operators.

EXECUTE

Reference an operator.


Examples

Granting a System Privilege to a User: Example To grant the CREATE SESSION system privilege to the sample user hr, allowing hr to log on to Oracle Database, issue the following statement:

GRANT CREATE SESSION 
   TO hr; 

Granting System Privileges to a Role: Example The following statement grants appropriate system privileges to a data warehouse manager role, which was created in the "Creating a Role: Example":

GRANT
     CREATE ANY MATERIALIZED VIEW
   , ALTER ANY MATERIALIZED VIEW
   , DROP ANY MATERIALIZED VIEW
   , QUERY REWRITE
   , GLOBAL QUERY REWRITE
   TO dw_manager
   WITH ADMIN OPTION;

The dw_manager privilege domain now contains the system privileges related to materialized views.

Granting a Role with the Admin Option: Example To grant the dw_manager role with the ADMIN OPTION to the sample user sh, issue the following statement:

GRANT dw_manager 
   TO sh 
   WITH ADMIN OPTION; 

User sh can now perform the following operations with the dw_manager role:

  • Enable the role and exercise any privileges in the privilege domain of the role, including the CREATE MATERIALIZED VIEW system privilege

  • Grant and revoke the role to and from other users

  • Drop the role

Granting Object Privileges to a Role: Example The following example grants the SELECT object privileges to a data warehouse user role, which was created in the "Creating a Role: Example":

GRANT SELECT ON sh.sales TO warehouse_user;

Granting a Role to a Role: Example The following statement grants the warehouse_user role to the dw_manager role. Both roles were created in the "Creating a Role: Example":

GRANT warehouse_user TO dw_manager; 

The dw_manager role now contains all of the privileges in the domain of the warehouse_user role.

Granting an Object Privilege on a Directory: Example To grant READ on directory bfile_dir to user hr, with the GRANT OPTION, issue the following statement:

GRANT READ ON DIRECTORY bfile_dir TO hr
   WITH GRANT OPTION;

Granting Object Privileges on a Table to a User: Example To grant all privileges on the table oe.bonuses, which was created in "Merging into a Table: Example", to the user hr with the GRANT OPTION, issue the following statement:

GRANT ALL ON bonuses TO hr 
   WITH GRANT OPTION; 

The user hr can subsequently perform the following operations:

  • Exercise any privilege on the bonuses table

  • Grant any privilege on the bonuses table to another user or role

Granting Object Privileges on a View: Example To grant SELECT and UPDATE privileges on the view emp_view, which was created in "Creating a View: Example", to all users, issue the following statement:

GRANT SELECT, UPDATE 
   ON emp_view TO PUBLIC; 

All users can subsequently query and update the view of employee details.

Granting Object Privileges to a Sequence in Another Schema: Example To grant SELECT privilege on the customers_seq sequence in the schema oe to the user hr, issue the following statement:

GRANT SELECT 
   ON oe.customers_seq TO hr; 

The user hr can subsequently generate the next value of the sequence with the following statement:

SELECT oe.customers_seq.NEXTVAL 
   FROM DUAL; 

Granting Multiple Object Privileges on Individual Columns: Example To grant to user oe the REFERENCES privilege on the employee_id column and the UPDATE privilege on the employee_id, salary, and commission_pct columns of the employees table in the schema hr, issue the following statement:

GRANT REFERENCES (employee_id), 
      UPDATE (employee_id, salary, commission_pct) 
   ON hr.employees
   TO oe; 

The user oe can subsequently update values of the employee_id, salary, and commission_pct columns. User oe can also define referential integrity constraints that refer to the employee_id column. However, because the GRANT statement lists only these columns, oe cannot perform operations on any of the other columns of the employees table.

For example, oe can create a table with a constraint:

CREATE TABLE dependent 
   (dependno   NUMBER, 
    dependname VARCHAR2(10), 
    employee   NUMBER 
   CONSTRAINT in_emp REFERENCES hr.employees(employee_id) );

The constraint in_emp ensures that all dependents in the dependent table correspond to an employee in the employees table in the schema hr.

반응형

'Database > ORACLE' 카테고리의 다른 글

rman Tool  (0) 2010.02.01
WS1-2-ch18. Data Pump (expdp/impdp) overview  (0) 2010.02.01
`BIN$+......==$0` 알수 없는 테이블..  (0) 2010.01.14
sqlplus 환경 설정  (0) 2010.01.08
Partition Table  (0) 2009.12.29
반응형


/etc/cron.daily 에 파일을 만들어 두거나

crond 에 등록해서 사용하시면 됩니다.

[기능요약]

1.root 계정으로 전체 디비를 디비별로 백업 가능함
2.옵션으로 테이블 별 백업 가능함.
3.보존 설정 기간 이후 자동 삭제

--------------------------------------------source----------------------------------------------------------

#!/bin/sh

############################################################################
#
# By 질주본능 2009/06/03
#
#    V 2.0
#
# 데이터 베이스별 혹은 테이블 별로 백업 받을 수 있도록 변경했으며
# 30 LINE 에 명기된 배열에 속하는 디비들만 테이블 별로 백업 받는다.
#
# 데이터베이스 단위로 받은 파일은 DB. 으로 시작하고
# 테이블 단위는 TB. 으로 시작하는 파일명을 갖는다.
#
# 백업 파일은 dump.gz 로 형성 되며 설정된 보존 기간이 지나면 자동 삭제 된다.
#
#############################################################################

##### SET VARIABLES ############ 전체를 백업 받으려면 여기에 root 계정을 입력한다.
DBHOST="yourhost"
DBUSER="yourid"
DBPWD="yourpassword"

#백업 경로
BACKUPDIR="/home/your_backup_dir/"
#로그 작성 경로
LOGDIR="/home/your_backup_log_dir/"
#로그 파일 앞에 붙을 특정 텍스트
LOGNAME="log_"

###### SET DB NAMES which BACKUP by TABLES ###### 여기 표시된 DB 들은 테이블 별로 백업된다.
DB_TBARR=(dbname1 dbname2 dbname3)

#백업 옵션을 원하는 대로 설정
#routine 옵션은 5버전 이상에서만 사용(function 등을 백업함)
OPTIONS="--skip-comments --default-character-set=euckr --routines"

##### SET CHARGE LIMIT ########## 백업 파일 저장 기간(일단위)
CHARGE_LMT=3

##### DELETE OLD_BACKUP FILES #######
find ${BACKUPDIR} -name "*.gz" -mtime +${CHARGE_LMT} -exec rm -rf {} \;

##### START LOG CREATE ##########
YMD_S=`date +%Y%m%d%H%M%S`
touch ${LOGDIR}${LOGNAME}${YMD_S}.start

##### DB LIST GET ###############
#IF YOU WANT TO EXCEPT SOME DATABASE ADD THIS
#grep -v Database | grep -v somename | grep -v somename`
#

#grep -v dbname 하면 백업 시 제외 된다.

RESULT=`mysql -u$DBUSER -p$DBPWD -h$DBHOST -e "show databases" | grep -v Database`

for DB in $RESULT; do

    sw=0
    ##### compare DB to TBARR #####
    for i in ${DB_TBARR[@]}; do
        if [ $i = $DB ]; then
            let "sw=sw+1"
        fi
        done

    if [ $sw = 0 ]; then
        # BACKUP by DB
        FNAME=${BACKUPDIR}DB.${DB}_${YMD_S}.dump
        #echo $FNAME
        touch $FNAME
        echo "set foreign_key_checks=0;" >> $FNAME
        mysqldump -u$DBUSER -p$DBPWD -h$DBHOST $OPTIONS $DB >> $FNAME
        echo "set foreign_key_checks=1;" >> $FNAME
        gzip --rsyncable $FNAME

    else
        # BACKUP by TABLES
                RESULT_TB=`mysql -u$DBUSER -p$DBPWD -h$DBHOST $DB -e"show tables" | grep -v heap | grep -v Tables_in `
                for TB in $RESULT_TB; do

                        FNAME=${BACKUPDIR}TB.${DB}.${TB}_${YMD_S}.dump
            #echo $FNAME
            touch $FNAME
            echo "set foreign_key_checks=0;" >> $FNAME
            mysqldump -u$DBUSER -p$DBPWD -h$DBHOST $OPTIONS $DB $TB >> $FNAME
            echo "set foreign_key_checks=1;" >> $FNAME
            gzip --rsyncable $FNAME

                done        
    fi

done

##### END LOG CREATE ###########
YMD_E=`date +%Y%m%d%H%M%S`

touch ${LOGDIR}${LOGNAME}${YMD_E}.end

 

출처 : http://www.phpschool.com/gnuboard4/bbs/board.php?bo_table=tipntech&wr_id=70556&page=2
반응형

'Database > MYSQL' 카테고리의 다른 글

MariaDB SHA2 512 방식으로 암호화 예제  (0) 2019.10.25
Mysql & MariaDB 튜닝 쉘  (0) 2019.08.14
무료 접속 툴 (Free Tool)  (0) 2009.03.06
C를 이용한 성적관리 예제  (0) 2009.03.06
mysql(latin1 -> euckr 변경)  (0) 2009.03.06

+ Recent posts