Install DB2 v8.2 on CentOS 4/5/6

    版本為 17:23, 23 Nov 2024

    到這個版本。

    返回到 版本存檔.

    查閱目前版本

    (http://publib.boulder.ibm.com/infoce...w/v8/index.jsp)

    Linux OS 安裝

    OS 安裝選用的套件

    • X Window System
    • GNOME Desktop
    • Editors
    • Graphical Internet
    • Text-based Internet
    • Server Configuration Tools
    • Legacy Network Server
      • rusers
      • rwho
    • Development Tools
    • Compatibility Arch Development
    • Legacy Software Development
      • compat-boost-1331
    • Administration Tools
    • System Tools
    • Compatibility Arch Support

    必要得套件安裝

    • pdksh
    • nfs-utils

    安裝前的系統參數調整

    編輯 /etc/sysctl.conf

    fs.file-max = 8192
    kernel.shmmax = 1073741824
    kernel.shmall = 471859
    kernel.msgmni = 4096
    kernel.sem = 250 256000 32 2048
    vm.lower_zone_protection = 250
    

    TIPs:

    kernel.shmax :for x86, here is 268435456 byte(256MB); for 64bit, here is 1073741824 byte(1GB)
    kernel.shmall: physical memory(KB) * 90% / 4, 2048 * 1024 * 90% /4= 471859.2 , 請注意不可小於 Table 所需的 buffer pool的總值.

    kernel.shmall: Maximum total size of shared memory in pages (normally 4096 bytes)
    kernel.shmmax: Maximum size of shared memory segment in bytes

    官網教學:
    Modifying kernel parameters and user limits (Linux, AIX, HP-UX, Solaris)
    核心參數需求(Linux)

    套用設定

    #sysctl -p
    
    #ipcs -l
    
    ------ Shared Memory Limits --------
    max number of segments = 4096          //SHMMNI
    max seg size (kbytes) = 1048576        //SHMMAX
    max total shared memory (kbytes) = 1887436  //SHMALL
    min seg size (bytes) = 1
    
    ------ Semaphore Limits --------
    max number of arrays = 2048             //SEMMNI
    max semaphores per array = 250
    max semaphores system wide = 64000
    max ops per semop call = 32
    semaphore max value = 32767
    
    ------ Messages: Limits --------
    max queues system wide = 4096             //MSGMNI
    max size of message (bytes) = 8192
    default max size of queue (bytes) = 16384 //MSGMAX
    

    TIPs:

    如何檢查目前運行中系統的這些參數設定值:

    cat /proc/sys/kernel/shmall
    cat /proc/sys/kernel/shmax

    oom-kill 值修改為 0

    #echo 0 > /proc/sys/vm/oom-kill
    

    開始安裝 DB2 Server 主程式

    在 X Window 環境下安裝)

    #tar xzf DB2_V82_ESE_LNX_AMD64_NLV.tar.gz
    #cd ese
    #db2setup

    Install Products
    > Installation Type: Typical
    > Install DAS

    • username: db2as
    • group: db2asadm
    • Home: /home/db2as

    > Set up a DB2 Instance: Do not create a DB2 Instance
    > Set up the administration contact list

    • Local
    • Enable notification: 不要選

    NOTE:

    出現警告視窗:未指定 SMTP server

    選擇 OK 繼續下一步驟

    > Finish,開始安裝主程式

    TIPs:

    沒有 X Window 環境下安裝,可執行 ./db2_install,然後輸入 DB2.ESE

    安裝 DB2 FixPak 18

    #tar xf FP18_MI00295.tar
    #cd FP18_MI00295
    #mkdir db2fp18
    #tar xf FP18_MI00295.tar -C db2fp18/
    #cd db2fp18
    #./installFixPak -y
    

    重啟主機

    新增 Instance

    建立 帳號/群組

    #groupadd db2adm
    #useradd -g db2adm -c "DB2 Instance User" db2inst
    

    以下可忽略,系統在新增 Instance 時會自動編輯這個檔案。
    編輯 /etc/services

    # DB2_db2inst      60000/tcp DB2_db2inst_1    60001/tcp DB2_db2inst_2    60002/tcp DB2_db2inst_END  60003/tcp
    

    新增 DB2 Instance

    #cd /opt/IBM/db2/V8.1/instance/
    #./db2icrt -s ese -u db2inst -w 64 db2inst
    

    TIPs:

    64-bit 系統環境必須加上 -w 64,否則會是 32-bit 的 Instance

    未授權的訊息

    #su - db2inst
    #db2licm -l
    
    Product Name                            = "DB2 Enterprise Server Edition"
    Product Identifier                      = "DB2ESE"
    Version Information                     = "8.2"
    Expiry Date                             = "11/06/2013 (Try & Buy)"
    Registered Connect User Policy          = "Disabled"
    Number Of Entitled Connect Users        = "5"
    Enforcement Policy                      = "Soft Stop"
    Number of processors                    = "1"
    Number of licensed processors           = "1"
    Database partitioning feature           = "Entitled"
    Annotation                              = ""
    Other information
    

    軟體版本

    #su - db2inst
    #db2level
    
    DB21085I  Instance "db2inst" uses "32" bits and DB2 code release "SQL08029"
    with level identifier "030A0106".
    Informational tokens are "DB2 v8.1.3.160", "s090715", "MI00295", and FixPak
    "18".
    Product is installed at "/opt/IBM/db2/V8.1".
    註:顯示 "32" bits 表示該 instance 並非 64-bit。
    

    匯入授權檔

    #su - db2inst
    #db2licm -a db2ese.lic
    

    已授權的訊息

    # db2licm -l
    
    Product Name                            = "DB2 Enterprise Server Edition"
    Product Identifier                      = "DB2ESE"
    Version Information                     = "8.2"
    Expiry Date                             = "Permanent"
    Registered Connect User Policy          = "Disabled"
    Number Of Entitled Connect Users        = "5"
    Enforcement Policy                      = "Soft Stop"
    Number of processors                    = "1"
    Number of licensed processors           = "1"
    Database partitioning feature           = "Not entitled"
    Annotation                              = ""
    Other information                       = ""
    

    DB2 啟動及驗證

    # su - db2inst
    # db2 "update dbm cfg using svcename DB2_db2inst"
    # db2set DB2COMM=tcpip
    # db2set DB2CODEPAGE=950
    # db2set DB2AUTOSTART=NO
    # db2start
    # ps -ef | grep db2sysc
    

    TIPs:

    第一次啟動 DB2 必須加上 db2set 的一些參數

    如果有正常啟動,執行 netstat -lt 檢查,應該要出現  *:DB2_db2inst,如果沒有,在啟動 Instance 前先執行
    db2set DB2COMM=tcpip

    如果出現這錯誤,將 DB2COMM=tcpip 移除
    SQL5043N  Support for one or more communications protocols failed to start successfully. However, core database manager functionality started successfully.

    建立資料庫

    su - db2inst
    mkdir devmmdb/
    db2 "create db DEVMMDB on /home/db2inst/devmmdb using codeset big5 territory TW collate using identity"
    
    db2 list db directory
    db2 connect to devmmdb 
    

    重要的調整

    Transaction Log

    參數的預設值太小,這會影響到 DB 平時運作以及 import 的操作

    $> db2 "get db cfg"
    

    DB 參數名稱

     Log file size (4KB)                         (LOGFILSIZ) = 1000
     Number of primary log files                (LOGPRIMARY) = 3
     Number of secondary log files               (LOGSECOND) = 2
     Changed path to log files                  (NEWLOGPATH) =
     Path to log files                                       = /home/devmm/DEVMMDB/devmm/NODE0000/SQL00001/SQLOGDIR
     Block log on disk full                (BLK_LOG_DSK_FUL) = YES
    

    TIPs:

    1000 x 4KB x (3+2) = 20MB
    Making sure the filesystem of traction log('Path to log files') has sufficient available space.

    mkdir /home/devmm/DEVMMDB/log
    db2 "update db cfg for DEVMMDB using LOGFILSIZ 12800"
    db2 "update db cfg for DEVMMDB using LOGPRIMARY 10"
    db2 "update db cfg for DEVMMDB using LOGSECOND 10"
    db2 "update db cfg for DEVMMDB using NEWLOGPATH /home/devmm/DEVMMDB/log"
    db2 "update db cfg for DEVMMDB using BLK_LOG_DSK_FUL YES" 
    

    Sample:

    db2 "update db cfg for RMMDB using LOGFILSIZ 20480"
    db2 "update db cfg for RMMDB using LOGPRIMARY 20"
    db2 "update db cfg for RMMDB using LOGSECOND 25"
    db2 "update db cfg for RMMDB using NEWLOGPATH /istrmm/RMMDB/log"
    db2 "update db cfg for RMMDB using BLK_LOG_DSK_FUL YES"

    Powered by MindTouch Core