728x90

db2에서 DECIMAL 타입을 CHAR 타입으로 변환할 때 9.7부터 출력형태가 바뀌었습니다.


다음은 db2 인포센터를 보면 CHAR 함수에 대한 주석입니다.


Decimal to character and leading zeros: In versions previous to version 9.7, the result for decimal input to this function includes leading zeros and a trailing decimal character. The database configuration parameter dec_to_char_fmt can be set to "V95" to have this function return the version 9.5 result for decimal input. The default value of dec_to_char_fmt for new databases is "NEW", which has this function return results which match the SQL standard casting rules and is consistent with results from the VARCHAR function.



DECIMAL 타입에 자리수를 지정하고 CHAR 타입으로 변환할 때 9.7 이전에는 숫자 앞뒤로 0을 채웠으나

9.7부터는 0을 채우지 않는 것이 기본 설정으로 변경되었습니다. 관련 파라미터는 DEC_TO_CHAR_FMT 입니다.


인포센터의 예제를 옮겨보겠습니다.


예 1
다음 테이블 및 데이터를 작성한다고 가정하십시오.
CREATE TABLE MY_TAB(C1 DEC(31,2)
INSERT INTO MY_TAB VALUES 0.20, 0.02, 1.20, 333.44  
다음 명령문을 발행하는 경우
SELECT CHAR(C1)FROM MY_TAB
이전 릴리스에서는 다음 결과 세트가 리턴됩니다.
1--------------------------------- 
00000000000000000000000000000.20  
00000000000000000000000000000.02  
00000000000000000000000000001.20  
00000000000000000000000000333.44
버전 9.7에서는 다음 결과 세트가 리턴됩니다.
1---------------------------------
.20
.02
1.20
333.44
예 2
다음 테이블 및 데이터를 작성한다고 가정하십시오.
CREATE TABLE MY_TAB(C1 DEC(5,0))
INSERT INTO MY_TAB VALUES 1, 4.0  
SELECT CHAR(C1)FROM MY_TAB
다음 명령문을 발행하는 경우
SELECT CHAR(C1)FROM MY_TAB
이전 릴리스에서는 다음 결과 세트가 리턴됩니다.
1-----
0001.
0004.
버전 9.7에서는 다음 결과 세트가 리턴됩니다.
1-----
14                    




참고:


CHAR scalar function -

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.sql.ref.doc/doc/r0000777.html


dec_to_char_fmt - 10진수를 문자 값으로 변환 함수 구성 매개변수 -

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.admin.config.doc/doc/r0054719.html


CHAR(decimal-expression) 스칼라 함수 리턴 동작 변경 -

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.wn.doc/doc/i0054264.html

728x90
728x90

DB2의 트랜잭션 로그는 LOGRETAIN, LOGARCHMETH1 매개변수를 설정함으로써 보관할 수 있다.


이러한 로그파일을 아카이브 로그라고 한다. 트랜잭션 로그는 DB에서 일어나는 변경사항에 대해 기록한 것이다.

따라서 전체 데이터가 없으면 의미가 없고, 전체 데이터가 있을 때 아카이브 로그를 적용하여 최대한 변경된 내용에 가깝게 데이터를 복구하는데 사용한다. 대부분 다음 순서와 같이 운영될 것이다.


1. 전체 백업

2. 로그 쌓임

3. 1번부터 다시 반복


전체 백업은 자주 수행하지 않을 수도 있다. 그래서 아카이브 로그를 오래 보관할 필요가 있는 곳도 있는데 이렇게 되면 아카이브 로그를 보관할 공간에 대한 부담이 점차 커지게 된다. 그래서 보통 이전 시점으로 복구할 가능성이 낮다고 하면 전체 백업을 수행하고 이전 전체 백업 이후로 쌓인 아카이브 로그 파일은 삭제한다.


아카이브 로그는 파일시스템에 저장되며 이는 현재 DB에서 사용중인 트랜잭션 로그 파일과는 위치를 분리하는 것이 안전하다.

직접 rm, del명령으로 아카이브 로그 파일을 삭제할 수도 있으나 좀 더 안전하게 삭제하려면 prune 명령을 사용한다.


prune 명령을 사용하는 방법은 다음과 같다.

>>-PRUNE-------------------------------------------------------->
>--+-HISTORY--timestamp--+-------------------+--+------------+-+-><
   |                     '-WITH FORCE OPTION-'  '-AND DELETE-' |
   '-LOGFILE PRIOR TO--log-file-name---------------------------'

prune 명령은 시점을 지정하여 복구 실행기록 파일을 정리할 때 사용한다.
db2 prune history 20120819 와 같이 사용할 경우 이 날짜 이전의 모든 기록은 삭제된다.
db2 prune history 20120819 and delete 옵션을 사용했을때는 그 시점 이전의 기록을 참조하여 연관된 아카이브 파일이 더 이상 필요하지 않으면 삭제한다.

logfile prior to 옵션은 지정한 로그파일 이전의 로그를 삭제하는 옵션으로 logretain 매개변수가 recovery로 설정되어 있을 때만 사용가능하다. logretain을 설정했을 때는 logarchmeth1 또한 logretain으로 설정되고 현재 사용중이 로그파일과 아카이브 로그가 같은 위치에 저장되므로 이 옵션으로 아카이브 로그를 삭제하는 편이 안전하다. 이 옵션으로 아카이브 로그를 삭제하면 현재 사용중인 로그 파일은 삭제하지 않는다.



http://publib.boulder.ibm.com/infocenter/db2luw/v8/index.jsp?topic=/com.ibm.db2.udb.doc/core/r0001992.htm



728x90
728x90

Question

If you want to restore a table space level backup image, the table space must exist prior to the restore operation, and the restore operation must be targeted to the same database. (This does not apply to version 9.5 or later if you are performing a RESTORE ... REBUILD operation using table space restores.)

Answer

Symptom: SQL2549N (the database was not restored because either all of the table spaces in the backup image are inaccessible, or one or more table space names in list of table space names to restore are invalid) while trying to restore a table space-level backup with redirect.

Cause: SQL2549N is returned if the table space has been dropped prior to the restore operation.

Action: Do not drop a table space if that table space is to be restored from a table space-level backup image, even if you want to change the container path. If you want to restore a table space level backup image, the table space must exist prior to the restore operation, and the restore operation must be targeted to the same database.



728x90
728x90

db2pd 명령은 DB2® 메모리 세트에서 신속하면서도 즉각적으로 정보를 리턴할 수 있기 때문에 문제점 해결에 사용됩니다.

개요

이 도구는 래치를 획득하거나 엔진 자원을 사용하지 않고 정보를 수집합니다. 그러므로 db2pd가 정보를 수집하는 동안 변경되고 있는 정보를 검색하는 것이 가능하며 예측됩니다. 따라서 데이터가 완전히 정확하지는 않을 수도 있습니다. 변경되는 메모리 포인터가 발생하면, db2pd가 비정상적으로 종료되지 않도록 신호 핸들러가 사용됩니다. 이로 인해 출력에 "데이터 구조 변경으로 명령이 강제로 종료됨"과 같은 메시지가 표시될 수 있습니다. 그럼에도 불구하고 이 도구는 문제점 해결에 유용할 수 있습니다. 래칭 없이 정보를 수집할 경우의 두 가지 이점은 신속한 검색 및 엔진 자원 경합이 없다는 점입니다.

특정 SQLCODE, ZRC 코드 또는 ECF 코드가 발생할 때 데이터베이스 관리 시스템에 대한 정보를 캡처하려면, db2pdcfg -catch 명령을 사용하여 이를 수행할 수 있습니다. 오류가 발생한 경우, db2cos(콜아웃 스크립트)가 시작됩니다. db2cos 스크립트를 동적으로 변경하여 db2pd 명령, 운영 체제 명령 또는 문제점을 해결하는 데 필요한 기타 명령을 실행할 수 있습니다. 템플리트 db2cos 스크립트 파일은 UNIX 및 Linux의 경우 sqllib/bin에 있습니다. Windows 운영 체제의 경우, db2cos는 $DB2PATH\bin 디렉토리에 있습니다.

새 노드를 추가하는 경우, db2pd -addnode 명령을 선택적 oldviewapps  detail 매개변수와 함께 사용하여 노드를 추가하고 있는 데이터베이스 파티션 서버에서 조작 진행을 모니터하여 자세한 정보를 얻을 수 있습니다.

현재 사용 중이거나 어떤한 이유로 비활성화된 이벤트 모니터 목록이 필요하면, db2pd -gfw 명령을 실행하십시오. 또한 이 명령은 각 고속 기록기 EDU에 대해 이벤트 모니터가 데이터를 기록하는 대상에 대한 정보와 통계를 리턴합니다.

예 1: 잠금 대기 진단

db2pd -db databasename -locks -transactions -applications -dynamic을 실행하는 경우, 결과는 다음과 유사합니다.
Locks:
Address            TranHdl Lockname                   Type Mode Sts Owner Dur HldCnt Att    ReleaseFlg
0x07800000202E5238 3       00020002000000040000000052 Row  ..X  G   3     1   0      0x0000 0x40000000
0x07800000202E4668 2       00020002000000040000000052 Row  ..X  W*  2     1   0      0x0000 0x40000000
-db 데이터베이스 이름 옵션을 사용하여 지정한 데이터베이스의 경우, 첫 번째 결과로 해당 데이터베이스에 대한 잠금이 표시됩니다. 이 결과는 TranHdl 2가 TranHdl 3에서 보유한 잠금에 대해 대기 중임을 표시합니다.
Transactions:
Address            AppHandl [nod-index] TranHdl Locks State Tflag      Tflag2     Firstlsn       Lastlsn        LogSpace SpaceReserved TID            AxRegCnt GXID
0x0780000020251B80 11       [000-00011] 2       4     READ  0x00000000 0x00000000 0x000000000000 0x000000000000 0        0             0x0000000000B7 1        0
0x0780000020252900 12       [000-00012] 3       4     WRITE 0x00000000 0x00000000 0x000000FA000C 0x000000FA000C 113      154           0x0000000000B8 1        0
TranHdl 2는 AppHandl 11과 연관되고 TranHdl 3은 AppHandl 12와 연관됨을 알 수 있습니다.
Applications:
Address            AppHandl [nod-index] NumAgents CoorPid Status        C-AnchID C-StmtUID L-AnchID L-StmtUID Appid
0x07800000006879E0 12       [000-00012] 1         1073336 UOW-Waiting   0        0         17       1         *LOCAL.burford.060303225602
0x0780000000685E80 11       [000-00011] 1         1040570 UOW-Executing 17       1         94       1         *LOCAL.burford.060303225601
AppHandl 12는 동적문 17, 1을 마지막으로 실행했음을 알 수 있습니다. ApplHandl 11은 동적문 17, 1을 현재 실행 중이며 명령문 94, 1을 마지막으로 실행했습니다.
Dynamic SQL Statements:
Address            AnchID StmtUID NumEnv NumVar NumRef NumExe Text
0x07800000209FD800 17     1       1      1      2      2      update pdtest set c1 = 5
0x07800000209FCCC0 94     1       1      1      2      2      set lock mode to wait 1
텍스트 컬럼이 잠금 시간종료와 연관된 SQL문을 표시함을 알 수 있습니다.

예 2: -wlocks 매개변수를 사용하여 대기 중인 잠금 모두 캡처

db2pd -wlocks -db pdtest를 실행하는 경우, 다음과 유사한 결과가 생성됩니다. 첫 번째 응용프로그램(AppHandl 47)은 테이블에서 삽입을 수행 중이고 두 번째 응용프로그램(AppHandl 46)은 해당 테이블에서 선택을 수행 중임을 표시합니다.
venus@boson:/home/venus =>db2pd -wlocks -db pdtest
Database Partition 0 -- Database PDTEST -- Active -- Up 0 days 00:01:22
Locks being waited on :
AppHandl [nod-index] TranHdl    Lockname                   Type    Mode Conv Sts CoorEDU    AppName  AuthID   AppID
47       [000-00047] 8          00020004000000000840000652 Row     ..X       G   5160       db2bp    VENUS    *LOCAL.venus.071207213730
46       [000-00046] 2          00020004000000000840000652 Row     .NS       W   5913       db2bp    VENUS    *LOCAL.venus.071207213658

예 3: -apinfo 매개변수를 사용하여 잠금 소유자 및 잠금 대기자에 대한 자세한 런타임 정보 캡처

예 2와 동일한 조건에서 다음 샘플 출력이 생성되었습니다.
venus@boson:/home/venus =>db2pd -apinfo 47 -db pdtest
Database Partition 0 -- Database PDTEST -- Active -- Up 0 days 00:01:30
Application :
  Address :                0x0780000001676480
  AppHandl [nod-index] :   47       [000-00047]
  Application PID :        876558
  Application Node Name :  boson
  IP Address:              n/a
  Connection Start Time :  (1197063450)Fri Dec  7 16:37:30 2007
  Client User ID :         venus
  System Auth ID :         VENUS
  Coordinator EDU ID :     5160
  Coordinator Partition :  0
  Number of Agents :       1
  Locks timeout value :    4294967294 seconds
  Locks Escalation :       No
  Workload ID :            1
  Workload Occurrence ID : 2
  Trusted Context :        n/a
  Connection Trust Type :  non trusted
  Role Inherited :         n/a
  Application Status :     UOW-Waiting
  Application Name :       db2bp
  Application ID :         *LOCAL.venus.071207213730
  ClientUserID :           n/a
  ClientWrkstnName :       n/a
  ClientApplName :         n/a
  ClientAccntng :          n/a
  List of inactive statements of current UOW :
    UOW-ID :          2
    Activity ID :     1
    Package Schema :  NULLID
    Package Name :    SQLC2G13
    Package Version :
    Section Number :  203
    SQL Type :        Dynamic
    Isolation :       CS
    Statement Type :  DML, Insert/Update/Delete
    Statement :       insert into pdtest values 99
venus@boson:/home/venus =>db2pd -apinfo 46 -db pdtest
Database Partition 0 -- Database PDTEST -- Active -- Up 0 days 00:01:39
Application :
  Address :                0x0780000000D77A60
  AppHandl [nod-index] :   46       [000-00046]
  Application PID :        881102
  Application Node Name :  boson
  IP Address:              n/a
  Connection Start Time :  (1197063418)Fri Dec  7 16:36:58 2007
  Client User ID :         venus
  System Auth ID :         VENUS
  Coordinator EDU ID :     5913
  Coordinator Partition :  0
  Number of Agents :       1
  Locks timeout value :    4294967294 seconds
  Locks Escalation :       No
  Workload ID :            1
  Workload Occurrence ID : 1
  Trusted Context :        n/a
  Connection Trust Type :  non trusted
  Role Inherited :         n/a
  Application Status :     Lock-wait
  Application Name :       db2bp
  Application ID :         *LOCAL.venus.071207213658
  ClientUserID :           n/a
  ClientWrkstnName :       n/a
  ClientApplName :         n/a
  ClientAccntng :          n/a
  List of active statements :
   *UOW-ID :          3
    Activity ID :     1
    Package Schema :  NULLID
    Package Name :    SQLC2G13
    Package Version :
    Section Number :  201
    SQL Type :        Dynamic
    Isolation :       CS
    Statement Type :  DML, Select (blockable)
    Statement :       select * from pdtest

예 4: 잠금 문제점 고려 시 콜라웃 스크립트 사용

콜아웃 스크립트를 사용하려면 db2cos 출력 파일을 찾으십시오. 데이터베이스 관리자 구성 매개변수 diagpath가 파일 위치를 제어합니다. 출력 파일의 컨텐츠는 db2cos 스크립트 파일에 입력하는 명령에 따라 다릅니다. db2cos 스크립트 파일에 db2pd -db sample -locks 명령이 포함된 경우 제공된 출력 예는 다음과 같습니다.
Lock Timeout Caught
Thu Feb 17 01:40:04 EST 2006
Instance DB2
Database: SAMPLE
Partition Number: 0
PID: 940
TID: 2136
Function: sqlplnfd
Component: lock manager
Probe: 999
Timestamp: 2006-02-17-01.40.04.106000
AppID: *LOCAL.DB2...
AppHdl:
...
Database Partition 0 -- Database SAMPLE -- Active -- Up 0 days 00:06:53
Locks:
Address    TranHdl Lockname                   Type Mode Sts Owner Dur HldCnt Att Rlse
0x402C6B30 3       00020003000000040000000052 Row  ..X  W*  3     1   0      0   0x40

출력에서 W*는 시간종료가 발생한 잠금을 표시합니다. 이 경우, 잠금 대기가 발생했습니다. 잠금이 상위 모드로 변환되는 경우에는 잠금 시간종료도 발생할 수 있습니다. 이는 출력에 C*로 표시됩니다.

결과를 트랜잭션, 응용프로그램, 에이전트 또는 db2cos 파일에 기타 db2pd 명령이 제공한 출력이 있는 SQL문에 맵핑할 수 있습니다. 출력 범위를 좁히거나 기타 명령을 사용하여 필요한 정보를 수집할 수 있습니다. 예를 들어, db2pd -locks wait 매개변수를 사용하여 활성화된 대기 상태인 잠금만 인쇄할 수 있습니다. 또한 -app  -agent 매개변수를 사용할 수 있습니다.

예 5: 응용프로그램을 동적 SQL문에 맵핑

db2pd -applications -dynamic 명령은 동적 SQL문에 대한 현재 및 마지막 앵커 ID와 명령문 고유 ID를 보고합니다. 따라서 응용프로그램에서 동적 SQL문으로의 직접 맵핑이 가능합니다.

Applications:
Address            AppHandl [nod-index] NumAgents  CoorPid  Status
0x00000002006D2120 780      [000-00780] 1          10615    UOW-Executing
C-AnchID C-StmtUID  L-AnchID L-StmtUID  Appid
163      1          110      1          *LOCAL.burford.050202200412
Dynamic SQL Statements:
Address            AnchID StmtUID NumEnv NumVar NumRef NumExe Text
0x0000000220A02760 163    1       2      2      2      1      CREATE VIEW MYVIEW
0x0000000220A0B460 110    1       2      2      2      1      CREATE VIEW YOURVIEW

예 6: 메모리 사용 모니터링

다음 샘플 출력에 표시된 대로 메모리 사용을 이해하려면 db2pd -memblock 명령이 유용할 수 있습니다.

All memory blocks in DBMS set.
Address            PoolID   PoolName   BlockAge   Size(Bytes) I LOC   File
0x0780000000740068 62       resynch    2          112         1 1746  1583816485
0x0780000000725688 62       resynch    1          108864      1 127   1599127346
0x07800000001F4348 57       ostrack    6          5160048     1 3047  698130716
0x07800000001B5608 57       ostrack    5          240048      1 3034  698130716
0x07800000001A0068 57       ostrack    1          80          1 2970  698130716
0x07800000001A00E8 57       ostrack    2          240         1 2983  698130716
0x07800000001A0208 57       ostrack    3          80          1 2999  698130716
0x07800000001A0288 57       ostrack    4          80          1 3009  698130716
0x0780000000700068 70       apmh       1          360         1 1024  3878879032
0x07800000007001E8 70       apmh       2          48          1 914   1937674139
0x0780000000700248 70       apmh       3          32          1 1000  1937674139
...

이 다음에는 정렬된 '풀별' 출력이 옵니다.

Memory blocks sorted by size for ostrack pool:
PoolID     PoolName   TotalSize(Bytes)     TotalCount LOC   File
57         ostrack    5160048              1          3047  698130716
57         ostrack    240048               1          3034  698130716
57         ostrack    240                  1          2983  698130716
57         ostrack    80                   1          2999  698130716
57         ostrack    80                   1          2970  698130716
57         ostrack    80                   1          3009  698130716
Total size for ostrack pool: 5400576 bytes
Memory blocks sorted by size for apmh pool:
PoolID     PoolName   TotalSize(Bytes)     TotalCount LOC   File
70         apmh       40200                2          121   2986298236
70         apmh       10016                1          308   1586829889
70         apmh       6096                 2          4014  1312473490
70         apmh       2516                 1          294   1586829889
70         apmh       496                  1          2192  1953793439
70         apmh       360                  1          1024  3878879032
70         apmh       176                  1          1608  1953793439
70         apmh       152                  1          2623  1583816485
70         apmh       48                   1          914   1937674139
70         apmh       32                   1          1000  1937674139
Total size for apmh pool: 60092 bytes
...

출력의 최종 섹션은 전체 메모리 세트에 대해 메모리 소비자를 정렬합니다.

All memory consumers in DBMS memory set:
PoolID     PoolName   TotalSize(Bytes)     %Bytes TotalCount %Count LOC   File
57         ostrack    5160048              71.90  1          0.07   3047  698130716
50         sqlch      778496               10.85  1          0.07   202   2576467555
50         sqlch      271784               3.79   1          0.07   260   2576467555
57         ostrack    240048               3.34   1          0.07   3034  698130716
50         sqlch      144464               2.01   1          0.07   217   2576467555
62         resynch    108864               1.52   1          0.07   127   1599127346
72         eduah      108048               1.51   1          0.07   174   4210081592
69         krcbh      73640                1.03   5          0.36   547   4210081592
50         sqlch      43752                0.61   1          0.07   274   2576467555
70         apmh       40200                0.56   2          0.14   121   2986298236
69         krcbh      32992                0.46   1          0.07   838   698130716
50         sqlch      31000                0.43   31         2.20   633   3966224537
50         sqlch      25456                0.35   31         2.20   930   3966224537
52         kerh       15376                0.21   1          0.07   157   1193352763
50         sqlch      14697                0.20   1          0.07   345   2576467555
...

UNIX 및 Linux 운영 체제에서는 전용 메모리에 대한 메모리 블록도 보고할 수 있습니다. 예를 들어, db2pd -memb pid=159770을 실행하는 경우 다음과 유사한 결과가 생성됩니다.

All memory blocks in Private set. 
Address            PoolID     PoolName     BlockAge   Size(Bytes) I LOC   File 
0x0000000110469068 88         private      1          2488        1 172   4283993058
0x0000000110469A48 88         private      2          1608        1 172   4283993058
0x000000011046A0A8 88         private      3          4928        1 172   4283993058
0x000000011046B408 88         private      4          7336        1 172   4283993058
0x000000011046D0C8 88         private      5          32          1 172   4283993058
0x000000011046D108 88         private      6          6728        1 172   4283993058
0x000000011046EB68 88         private      7          168         1 172   4283993058
0x000000011046EC28 88         private      8          24          1 172   4283993058
0x000000011046EC68 88         private      9          408         1 172   4283993058
0x000000011046EE28 88         private      10         1072        1 172   4283993058
0x000000011046F288 88         private      11         3464        1 172   4283993058
0x0000000110470028 88         private      12         80          1 172   4283993058
0x00000001104700A8 88         private      13         480         1 1534  862348285 
0x00000001104702A8 88         private      14         480         1 1939  862348285 
0x0000000110499FA8 88         private      80         65551       1 1779  4231792244
Total set size: 94847 bytes
Memory blocks sorted by size:
PoolID     PoolName   TotalSize(Bytes)     TotalCount LOC   File      
88         private    65551                1          1779  4231792244
88         private    28336                12         172   4283993058
88         private    480                  1          1939  862348285 
88         private    480                  1          1534  862348285 
Total set size: 94847 bytes

예 7: 테이블스페이스를 다 사용하고 있는 응용프로그램 식별

db2pd -tcbstats를 사용하여 테이블에 대한 삽입 수를 식별할 수 있습니다. 다음은 TEMP1이라는 사용자 정의 전역 임시 테이블에 대한 샘플 정보입니다.

TCB Table Information:
Address            TbspaceID TableID PartID MasterTbs MasterTab TableName  SchemaNm ObjClass DataSize  LfSize LobSize XMLSize
0x0780000020B62AB0 3         2       n/a    3         2         TEMP1      SESSION  Temp     966       0      0       0 
TCB Table Stats:
Address            TableName   Scans   UDI   PgReorgs   NoChgUpdts   Reads   FscrUpdates Inserts   Updates   Deletes   OvFlReads OvFlCrtes 
0x0780000020B62AB0 TEMP1       0       0     0          0            0       0           43968     0         0          0        0         

db2pd -tablespaces 명령을 사용하여 테이블스페이스 3에 대한 정보를 얻을 수 있습니다. 샘플 출력은 다음과 같습니다.

Tablespace 3 Configuration:
Address            Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe  LastConsecPg Name
0x0780000020B1B5A0 DMS  UsrTmp  4096   32       Yes  32       1     1         on  1        0          31           TEMPSPACE2
Tablespace 3 Statistics:
Address            TotalPgs   UsablePgs  UsedPgs    PndFreePgs FreePgs    HWM        State      MinRecTime NQuiescers
0x0780000020B1B5A0 5000       4960       1088       0          3872       1088       0x00000000 0          0          
Tablespace 3 Autoresize Statistics:
Address            AS  AR  InitSize    IncSize     IIP MaxSize     LastResize      LRF
0x0780000020B1B5A0 No  No  0           0           No  0           None            No  
Containers:
Address            ContainNum Type    TotalPgs   UseablePgs StripeSet  Container 
0x0780000020B1DCC0 0          File    5000       4960       0          /home/db2inst1/tempspace2a

FreePgs 컬럼은 스페이스를 채우고 있음을 표시합니다. 사용 가능한 페이지 값이 줄어들면 사용 가능한 스페이스도 줄어듭니다. 또한 FreePgs 값에UsedPgs 값을 더하면 UsablePgs 값과 같음에 유의하십시오.

이를 알았으면 db2pd -db sample -dyn을 실행하여 TEMP1 테이블을 사용 중인 동적 SQL문을 식별할 수 있습니다.

Database Partition 0 -- Database SAMPLE -- Active -- Up 0 days 00:13:06
Dynamic Cache:
Current Memory Used           1022197
Total Heap Size               1271398
Cache Overflow Flag           0
Number of References          237
Number of Statement Inserts   32
Number of Statement Deletes   13
Number of Variation Inserts   21
Number of Statements          19
Dynamic SQL Statements:
Address            AnchID StmtUID  NumEnv  NumVar  NumRef  NumExe  Text
0x0000000220A08C40 78     1        2       2       3       2       declare global temporary table temp1 (c1 char(6)) not logged
0x0000000220A8D960 253    1        1       1       24      24      insert into session.temp1 values('TEST')

마지막으로, db2pd -db sample -app를 실행하여 이전 출력의 정보를 응용프로그램 출력에 맵핑하여 응용프로그램을 식별할 수 있습니다.

Applications:
Address            AppHandl [nod-index] NumAgents  CoorPid Status
0x0000000200661840 501      [000-00501] 1          11246   UOW-Waiting
C-AnchID C-StmtUID  L-AnchID L-StmtUID  Appid
0        0          253      1          *LOCAL.db2inst1.050202160426

동적 SQL문을 식별한 앵커 ID(AnchID) 값을 사용하여 연관된 응용프로그램을 식별할 수 있습니다. 결과는 마지막 앵커 ID(L-AnchID) 값이 앵커 ID(AnchID) 값과 동일함을 표시합니다. 다음 번에 db2pd를 실행할 때 db2pd 실행 결과를 사용하십시오.

db2pd -agent 출력은 응용프로그램이 읽은 행 수를 Rowsread 컬럼에, 기록한 행 수를 Rowswrtn 컬럼에 표시합니다. 다음 샘플 출력에 표시된 대로 이러한 값을 통해 응용프로그램이 완료한 것과 응용프로그램이 여전히 완료해야 하는 것을 알 수 있습니다.
Address            AppHandl [nod-index] AgentPid  Priority  Type	DBName
0x0000000200698080 501      [000-00501] 11246     0         Coord	SAMPLE
State       ClientPid  Userid   ClientNm Rowsread   Rowswrtn   LkTmOt
Inst-Active 26377      db2inst1 db2bp    22         9588       NotSet

db2pd -agent 명령 실행으로 발생하는 AppHandl  AgentPid 값을 db2pd -app 명령 실행으로 발생하는 AppHandl  CoorPid 값에 맵핑할 수 있습니다.

내부 임시 테이블이 테이블스페이스를 채우고 있다고 예측되는 경우에는 단계가 약간 다릅니다. 그러나 db2pd -tcbstats를 사용하여 삽입이 많은 테이블을 식별하십시오. 다음은 내재된 임시 테이블에 대한 샘플 정보입니다.

TCB Table Information:
Address            TbspaceID TableID PartID MasterTbs MasterTab TableName          SchemaNm ObjClass    DataSize  ...     
0x0780000020CC0D30 1         2       n/a    1         2         TEMP (00001,00002) <30>     <JMC Temp   2470      ...
0x0780000020CC14B0 1         3       n/a    1         3         TEMP (00001,00003) <31>     <JMC Temp   2367      ...
0x0780000020CC21B0 1         4       n/a    1         4         TEMP (00001,00004) <30>     <JMC Temp   1872      ...
TCB Table Stats:
Address            TableName          Scans   UDI   PgReorgs   NoChgUpdts Reads   FscrUpdates Inserts ... 
0x0780000020CC0D30 TEMP (00001,00002) 0       0     0          0          0       0           43219   ...
0x0780000020CC14B0 TEMP (00001,00003) 0       0     0          0          0       0           42485   ...
0x0780000020CC21B0 TEMP (00001,00004) 0       0     0          0          0       0           0       ...

이 예에서는 TEMP (TbspaceID, TableID) 이름 지정 규칙을 가진 테이블에 대한 많은 삽입이 있습니다. 이는 내재된 임시 테이블입니다.SchemaNm 컬럼 값에서는 AppHandl 값 이름 지정 규칙이 SchemaNm 값과 병합되므로 작업 수행 중인 응용프로그램을 식별할 수 있습니다.

그런 다음, 해당 정보를 db2pd -tablespaces 출력에 맵핑하여 테이블스페이스 1에 사용한 스페이스를 확인할 수 있습니다. 다음 출력의 테이블스페이스 통계에서 UsedPgs 값과 UsablePgs 값 간의 관계에 주의하십시오.

Tablespace Configuration:
Address            Id    Type Content PageSz ExtentSz Auto Prefetch BufID BufIDDisk FSC NumCntrs MaxStripe LastConsecPg Name
0x07800000203FB5A0 1     SMS  SysTmp  4096   32       Yes  320      1     1         on  10       0         31           TEMPSPACE1
Tablespace Statistics:
Address            Id    TotalPgs   UsablePgs  UsedPgs    PndFreePgs FreePgs    HWM    State      MinRecTime NQuiescers
0x07800000203FB5A0 1     6516       6516       6516       0          0          0      0x00000000 0          0
Tablespace Autoresize Statistics:
Address            Id    AS  AR  InitSize    IncSize     IIP MaxSize     LastResize  LRF
0x07800000203FB5A0 1     No  No  0           0           No  0           None        No
Containers:
...

-tcbstats 출력에서 응용프로그램 핸들 30 및 31을 보았으므로 db2pd -app 명령을 사용하여 이를 식별할 수 있습니다.

Applications:
Address            AppHandl [nod-index] NumAgents  CoorPid    Status          C-AnchID C-StmtUID  L-AnchID   L-StmtUID  Appid
0x07800000006FB880 31       [000-00031] 1          4784182    UOW-Waiting     0        0          107        1          *LOCAL.db2inst1.051215214142
0x07800000006F9CE0 30       [000-00030] 1          8966270    UOW-Executing   107      1          107        1          *LOCAL.db2inst1.051215214013

마지막으로, 이전 출력의 정보를 db2pd -dyn 명령을 실행하여 확보한 동적 SQL 출력에 맵핑할 수 있습니다.

Dynamic SQL Statements:
Address            AnchID StmtUID    NumEnv     NumVar     NumRef     NumExe     Text
0x0780000020B296C0 107    1          1          1          43         43         select c1, c2 from test group by c1,c2

예 8: 복구 모니터링

db2pd -recovery 명령을 실행하는 경우, 다음 샘플 출력에 표시된 대로 출력은 복구가 진행 중임을 검증하는 데 사용할 수 있는 몇 개의 카운터를 표시합니다. Current Log  Current LSN 값은 로그 위치 지정을 제공합니다. CompletedWork 값은 지금까지 완료된 바이트 수입니다.

Recovery:
Recovery Status     0x00000401
Current Log         S0000005.LOG
Current LSN         000002551BEA
Job Type            ROLLFORWARD RECOVERY
Job ID              7
Job Start Time      (1107380474) Wed Feb  2 16:41:14 2005
Job Description     Database Rollforward Recovery
Invoker Type        User
Total Phases        2
Current Phase       1
Progress:
Address            PhaseNum Description StartTime                CompletedWork  TotalWork
0x0000000200667160 1        Forward     Wed Feb  2 16:41:14 2005 2268098 bytes  Unknown
0x0000000200667258 2        Backward    NotStarted               0 bytes        Unknown

예 9: 트랜잭션이 사용 중인 자원 양 판별

db2pd -transactions 명령을 실행하는 경우, 다음 샘플 출력에 표시된 대로 출력은 잠금 수, 첫 번째 로그 시퀀스 번호(LSN), 마지막 LSN, 사용한 로그 스페이스, 예약된 스페이스를 표시합니다. 이는 트랜잭션 동작을 이해하는 데 유용할 수 있습니다.

Transactions:
Address            AppHandl [nod-index] TranHdl  Locks  State  Tflag
0x000000022026D980 797      [000-00797] 2        108    WRITE  0x00000000
0x000000022026E600 806      [000-00806] 3        157    WRITE  0x00000000
0x000000022026F280 807      [000-00807] 4        90     WRITE  0x00000000
Tflag2     Firstlsn       Lastlsn        LogSpace   SpaceReserved
0x00000000 0x000001072262 0x0000010B2C8C 4518       95450
0x00000000 0x000001057574 0x0000010B3340 6576       139670
0x00000000 0x00000107CF0C 0x0000010B2FDE 3762       79266
TID            AxRegCnt   GXID
0x000000000451 1          0
0x0000000003E0 1          0
0x000000000472 1          0

예 10: 로그 사용 모니터링

db2pd -logs 명령은 데이터베이스에 대한 로그 사용 모니터링에 유용합니다. 다음 샘플 출력에 표시된 대로 Pages Written 값을 사용하여 로그 사용이 증가하고 있는지 여부를 판별할 수 있습니다.

Logs:
Current Log Number            0
Pages Written                 0
Cur Commit Disk Log Reads     0
Cur Commit Total Log Reads    0
Method 1 Archive Status       n/a
Method 1 Next Log to Archive  n/a
Method 1 First Failure        n/a
Method 2 Archive Status       n/a
Method 2 Next Log to Archive  n/a
Method 2 First Failure        n/a
Log Chain ID                  0
Current LSN                   0x0000000001F40010
Address            StartLSN       State      Size  Pages  Filename
0x00002B75E9E3D2D0 0000000001F40010 0x00000000 1000      1000      S0000000.LOG
0x00002B75E9E53D70 0000000002328010 0x00000000 1000      1000      S0000001.LOG
0x00002B75E9E545D0 0000000002710010 0x00000000 1000      1000      S0000002.LOG
이 출력을 사용하여 다음 두 가지 유형의 문제점을 식별할 수 있습니다.
  • 가장 최근의 로그 아카이브가 실패하면, Archive Status Failure 값으로 설정됩니다. 진행 중인 아카이브 실패가 있고 로그가 전혀 아카이브되지 않는다면, Archive Status First Failure 값으로 설정됩니다.
  • 로그 아카이브가 아주 느린 속도로 진행되는 경우, Next Log to Archive 값이 Current Log Number 값보다 작습니다. 아카이브 속도가 아주 느린 경우, 사용 중인 로그 스페이스가 부족할 수 있으며 이로 인해 데이터 변경이 데이터베이스에서 발생하지 못할 수 있습니다.

예 11: Sysplex 목록 보기

db2pd -sysplex 명령이 다음 샘플 출력을 표시하지 않는 경우, sysplex 목록을 보고하는 다른 유일한 방법은 DB2 추적을 사용하는 것입니다.

Sysplex List:
Alias:         HOST
Location Name: HOST1
Count:         1
IP Address      Port       Priority   Connections Status     PRDID
 1.2.34.56      400        1          0           0

예 12: 스택 추적 작성

Windows 운영 체제의 경우 db2pd -stack all 명령을, 또는 UNIX 운영 체제의 경우 -stack 명령을 사용하여 현재 데이터베이스 파티션의 모든 프로세스에 대한 스택 추적을 생성할 수 있습니다. 프로세스 또는 스레드가 루프 또는 정지 중이라고 예측되는 경우에는 이 명령을 반복적으로 사용할 수 있습니다.

다음 예에 표시된 대로 db2pd -stack eduid 명령을 실행하여 특정 엔진 디스패치 가능 단위(EDU)에 대한 현재 모든 스택을 확보할 수 있습니다.

  Attempting to dump stack trace for eduid 137.
  See current DIAGPATH for trapfile.

예를 들어, 모든 DB2 프로세스에 대한 호출 스택을 원할 경우 Windows 운영 체제에서는 db2pd -stack all 명령을 사용하십시오.

  Attempting to dump all stack traces for instance.
  See current DIAGPATH for trapfiles.

실제 노드가 여러 개인 파티션된 데이터베이스 환경을 사용 중인 경우, db2_all "; db2pd -stack all" 명령을 사용하여 모든 파티션에서 정보를 얻을 수 있습니다. 그러나 파티션이 동일한 시스템에서 모두 논리적 파티션인 경우, 보다 빠른 방법은 db2pd -alldbp -stacks를 사용하는 것입니다.

dumpdir 매개변수를 사용하여 특정 디렉토리 경로로 db2pdb -stacks 명령 출력 경로를 재지정하고 timeout 매개변수를 사용하여 특정 지속기간 동안만 출력 경로를 재지정할 수도 있습니다. 예를 들어, 모든 프로세스에 대한 스택 추적 출력의 경로를 30초 동안 /home/waleed/mydir로 재지정하려면 다음 명령을 실행하십시오.

db2pd -alldbp -stack all dumpdir=/home/waleed/mydir timeout=30

예 13: 데이터베이스 파티션에 대한 메모리 통계 보기

db2pd -dbptnmem 명령은 DB2 서버가 현재 사용 중인 메모리 양과 상위 레벨에서 해당 메모리를 사용 중인 서버 영역을 표시합니다.

다음은 AIX® 시스템에서 db2pd -dbptnmem 실행으로 인한 출력 예입니다.

Database Partition Memory Controller Statistics
Controller Automatic: Y
Memory Limit:   122931408KB
Current usage:     651008KB
HWM usage:         651008KB
Cached memory:     231296KB
이러한 데이터 필드 및 컬럼에 대한 설명은 다음과 같습니다.
Controller Automatic
메모리 제어기 설정을 표시합니다. instance_memory 구성 매개변수가 AUTOMATIC으로 설정된 경우 "Y" 값을 표시합니다. 이는 데이터베이스 관리자가 메모리 소비 상한값을 자동으로 판별함을 의미합니다.
Memory Limit
인스턴스 메모리 한계가 강제 실행되는 경우, instance_memory 구성 매개변수의 값은 사용할 수 있는 DB2 서버의 상한값입니다.
Current usage
서버가 현재 소비하고 있는 메모리의 양입니다.
HWM usage
db2start 명령이 실행될 때 데이터베이스 파티션이 활성화된 이후로 소비된 상위 워터 마크(HWM) 또는 최대 메모리 사용량입니다.
Cached memory
현재 사용되고 있지 않지만 향후 메모리 요청을 위해 성능상의 이유로 캐시된 현재 사용 양입니다.

다음은 AIX 운영 체제에서 db2pd -dbptnmem 실행으로 인한 샘플 출력의 연속입니다.

Individual Memory Consumers:
Name           Mem Used (KB)   HWM Used (KB)   Cached (KB)
===========================================================
APPL-DBONE       160000          160000        159616 
DBMS-name         38528           38528          3776 
FMP_RESOURCES     22528           22528             0 
PRIVATE           13120           13120           740 
FCM_RESOURCES     10048           10048             0 
LCL-p606416         128             128             0 
DB-DBONE         406656          406656         67200
DB2 서버 내 등록된 모든 메모리 "소비자"가 소비 중인 전체 메모리 양과 함께 나열됩니다. 컬럼 설명은 다음과 같습니다.
이름
메모리 소비자의 짧은 식별 이름. 예를 들면, 다음과 같습니다.
APPL-dbname
dbname 데이터베이스용으로 소비된 응용프로그램 메모리
DBMS-name
전역 데이터베이스 관리자 메모리 요구사항
FMP_RESOURCES
db2fmps와 통신하는 데 필요한 메모리
PRIVATE
기타 전용 메모리 요구사항
FCM_RESOURCES
FCM(Fast Communication Manager) 자원
LCL-pid
로컬 응용프로그램과 통신하는 데 사용된 메모리 세그먼트
DB-dbname
dbname 데이터베이스용으로 소비된 데이터베이스 메모리
Mem Used (KB)
소비자에게 현재 할당된 메모리 양
HWM Used (KB)
소비자가 사용한 메모리의 상위 워터 마크(HWM) 또는 최대 메모리
Cached (KB)
Mem Used (KB) 중에서, 현재 사용되고 있지 않지만 향후 메모리 할당에 즉시 사용할 수 있는 메모리 양

예 14: 인덱스 재구성 진행 모니터링

DB2 버전 9.7 Fixpack 2 이상의 Fixpack에서는 인덱스 재구성에 대한 진행 보고서에 다음과 같은 특성이 포함됩니다.
  • db2pd -reorgs index 명령은 파티션된 인덱스에 대한 인덱스 Reorg 진행을 보고합니다(파티션되지 않은 인덱스에 대한 지원이 도입된 수정팩 1).
  • db2pd -reorgs index 명령은 파티션 레벨에서 인덱스 Reorg의 모니터링을 지원합니다(즉, 단일 파티션을 재구성하는 동안).
  • 파티션되지 않은 인덱스 및 파티션된 인덱스에 대한 Reorg 진행이 별도의 출력으로 보고됩니다. 하나의 출력에 파티션되지 않은 인덱스에 대한 Reorg 진행이 표시되고 다음 출력에 각 테이블 파티션의 파티션된 인덱스에 대한 Reorg 진행이 표시되며, 각 출력에 하나의 파티션에 대한 인덱스 Reorg 통계만 보고됩니다.
  • 파티션되지 않은 인덱스가 먼저 처리된 후 파티션된 인덱스가 순차적으로 처리됩니다.
  • db2pd -reorgs index 명령은 출력에 파티션된 인덱스에 대한 다음과 같은 추가 정보 필드를 표시합니다.
    • MaxPartition - 처리되는 테이블에 대한 총 파티션 수입니다. 파티션 레벨 Reorg의 경우 단일 파티션만 재구성되므로MaxPartition에 항상 1 값이 사용됩니다.
    • PartitionID - 처리되는 파티션에 대한 데이터 파티션 ID입니다.
다음은 파티션 2와 함께 범위에 따라 파티션된 테이블에 대한 인덱스 Reorg 진행을 보고하는 db2pd -reorgs index 명령을 사용하여 획득한 출력의 예입니다.
참고: 첫 번째 출력은 파티션되지 않은 인덱스의 인덱스 Reorg 상태를 보고합니다. 다음 출력은 각 파티션에서 파티션된 인덱스의 인덱스 Reorg 상태를 보고합니다.
Index Reorg Stats:
Retrieval Time: 02/08/2010 23:04:21
TbspaceID: -6       TableID: -32768
Schema: ZORAN    TableName: BIGRPT
Access: Allow none
Status: Completed
Start Time: 02/08/2010 23:03:55   End Time: 02/08/2010 23:04:04
Total Duration: 00:00:08
Prev Index Duration:  -
Cur Index Start: -
Cur Index: 0            Max Index: 2            Index ID: 0
Cur Phase: 0          ( -     )   Max Phase: 0
Cur Count: 0                      Max Count: 0
Total Row Count: 750000
Retrieval Time: 02/08/2010 23:04:21
TbspaceID: 2        TableID: 5
Schema: ZORAN    TableName: BIGRPT
PartitionID: 0      MaxPartition: 2
Access: Allow none
Status: Completed
Start Time: 02/08/2010 23:04:04   End Time: 02/08/2010 23:04:08
Total Duration: 00:00:04
Prev Index Duration:  -
Cur Index Start: -
Cur Index: 0            Max Index: 2            Index ID: 0
Cur Phase: 0          ( -     )   Max Phase: 0
Cur Count: 0                      Max Count: 0
Total Row Count: 375000
Retrieval Time: 02/08/2010 23:04:21
TbspaceID: 2        TableID: 6
Schema: ZORAN    TableName: BIGRPT
PartitionID: 1      MaxPartition: 2
Access: Allow none
Status: Completed
Start Time: 02/08/2010 23:04:08   End Time: 02/08/2010 23:04:12
Total Duration: 00:00:04
Prev Index Duration:  -
Cur Index Start: -
Cur Index: 0            Max Index: 2            Index ID: 0
Cur Phase: 0          ( -     )   Max Phase: 0
Cur Count: 0                      Max Count: 0
Total Row Count: 375000

예 15: 프로세서 시간 소모별 상위 EDU 표시 및 EDU 스택 정보 표시

-edus 매개변수 옵션을 사용하여 db2pd 명령을 실행하는 경우 출력에는 모든 EDU(Engine Dispatchable Unit)가 나열됩니다. EDU 출력은 인스턴스 레벨 또는 멤버 레벨과 같이 사용자가 지정하는 단위 레벨로 리턴될 수 있습니다. Linux 및 UNIX 운영 체제에 한하여 모든 EDU의 두 스냅샷이 사용자가 지정한 간격으로 분리되어 작성되도록 interval 매개변수 서브옵션을 지정할 수도 있습니다. interval 매개변수를 지정하는 경우 출력에 있는 2개의 추가 컬럼은 간격에 따라 프로세서 사용자 시간의 델타(USR DELTA 컬럼)와 프로세서 시스템 시간의 델타(SYS DELTA 컬럼)를 표시합니다.

다음 예에서는 5초 간격에 따라 프로세서 사용자 시간과 프로세서 시스템 시간의 델타가 제공됩니다.

$ db2pd -edus interval=5
Database Partition 0 -- Active -- Up 0 days 00:53:29 -- Date 06/04/2010 03:34:59
List of all EDUs for database partition 0
db2sysc PID: 1249522
db2wdog PID: 2068678
EDU ID    TID            Kernel TID      EDU Name                            USR           SYS         USR DELTA    SYS DELTA
=============================================================================================================================
6957      6957           13889683        db2agntdp (SAMPLE  ) 0              58.238506     0.820466    1.160726     0.014721
6700      6700           11542589        db2agent (SAMPLE) 0                 52.856696     0.754420    1.114821     0.015007
5675      5675           4559055         db2agntdp (SAMPLE  ) 0              60.386779     0.854234    0.609233     0.014304
3088      3088           13951225        db2agntdp (SAMPLE  ) 0              80.073489     2.249843    0.499766     0.006247
3615      3615           2887875         db2loggw (SAMPLE) 0                 0.939891      0.410493    0.011694     0.004204
4900      4900           6344925         db2pfchr (SAMPLE) 0                 1.748413      0.014378    0.014343     0.000103
7986      7986           13701145        db2agntdp (SAMPLE  ) 0              1.410225      0.025900    0.003636     0.000074
2571      2571           8503329         db2ipccm 0                          0.251349      0.083787    0.002551     0.000857
7729      7729           14168193        db2agntdp (SAMPLE  ) 0              1.717323      0.029477    0.000998     0.000038
7472      7472           11853991        db2agnta (SAMPLE) 0                 1.860115      0.032926    0.000860     0.000012
3358      3358           2347127         db2loggr (SAMPLE) 0                 0.151042      0.184726    0.000387     0.000458
515       515            13820091        db2aiothr 0                         0.405538      0.312007    0.000189     0.000178
7215      7215           2539753         db2agntdp (SAMPLE  ) 0              1.165350      0.019466    0.000291     0.000008
6185      6185           2322517         db2wlmd (SAMPLE) 0                  0.061674      0.034093    0.000169     0.000100
6442      6442           2756793         db2evmli (DB2DETAILDEADLOCK) 0      0.072142      0.052436    0.000092     0.000063
4129      4129           15900799        db2glock (SAMPLE) 0                 0.013239      0.000741    0.000064     0.000001
2         2              11739383        db2alarm 0                          0.036904      0.028367    0.000009     0.000009
4386      4386           13361367        db2dlock (SAMPLE) 0                 0.015653      0.001281    0.000014     0.000003
1029      1029           15040579        db2fcms 0                           0.041929      0.016598    0.000010     0.000004
5414      5414           14471309        db2pfchr (SAMPLE) 0                 0.000093      0.000002    0.000000     0.000000
258       258            13656311        db2sysc 0                           8.369967      0.263539    0.000000     0.000000
5157      5157           7934145         db2pfchr (SAMPLE) 0                 0.027598      0.000177    0.000000     0.000000
1543      1543           2670647         db2fcmr 0                           0.004191      0.000079    0.000000     0.000000
1286      1286           8417339         db2extev 0                          0.000312      0.000043    0.000000     0.000000
2314      2314           14360813        db2licc 0                           0.000371      0.000051    0.000000     0.000000
5928      5928           3137537         db2taskd (SAMPLE) 0                 0.004903      0.000572    0.000000     0.000000
3872      3872           2310357         db2lfr (SAMPLE) 0                   0.000126      0.000007    0.000000     0.000000
4643      4643           11694287        db2pclnr (SAMPLE) 0                 0.000094      0.000002    0.000000     0.000000
1800      1800           5800175         db2extev 0                          0.001212      0.002137    0.000000     0.000000
772       772            7925817         db2thcln 0                          0.000429      0.000072    0.000000     0.000000
2057      2057           6868993         db2pdbc 0                           0.002423      0.001603    0.000000     0.000000
2828      2828           10866809        db2resync 0                         0.016764      0.003098    0.000000     0.000000

상위 프로세서 시간 소비자에 해당하는 EDU 관련 정보만 제공하고 리턴되는 출력의 양을 줄이려면 top 매개변수 옵션을 추가로 포함할 수 있습니다. 다음 예에서는 5초 간격에 따라 상위 5대 EDU만 리턴합니다. 스택 정보도 리턴되며 DUMPDIR(기본적으로 diagpath로 설정됨)에 지정된 디렉토리 경로에 별도로 저장되어 있음을 확인할 수 있습니다.

$ db2pd -edus interval=5 top=5 stacks
Database Partition 0 -- Active -- Up 0 days 00:54:00 -- Date 06/04/2010 03:35:30
List of all EDUs for database partition 0
db2sysc PID: 1249522
db2wdog PID: 2068678
EDU ID    TID            Kernel TID     EDU Name                USR          SYS         USR DELTA    SYS DELTA
===============================================================================================================
3358      3358           2347127        db2loggr (SAMPLE) 0     0.154906     0.189223    0.001087     0.001363
3615      3615           2887875        db2loggw (SAMPLE) 0     0.962744     0.419617    0.001779     0.000481
515       515            13820091       db2aiothr 0             0.408039     0.314045    0.000658     0.000543
258       258            13656311       db2sysc 0               8.371388     0.264812    0.000653     0.000474
6700      6700           11542589       db2agent (SAMPLE) 0     54.814420    0.783323    0.000455     0.000310
$ ls -ltr
total 552
drwxrwxr-t    2 vbmithun build         256 05-31 09:59 events/
drwxrwxr-t    2 vbmithun build         256 06-04 03:17 stmmlog/
-rw-r--r--    1 vbmithun build       46413 06-04 03:35 1249522.3358.000.stack.txt
-rw-r--r--    1 vbmithun build       22819 06-04 03:35 1249522.3615.000.stack.txt
-rw-r--r--    1 vbmithun build       20387 06-04 03:35 1249522.515.000.stack.txt
-rw-r--r--    1 vbmithun build       50426 06-04 03:35 1249522.258.000.stack.txt
-rw-r--r--    1 vbmithun build      314596 06-04 03:35 1249522.6700.000.stack.txt
-rw-r--r--    1 vbmithun build       94913 06-04 03:35 1249522.000.processObj.txt

예 16: 에이전트 이벤트 메트릭 표시

db2pd 명령이 에이전트의 이벤트 메트릭 리턴을 지원합니다. 특정한 기간 동안 에이전트가 상태를 변경했는지 여부를 판별해야 하는 경우, event 옵션을 -agents 매개변수와 함께 사용하십시오. 리턴된 AGENT_STATE_LAST_UPDATE_TIME(틱 값) 컬럼에서는 에이전트에서 처리되는 이벤트가 변경된 마지막 시간을 보여줍니다. AGENT_STATE_LAST_UPDATE_TIME(틱 값)에 대해 이전에 가져온 값을 통해, 에이전트가 새 태스크로 이동했는지 여부나 확장된 기간 동안 동일한 태스크를 계속해서 처리하는지 여부를 판별할 수 있습니다.

db2pd –agents event
Database Partition 0 -- Active -- Up 0 days 03:18:52 -- Date 06/27/2011 11:47:10
Agents:
Current agents:      12
Idle agents:         0
Active coord agents: 10
Active agents total: 10
Pooled coord agents: 2
Pooled agents total: 2
AGENT_STATE_LAST_UPDATE_TIME(Tick Value)         EVENT_STATE  EVENT_TYPE  EVENT_OBJECT  EVENT_OBJECT_NAME 

2011-06-27-14.44.38.859785(5622972377924968075) IDLE WAIT REQUEST n/a 


http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.admin.trb.doc/doc/c0054595.html

728x90
728x90


Abstract

For IBM® Tivoli Storage Manager and DB2® to install and perform properly on HP-UX, Solaris, and Linux systems, you must update the kernel configuration parameters. If you do not update these parameters, the installation of DB2 and Tivoli Storage Manager might fail. If these values are not set and the installation is successful, operational issues might still be encountered when using the server.

Content

Using the db2osconf utility on HP-UX and Solaris systems

For HP-UX and Solaris systems, you can run the db2osconf utility to get recommended changes based on the size of your system. The db2osconf utility checks the current kernel configuration parameter settings, and suggests any updates that should be made. The db2osconf utility does not change the kernel parameters, but only suggests updates to help improve performance. 

The suggested updates provided by the db2osconf utility are the minimum settings required to run DB2 on your system. To run both Tivoli Storage Manager and DB2, additional changes are required in addition to the suggestions made by the db2osconf utility. 

db2osconf 유틸리티는 DB2가 실행하기 위한 설정해야할 커널 파라미터의 최소 설정값을 제안해준다. 커널 파라미터 값을 변경하지는 않는다. HP-UX나 Solaris에서는 커널 파라미터를 수정할 때 참조한다.

The recommended values are for one Tivoli Storage Manager instance-one server for DB2 Version 9.7, Fix Pack 2 (or later). 

Even though it is possible to recommend kernel parameters based on a particular DB2 database workload, this level of accuracy is not beneficial. If the kernel parameter values are too close to what are actually needed and the workload changes in the future, the DB2 database manager might encounter a problem due to a lack of interprocess communication (IPC) resources. A lack of IPC resources can lead to an unplanned outage for the DB2 database manager and a reboot would be necessary in order to increase kernel parameters. By setting the kernel parameters reasonably high, it should reduce or eliminate the need to change them in the future. The amount of memory consumed by the kernel parameter recommendations is almost trivial compared to the size of the system.

Additional details about the db2osconf utility are available at:
IBM DB2 Database for Linux, UNIX, and Windows Information Center

For Solaris 10 systems, you should use PROJMOD commands to update the kernel parameters. For Solaris 9 systems, you should edit the /etc/system file to update kernel parameters.

The DBMEMPERCENT server option

For best results, deploy one instance - one Tivoli Storage Manager server on one workstation and use the default setting for DBMEMPERCENT (AUTO). With this configuration, the DBMEMPERCENT should not need to be adjusted. 
For more details about using DBMEMPERCENT with Tivoli Storage Manager V6, see
http://www.ibm.com/support/docview.wss?uid=swg21444747

Modifying kernel parameters on Linux systems

To update the kernel parameters on Red Hat® and SUSE Linux®, you can run the ipcs -lcommand to list the parameter values and then analyze the output to determine whether any changes are required for your system.

Additional details are available at: IBM DB2 Database for Linux, UNIX, and Windows Information Center

Modifying kernel parameters on HP-UX systems
You must have root authority to modify kernel parameters.

To modify kernel parameters:
1. Enter the sam command to start the System Administration Manager (SAM) program.
2. Double-click the Kernel Configuration icon.
3. Double-click the Configurable Parameters icon.
4. Double-click the parameter that you want to change and type the new value in the Formula/Value field.
5. Click OK.
6. Repeat these steps for all of the kernel configuration parameters that you want to change.
7. When you are finished setting all of the kernel configuration parameters, select Action --> Process New Kernel from the action menu bar.

Important: The HP-UX operating system automatically restarts after you change the values for the kernel configuration parameters. 

As of November 30, 2011, use the information in the following links to determine the minimum values that you should set to run Tivoli Storage Manager and DB2 together:

HP-UX recommended parameter values
http://publib.boulder.ibm.com/infocenter/tsminfo/v6r3/index.jsp?topic=%2Fcom.ibm.itsm.srv.install.doc%2Ft_srv_krnlparms_hp.html

Oracle Solaris recommended parameter values
http://publib.boulder.ibm.com/infocenter/tsminfo/v6r3/index.jsp?topic=%2Fcom.ibm.itsm.srv.install.doc%2Ft_srv_krnlparms_sol.html

Linux recommended parameter values
http://publib.boulder.ibm.com/infocenter/tsminfo/v6r3/index.jsp?topic=%2Fcom.ibm.itsm.srv.install.doc%2Ft_srv_krnlparms_lnx.html


http://www-01.ibm.com/support/docview.wss?uid=swg27015156

728x90
728x90


Question

How can I avoid my users connecting to my databases, when I am running db2dart on an offline databases?

Answer

Several options are available to stop users from connecting to the database when you run db2dart:

Only one of these options should be used. 

  1. The most common simple way is doing a port change. 

  2. Revoke connect privilege either for the group/user's is another option. 

    For Example :  

        REVOKE CONNECT on DATABASE FROM PUBLIC

    Review the related URL below for examples on how to REVOKE database authorities. 

    Note : Revoking the CONNECT authority from a user does not affect any privileges that were granted to that user on objects in the database. If the user is subsequently granted the CONNECT authority again, all previously held privileges are still valid, assuming they were not explicitly revoked.

    The CONNECT authority cannot be revoked from an authorization-name holding DBADM authority without also revoking the DBADM authority (SQLSTATE 42504).

  3. Unset DB2COMM registry variable (which is set to TCPIP), by using the command:  

        db2 set DB2COMM=
        db2stop
        db2start
     

    Review the related URL below for examples on how to set the DB2COMM variable.

    Note: This option blocks users from connecting to the instance's databases remotely. You must also ensure that there are no other local connections. This will make all databases on the instance to become inaccessible. 

  4. Quiesce the database. A user with SYSADM authority must connect to the database and issue the following commands:
     
        CONNECT TO database-alias
        QUIESCE DATABASE IMMEDIATE FORCE CONNECTIONS;


http://www-01.ibm.com/support/docview.wss?uid=swg21589216

728x90
728x90

There is no installation program for the stand alone IBM Data Server Driver for ODBC and CLI. You must install the driver manually:

  1. Copy the compressed file that contains the driver onto the target machine from the internet or a DB2 Version 9 installation CD.
  2. Uncompress that file into your chosen install directory on the target machine.
  3. Optional: remove the compressed file.

If you are installing the IBM Data Server Driver for ODBC and CLI under the following conditions:
the steps you would follow are:
  1. Create the directory $HOME/db2_cli_odbc_driver, where you will install the driver.
  2. Locate the compressed file ibm_data_server_driver_for_odbc_cli.tar.Z on the install CD.
  3. Copy the tar file ibm_data_server_driver_for_odbc_cli.tar.Z to the install directory, $HOME/db2cli_odbc_driver.
  4. Uncompress ibm_data_server_driver_for_odbc_cli.tar.Z:
  1. Delete ibm_data_server_driver_for_odbc_cli.tar.Z.
  2. Ensure the following if you installed the driver on a NFS file system:
  3. On UNIX® or Linux® platforms the db2dump and the db2 directory need to be writable. Alternatively, the path you have referenced in the diagpath parameter must be writable.
  4. If host or i5/OS® data servers are being accessed directly ensure the license directory is writable.

If you are installing the IBM Data Server Driver for ODBC and CLI on Windows Platform, then you could copy the compressed folder under C:\Program Files\IBM and uncompress it. If you want to register the newly installed driver into the OBCD Administrator tool, then run the exe db2oreg1.exe located under the bin directory of the uncompressed driver(e.g: <uncompressed driver folder>/bin/db2oreg1.exe) from the command prompt as:

cd <uncompressed driver folder>/bin
db2oreg1 -i

After the above command is run to complete, you could see the driver registered in the ODBC Data source Administrator's Driver panel.

If you are installing 32-bit ODBC Driver on 64-bit Windows Operating System then you might hit the error "Data source name not found and no default driver specified".
Please follow the guidelines from the below link to resolve the issue:
Pointing to 32 bit ODBC driver on 64 bit Microsoft system

You could also find the resolution in the Microsoft Technote:
http://support.microsoft.com/kb/942976



728x90
728x90

This topic explains how to set up client access to DB2® databases for ODBC applications in Linux and UNIX operating systems. If your application is a CLI application, you are only required to perform the task in the Before you begin section to set up your environment.

Before you begin

Before setting up the ODBC environment, ensure you have set up the CLI environment.

About this task

For ODBC applications on UNIX that need to access a DB2 database, follow the steps described below.

Procedure

  1. Ensure that an ODBC driver manager is installed and that each user that will use ODBC has access to it. DB2 does not install an ODBC driver manager, so you must use the ODBC driver manager that was supplied with your ODBC client application or ODBC SDK in order to access DB2 data using that application.
  2. Set up .odbc.ini, the end-user's data source configuration. Each user ID has a separate copy of this file in their home directory. Note that the file starts with a dot. Although necessary files are usually updated automatically by the tools on most platforms, users of ODBC on UNIX platforms will have to edit them manually.

    Using an ASCII editor, update the file to reflect the appropriate data source configuration information. To register a DB2 database as an ODBC data source there must be one stanza (section) for each DB2 database.

    The .odbc.ini file must contain the following lines (examples refer to configuration of the SAMPLE database data source):
    • in the [ODBC Data Source] stanza:
         SAMPLE=IBM DB2 ODBC DRIVER
      which indicates that there is a data source called SAMPLE that uses the IBM® DB2 ODBC DRIVER;
    • in the [SAMPLE] stanza:
      on AIX®, for example,
         [SAMPLE]
         Driver=/u/thisuser/sqllib/lib/libdb2.a
         Description=Sample DB2 ODBC Database
      on the Solaris operating system, for example,
         [SAMPLE]
         Driver=/u/thisuser/sqllib/lib/libdb2.so
         Description=Sample DB2 ODBC Database

      which indicates that the SAMPLE database is part of the DB2 instance located in the directory/u/thisuser.

      With the introduction of the 64-bit development environment, there have been a number of inconsistencies among vendors regarding the interpretation of the sizes of certain parameters. For example, the 64-bit Microsoft ODBC Driver Manager treats SQLHANDLE and SQLLEN as both 64-bits in length, whereas Data Direct Connect and open source ODBC driver managers treat SQLHANDLE as 64-bit, but SQLLEN as 32-bit. The developer must therefore pay careful attention to which version of the DB2 driver is required. Specify the appropriate DB2 driver in the data source stanza, according to the following information:
      Type of applicationDB2 driver to specify
      32-bit CLIlibdb2.*
      32-bit ODBC Driver Managerlibdb2.*
      64-bit CLIlibdb2.*
      64-bit ODBC Driver Managerlibdb2o.* (db2o.o for AIX)
      Note: The file extension of the DB2 driver to specify depends on the operating system. The extensions are as follows:
      • .a - AIX
      • .so - Linux, Solaris, HP-IPF
      • .sl - HP-PA
  3. Ensure that the application execution environment has reference to the ODBC driver manager by including the corresponding shared library in the environment variable for the library path. The following table indicates the library name by operating system
    Operating systemEnvironment variableLibrary name
    AIXLIBPATHlibodbc.a
    HP-UX, Linux, and SolarisLD_LIBRARY_PATHlibodbc.so
  4. Enable a system-wide .odbc.ini file to be used by setting the ODBCINI environment variable to the fully qualified pathname of the .ini file. Some ODBC driver managers support this feature which allows for centralized control. The following examples show how to set ODBCINI:
    in the C shell,
       setenv ODBCINI /opt/odbc/system_odbc.ini
    in the Bourne or Korn shell,
       ODBCINI=/opt/odbc/system_odbc.ini;export ODBCINI
  5. Once the .odbc.ini file is set up, you can run your ODBC application and access DB2 databases. Refer to the documentation that comes with your ODBC application for additional help and information.

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.cli.doc/doc/t0006349.html
http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.cli.doc/doc/t0010406.html

http://www.unixodbc.org/doc/db2.html

728x90
728x90

To run ODBC applications on Linux or UNIX operating systems, you must configure the unixODBC Driver Manager.

Procedure


To set up the unixODBC Driver Manager for use with CLI and ODBC applications:

  1. Download the latest unixODBC source code from http://www.unixodbc.org.
  2. Untar the source files. For example:
    gzip -d unixODBC-2.2.11.tar.gz
    tar xf unixODBC-2.2.11.tar
  3. For AIX® only: Configure the C compiler to be thread-enabled:
    export CC=xlc_r
    export CCC=xlC_r
  4. To compile a 64-bit version of the driver manager using the xlc_r compilers, set the environment variablesOBJECT_MODE and CFLAGS:
    export OBJECT_MODE=64
    export CFLAGS=-q64 -DBUILD_REAL_64_BIT_MODE
  5. Install the driver manager in either your home directory or the default /usr/local prefix:
    • (Home directory) Issue the following command in the directory where you untarred the source files:
      ./configure --prefix=$HOME -DBUILD_REAL_64_BIT_MODE --enable-gui=no 
                                         --enable-drivers=no
    • (/usr/local as root) Issue the following command:
      ./configure --enable-gui=no --enable-drivers=no
      (prefix 옵션을 생략하면 /usr/local 디렉토리를 사용한다)
  6. Optional: Examine all configuration options by issuing the following command:
    ./configure --help
  7. Build and install the driver manager:
    make
    make install
    Libraries will be copied to the [prefix]/lib directory, and executables will be copied to the [prefix]/bindirectory.
  8. For AIX only: Extract the shared library from the ODBC driver for DB2® to yield shr.o on 32-bit operating systems and shr_64.o on 64-bit operating systems. To avoid confusion, rename the files db2.o and db2_64.o, respectively. These steps are necessary on AIX because the unixODBC Driver Manager loads the driver dynamically.
    • On 32-bit operating systems, issue the following commands:
      cd INSTHOME/sqllib/lib
      ar -x libdb2.a
      mv shr.o db2.o
      where INSTHOME is the home directory of the instance owner.
    • On 64-bit operating systems, issue the following commands:
      cd INSTHOME/sqllib/lib
      ar -x -X 64 libdb2.a
      mv shr_64.o db2_64.o
      where INSTHOME is the home directory of the instance owner.
    Ensure that your INI file references the correct library.
  9. Optional: For AIX only: Extract libodbc.alibodbcinst.a, and libodbccr.a if you will be dynamically loading the driver manager: (명령을 수행하기 전에 OBJECT_MODE 환경변수가 설정되어 있는지 확인한다)
    ar -x libodbc.a
    ar -x libodbcinst.a
    ar -x libodbccr.a 
    This produces libodbc.so.1libodbcinst.so.1, and libodbccr.so.1 respectively in the [prefix]/lib/so directory. (파일확장자는 unixODBC 버전에 따라 달라질 수 있다)
  10. Build the application and ensure it is linked to the unixODBC Driver Manager by including the -L[prefix]/lib -lodbc option in the compile and link command.
  11. Specify the paths for at least the user INI file (odbc.ini) or the system INI file (odbcinst.ini), and set the ODBCHOME environment variable to the directory where the system INI file was created.
    Important: Provide absolute paths when specifying the paths of the user and system INI files. Do not use relative paths or environment variables.
    Note: If compiling 64-bit applications for the ODBC Driver, use the -DODBC64 option to enable the 64-bit definitions in the driver manager.

http://publib.boulder.ibm.com/infocenter/db2luw/v9r7/topic/com.ibm.db2.luw.apdv.cli.doc/doc/t0010406.html


728x90
728x90

DB2에서는 온라인 백업 수행중 테이블 TRUNCATE가 수행되지 않는다. 엄밀히 말하자면 기본적으로 TRUNCATE TABLE 기본 옵션이 DROP STORAGE를 사용하기 때문인데 카탈로그 테이블 경함으로 인한 것으로 보인다.

부득이 백업 수행중에 TRUNCATE를 해야한다면 REUSE STORAGE 옵션을 사용한다.

이렇게 했을 경우 테이블에 할당된 공간은 해제되지 않는다. (기존의 공간을 계속 차지한 상태)


 description

  • ADMIN_MOVE_TABLE issues TRUNCATE TABLE e.g. after having created
    a row compression dictionary from a table sample.
    The TRUNCATE  TABLE statement is issued without the "REUSE
    STORAGE"
    option and therefore defaults to "DROP STORAGE".
    TRUNCATE TABLE ... DROP STORAGE is not compatbile with online
    backup.
    Either TRUNCATE waits or the online backup has to wait ...
    We need to issue TRUNCATE TABLE with REUSE STORAGE clause.


http://www-01.ibm.com/support/docview.wss?uid=swg1IC73834

728x90

+ Recent posts