第1章 db2のアーキテクチャ - ibm - united states (32bit/64bit) o windows (32bit/64bit) db2...

of 57 /57
第1章 DB2のアーキテクチャ 本書に含まれている情報は、正式なIBMのテストを受けていません。また、明記にしろ、暗黙的にしろ、なんらの保証もなしに配布されるものです。 この情報の使用またはこれらの技術の実施は、いずれも、使用先の責任において行われるべきものであり、それらを評価し、実際に使用する環境に統合する 使用先の判断に依存しています。それぞれの項目は、ある特定の状態において正確であることがIBMによって調べられていますが、他のところで同じまたは同 様の結果が得られる保証はありません。これらの技術を自身の環境に適用することを試みる使用先は、自己の責任において行う必要があります。 © Copyright IBM Japan Co., Ltd. 2011

Author: dangnga

Post on 25-Mar-2018

241 views

Category:

Documents


11 download

Embed Size (px)

TRANSCRIPT

  • DB2IBM

    IBM

    Copyright IBM Japan Co., Ltd. 2011

  • 2011 IBM Corporation22

    DB2

    OracleDB2

    DB2Oracle

    DB2

  • 2011 IBM Corporation3

    DB2 DB2

  • 2011 IBM Corporation44

    DB2

    DB2 Personal EditionLinux (32bit/64bit)Windows (32bit/64bit)

    DB2 Workgroup Server EditionLinux (32bit/64bit)Linux Power (64bit)Windows (32bit/64bit)AIX (64bit)Solaris (64bit)HP-UX (64bit)

    DB2 Enterprise Server EditionLinux (64bit)Linux Power (64bit)Linux zSeries (64bit)Windows (32bit/64bit)AIX (64bit)HP-UX (64bit)Solaris (64bit)

    DB2 Express EditionLinux (32bit/64bit)Linux Power (64bit)Windows (32bit/64bit)Solaris (x86-64)

    DB2 Enterprise 9

    DB2 Workgroup 9

    DB2 Express 9

    DB2 Personal 9

    Database Enterprise Developer EditionAll Servers and clients supported by DB2

    For Developer

    DB2 9.7 DB2 Data Server Version

    20095

    20096

    DB2 Advanced Enterprise Server Edition

  • 2011 IBM Corporation55

    DB2 9.7

    IBM DB2 Enterprise Server Edition 9.7 (ESE) DB2 Enterprise 9.7

    PL/SQLpureXMLHADRMQT

    MDC

    IBM DB2 Workgroup Server Edition 9.7 (WSE) DB2 Workgroup 9.7

    16CPU

    64GB

    PL/SQLpureXML, HADRpureScale(*1)

    (*1) 4

  • 2011 IBM Corporation66

    DB2 9.7

    IBM DB2 Advanced Enterprise Server Edition 9.7 (AESE) DB2 Enterprise 9.7

    DB2 Enterprise Server Edition

    Optim Performance Manager QIBM MQ

    1 DB

    2

    1DB212DB2 Oracle Database DB2

  • 2011 IBM Corporation77

    DB2 9.7

    IBM DB2 Express Edition 9.7 DB2 Express 9.7SMBDB2

    200 PVU(*1)

    4GB

    pureXML

    IBM DB2 Express-C

    2CPU

    2 GB

    pureXML

    (*1) PVU:

    Value Unit

  • 2011 IBM Corporation88

    DB2 9.7

    IBM Data Server Client DB/

    IBM Data Server Runtime Client JDBC, ADOODBC, DB2 CLI, .NET, ADO.NET, OLE DB, PHP ,Ruby

    GUIDB2 CLP

    IBM Data Server Driver for ODBC, CLI, and .NET DB2 CLI APIODBC API.NET API

    Windows

    IBM Data Server Driver for JDBC and SQLJ Java

    JDBC 3

    JDBC 4 SQLJ

  • 2011 IBM Corporation99

    DB2 V9.7 DB2 V9.7 Features Adv.

    ESEESE WSE Express

    DB2 High Availability Feature (HAF) ()

    PVU

    HADR,

    TSA,

    DB2 pureScale Feature *

    PVU

    DB2 Performance Optimization Feature (POF)

    ()

    PVU

    DB2 ,

    Optim Performance Manager,

    Query Patroller

    DB2 Storage Optimization Feature (SOF) (

    PVU

    DB2 Advanced Access Control Feature (AACF) (

    PVU

    (LBAC)

    DB2 Geodetic Data Management Feature

    PVU

    Homogeneous Replication

    Feature ( PVU DB2Q

    Feature

    *: DB24

  • 2011 IBM Corporation10

    OracleDB2OracleDB2

  • 2011 IBM Corporation1111

    OracleDB2 (1)

    Oracle DB2 Comment

    DB2

    DBM

    DB21DB

    Oracle1 1DB

    DB2:1DB

    Oracle: DB

    DB2: DBDB

    /

    Oracle:

  • 2011 IBM Corporation1212

    OracleDB2 (2)Oracle DB2 Comment

    DMS

    Redo

    Redo

    PL/SQL SQL/PL SQL

    I/O

    SGA

    SQL

    SYSTEM

  • 2011 IBM Corporation13

    DB2OracleDB2Oracle

  • 2011 IBM Corporation1414

    DB2Oracle

  • 2011 IBM Corporation1515

    Oracle

    Oracle : 3

    JavaPool

    DatabaseBufferCache

    DataDictionary

    Cache

    OracleArchitectureOracleArchitecture

    ArchiveLogFiles

    DataFiles

    RedoLog

    Files

    Oracle Oracle DatabaseDatabase

    RECO

    Oracle Oracle ProcessesProcesses

    LibraryCache

    Init.Ora

    RedoLog

    Buffer

    SGASGAPPGGAA

    User Processes

    User Processes

    User Processes

    User Processes

    PMON

    ControlFiles

    ARCnCKPTDBWn LGWRSMON

    Shared Pool

    LargePool

    StreamsPool

    InstanceInstance

  • 2011 IBM Corporation1616

    DB2

    DB2:/ DB2

    DBMS Oracle

    COMMIT

    BFP

  • 2011 IBM Corporation1717

    Oracle

    SGA

    PGA OracleSGA

    PGA

    SGA

    SGAREDO

    PGA

    SGA

    Shared PoolLibrary Cache

    Data Dictcache

    DataBufferCache

    RedoLog

    Buffer

    PGA

    Server Process

    Instance

    PGAPGA

  • 2011 IBM Corporation1818

    DB2

    DB2 3

    :

    Database_ memory

    Appl_memory

    Database_A

    Database_ memory

    Appl_memory

    Database_B

    DBMS Memory

    Instance_memory

    Agent Private Memory

  • 2011 IBM Corporation1919

    Oracle

    (DBWR) (LGWR)

    (SMON)

    (PMON)

    (CKPT) (RECO)

    (ARCn)

    (Dnnn)

    Oracle

  • 2011 IBM Corporation2020

    DB2

    EDU

    db2sysc

    EDU

    DB2

    db2pfchr

    db2pclnr

    db2logmgr

    EDU

    db2agent db2fmp

  • 2011 IBM Corporation2121

    Instance Database

    Oracle Oracle

    Oracle OFA

    Parameter file

    Control fileDatafiles Redo log files

    Password file

    Alert and trace log file

  • 2011 IBM Corporation2222

    DB2

    DB2 DB2

    :

    (db2dump)

    (function) :

    (SQL0000n)

    (SQLOGDIR)

    (Nodennnn/DBNAME)

    db2dump

    ()

    Drive/Directory

    DB2 instance name

    Node0000

    SQL00001

    DBNAME

    SQLOGDIR

    C0000000.CATT0000000

    T0000001 C0000000.CAT

    T0000002 C0000000.LRG

    SQLDBCONF

    The partition number of the database, 0 for a non-partitioned database

    The database id starts at 1 and increases for all subsequent database

    The database configuration file

    The directory for default log files

    The DMS container for catalog tablespace

    The SMS container for default system temporary tablespaceThe DMS container for default user tablespace

    Drive/Directory

    sqllib

    Error log file

    All the external stored procedures and executable programs are stored in here

    db2dump

    function

    Instance directory

    Database directoryetc...

  • 2011 IBM Corporation2323

    Oracle: User_xxx

    ALL_xxx

    DBA_xxx

    DB2: Catalog SYSCAT

    DB SYSSTAT

    DB2 9.7 OracleDB2

  • 2011 IBM Corporation2424

    Oracle

    Oracle Oracle

    USER ken PASSWORD [email protected]?s

    Authentication OK/NG

    I'm kenOracle

    Database

    ....

    ............

  • 2011 IBM Corporation2525

    DB2 DB2OS

    OSID

    OS

    SYSADM

    SYSCTRL

    SYSMAINT

    DBADM

    USER ken PASSWORD [email protected]?s

    ACCESS

    OK

    DB2

    DB2

    Authentication OK/NG

    I'm ken

    Can Iaccess? NO

    ....DB2Data

    Server

    ....

    ....

  • 2011 IBM Corporation26

    DB2DB2

  • 2011 IBM Corporation2727

    DB2

    DB2

    IBM Optim Database Administrator

  • 2011 IBM Corporation28

    DB2 db2setupJava GUI

    setup.exe UNIX/Linuxdb2setup

    db2_installCUIUNIX/Linux telnetCUIDB2 ESE db2_install -b /opt/IBM/db2/V9.7_01 -p ESE -L JP

    -b /opt/IBM/db2/V9.7_01

    -p ESE DB2ESE -L JP

    db2_install db2setupdb2_install

    Infomix

  • 2011 IBM Corporation29

    GUI

    DB2 9.7 Windowshttp://www.ibm.com/developerworks/jp/data/library/db2/j_d-db2v97wininstall/

  • 2011 IBM Corporation30

    db2_install (1/2)> ls -l

    total 1563456

    -rw-r-----

    1 root system 800481280 Mar 06 15:12 DB2_ESE_V95_AIX.tar

    drwxr-xr-x 6 root system 4096 Mar 06 17:40 ese

    > cd ese

    > ls -l

    total 120

    drwxr-xr-x 6 daemon staff 4096 Oct 04 2007 db2

    -r-xr-xr-x 1 bin bin 4700 Oct 04 2007 db2_deinstall

    -r-xr-xr-x 1 bin bin 4570 Oct 04 2007 db2_install

    -r-xr-xr-x 1 bin bin 4560 Oct 04 2007 db2prereqcheck

    -r-xr-xr-x 1 bin bin 4552 Oct 04 2007 db2setup

    drwxr-xr-x 16 bin bin 4096 Oct 04 2007 doc

    -r-xr-xr-x 1 bin bin 4588 Oct 04 2007 installFixPack

    drwxr-xr-x 5 root system 256 Oct 04 2007 nlpack

    drwxr-xr-x 15 bin bin 4096 Oct 04 2007 readmefirst

    -r--r--r--

    1 bin bin 1503 Oct 04 2007 readmefirst.htm

    -r--r--r--

    1 bin bin 678 Oct 04 2007 readmefirst.txt

    > ./db2_install -b /opt/IBM/db2/V9.7_01 -p ESE -L JP

    DB2

    : 45

    : 1828

    #1

    :

    2

    #1

    "/tmp/db2_install.log.1241120"

    DB2

    /tmp

  • 2011 IBM Corporation31

    db2_install (2/2)

    > cd /opt/IBM/db2/V9.7_01/installdb2_deinstall db2chgpath db2ls_exec logsdb2_deinstall_exec db2ls db2un.rsp tsamp

    > ./db2ls

    UID

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

    /opt/IBM/db2/V9.7 9.7.0.0 0 Fri Mar 6 16:02:06 2009 JST 0

    > ./db2ls -q -b /opt/IBM/db2/V9.7_01

    : /opt/IBM/db2/V9.7_01

    ID

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

    BASE_CLIENT 9.7.0.0 0 Base client support

    JAVA_SUPPORT 9.7.0.0 0 Java support

    SQL_PROCEDURES 9.7.0.0 0 SQL procedures

    BASE_DB2_ENGINE 9.7.0.0 0 Base server support

    JDK 9.7.0.0 0 IBM Software Development Kit (SDK) for Java(TM)

    CONNECT_SUPPORT 9.7.0.0 0 Connect

    support

    COMMUNICATION_SUPPORT_TCPIP 9.7.0.0 0 Communication support -

    TCP/IP

    REPL_CLIENT 9.7.0.0 0 Replication tools

    DB2_DATA_SOURCE_SUPPORT 9.7.0.0 0 DB2 data source support

    -q -b

  • 2011 IBM Corporation3232

    DB2

    DB2

    DB2 copy 1OSDB2

    DB2

    (fix pack )

    DB2 11DB2

    1DB2

    DB2 DB2

    Operating SystemDB2 Copy A/opt/IBM/db2/V9.7_GA

    DB2 Copy B/opt/IBM/db2/V9.7_FP1

    db2inst1 db2inst2 db2inst2

    db2iupdt

  • 2011 IBM Corporation3333

    DB2

    root

    : db2icrt

    : db2ilist DB2

    : db2start : db2stop

    DB2

    db2_ps

    (Linux/UNIX only)

    : db2idrop : db2iupdt

    DB2 : db2iupgrade db2imigr

    DB2

    db2_ps

    db2icrt -u db2fenc1 db2inst1

  • 2011 IBM Corporation3434

    DB21DB

    DB2DB1db2sysc

    EDUdb2pd -edus

    DB1 DB

    on

    DB2

    db2 create database DB1 on /db2/db1

    db2 drop database DB1

    db2inst1DB2DB1

    TablespaceB Tablespace1 Tablespace2TablespaceA

  • 2011 IBM Corporation3535

    DB2

    DB2

    (g)

    DB2

    (i)

    DBM CFG

    DB CFG

    (g)

    (i)

    DB

    DB

    (i)

    (g)

  • 2011 IBM Corporation3636

    DB2

    DB2

    Non-Automatic Storage

    Database X

    TableSpace A

    TableSpace B

    TableSpace C

    Automatic StorageDatabase Y

    TableSpace A

    TableSpace B

    TableSpace C

    Storage paths on file systems

  • 2011 IBM Corporation3737

    DB

    (///T000000n) DB

    DB

    DB2

    alter database add/drop automatic storage on ''

  • 2011 IBM Corporation3838

    (1)

    USERSPACE1 ()

    JOIN (1)

    DECLARE GLOBAL TEMPORARY TABLE

    () SYSCATSPACE

    DB2

    CREATE TABLESPACE TS1 PAGESIZE 16KMANAGED BY DATABASE USING

    ( FILE '/db2/ts1.dat' 1000M)

  • 2011 IBM Corporation3939

    System Managed Space (SMS)

    OS OS

    Database Managed Space (DMS)

    raw 2 DB2 DMS FILE

    DB2

  • 2011 IBM Corporation4040

    4KB / 8KB / 16KB / 32KB

    SMS DMS File

    Large object (CLOB/BLOB)I/O

    DB2

    (Large)*

    4KB 4005 500 8TB8KB 8101 1012 16TB16KB 16293 1012 32TB32KB 32677 1012 64TB

    *DMS

  • 2011 IBM Corporation4141

    : SMS

    16KBDMS

    DB2

    CREATE TABLESPACE TS1 MANAGED BY SYSTEMUSING ('d:TS1_CONT1', 'e:TS1_CONT1')

    CREATE TABLESPACE TS2 PAGESIZE 16KMANAGED BY DATABASEUSING ( FILE '/db2/cont1/ts1_1.dat 500MB, FILE '/db2/cont2/ts1_2.dat 500MB)BUFFERPOOL BP16K

    CREATE TABLESPACE TS3 MANAGED BY AUTOMATIC STORAGE

  • 2011 IBM Corporation4242

    DB2

    TCP/IPDB2 LISTEN

    DB2 DB2

    DB

    DB

    DBM

    /etc/services

    SVCENAMESSL_SVCENAME

    DB2COMM

  • 2011 IBM Corporation4343

    DB2

    DB2

    DB2COMM

    DB2COMM=TCPIPDB2COMM=SSL DB2

    DBM

    TCP/IPSVCENAMESSLSSL_SVCENAME

    /etc/services

    DB2LISTENDBIP IPLISTEN

    $ db2 get dbm cfg |grep SVCETCP/IP Service name (SVCENAME) = DB2_db2inst1SSL service name (SSL_SVCENAME) =

    cat /etc/services |grep -i db2DB2_db2inst1 50000/tcp

  • 2011 IBM Corporation4444

    DB2

    2

    DBIP DBDB

    DBIP3

    > db2 list node directory

    = HORIKEN

    =

    = LOCAL

    = TCPIP

    = horiken

    = 50000

    > db2 list db directory

    = LABDB

    = LABDB

    = HORIKEN

    String url = "jdbc:db2://horiken:50000/labdb"

  • 2011 IBM Corporation4545

    DB2 : IBM Optim Database Administrator DB2Informix IDSEclipse

    http://www-01.ibm.com/software/data/optim/

    http://www-01.ibm.com/software/data/optim/

  • 2011 IBM Corporation46

  • 2011 IBM Corporation4747

    DB2Oracle

    /

    Export/Import

    SQL

  • 2011 IBM Corporation4848

    startup

    shutdown

    shutdown immediate

    Startup restrict open

    db2start

    db2stop

    db2startdb2 quiesce instance immediate force connections

    db2stop force

    DB2 Oracle

  • 2011 IBM Corporation4949

    SQLXquery

    : on dbpath on

    Activate

    Deactivate

    db2sampl

    Create database

    on dbpath on

    pagesize

    activate db

    deactivate db

    Oracle

    DB2DB

  • 2011 IBM Corporation5050

    DB2 /backup

    rmanOracle rman

    /backup

    rman target / nocatalog

    configure channel device type disk format='/backup/full_db_%U'

    backup as backupset database plus archivelog

    backup db to /backup

    backup db online to /backup

  • 2011 IBM Corporation5151

    DB2

    /backup

    rmanOracle rman

    /backup ()

    restore db from /backup taken at

    rollforward database to end of logs and complete

    rman target / nocatalog

    configure channel device type disk format='/backup/full_db_%U'

    RMAN> restore database;RMAN> recover database;

    RMAN> alter database open;

  • 2011 IBM Corporation5252

    Export/Import DB2

    CSVSQL

    ( replace insert)

    Oracle Oracle CSV

    exp toolexportimport

    export to of del select * from

    import from of del [replace | insert] into

    exp "/@ file tables=()"

    imp "/@ file tables=()"

  • 2011 IBM Corporation5353

    (1)

    DB2 Oracle

    select * from v$parameter

    select * from v$sgaselect * from v$pgastat

    select * from v$session

    select * from dict

    select * from v$tablespace;

    select * from sysibmadm.dbcfgselect * from sysibmadm.dbmcfg

    select * from sysibmadm.SNAPAPPL_INFO

    select * from sysibmadm.SNAPDBM_MEMORY_POOLselect * from sysibmadm.SNAPDB_MEMORY_POOL"

    list tables

    select * from table(mon_get_tablespace('',-2))

  • 2011 IBM Corporation5454

    (2)

    show userselect current user from sysibm.sysdummy1

    select * from sysibmadm.admintabinfo

    admintabinfo view

    LOBXML

    LOAD,REORG,CLEANUP

    DB2 Oracle

    select * from dba_segments

  • 2011 IBM Corporation5555

    SQL (1)

    DB2

    Oracle

    DB2(9.5)

    Oracle DB2 9.7

    DB2(9.5)

    Oracle DB2 9.7

    DB2

    Oracle

    select sysdate from DUAL

    select * from v$parameter where rownum

  • 2011 IBM Corporation5656

    SQL (2)

    (4) DB2(9.5)

    Oracle DB2 9.7

    DB2

    Oracle

    DB2(9.5)

    Oracle DB2 9.7

    select add_months(sysdate, -4) + 1 from dual

    select systimestamp + INTERVAL '0 5:3:10' DAY TO SECOND from dual

    truncate table

    select current date - 4 months + 1 days from sysibm.sysdummy1

    select current timestamp + 5 HOURS - 3 MINUTES + 10 SECONDS from sysibm.sysdummy1

    import from /dev/null of del replace into

  • 2011 IBM Corporation5757

    Lets go Lab1!!

    DB2 3DB2 DB2 9.7 DB2 9.7 DB2 9.7 DB2 9.7 DB2 V9.7 10OracleDB2 (1)OracleDB2 (2) 13DB2Oracle Oracle DB2 Oracle DB2 Oracle DB2 Oracle DB2 Oracle 25 26DB2GUIdb2_install (1/2)db2_install (2/2)DB2 DB2 DB2 DB2 DB2 DB2 DB2 DB2 DB2 DB2 DB2 DB2 DB2 DB2 : IBM Optim Database Administrator 46DB2OracleExport/Import (1) (2)SQL (1)SQL (2) 57