安裝後的步驟

新增 DB Instance
groupadd db2adm
useradd -g db2adm -c "DB2 Instance User" -d /devinst devinst

cd /opt/ibm/db2/V9.7/instance/
./db2icrt -s ese -u devinst devinst 

# for Client only
./db2icrt -s client <app-username>

移除 Instance

cd /opt/ibm/db2/V11.1/instance

# List current instances
./db2ilist

# Remove the instance
# NOTE: The directory sqllib/ is supposed to be deleted after removing instance.
# If it isn't for some reason you have to manually remove the directory sqllib/ in the home directory.
./db2idrop <instance-name-id>
匯入 DB2 授權檔

注意事項:

TIP

_c 以 CPU 計價
_t 試用版
_u 以 USER 數計價

解開檔案

su - db2inst
unzip  DB2_AESE_CPU_QS_Activation_97.zip
cd  aese_c/

匯入前的授權資訊

db2licm -l

Product name: "DB2 Advanced Enterprise Server Edition"
License type: "License not registered"
Expiry date: "License not registered"
Product identifier: "db2aese"
Version information: "9.7"

db2level

DB21085I This instance or install (instance name, where applicable: "mydev")
uses "64" bits and DB2 code release "SQL0907B" with level identifier
"080C0107".
Informational tokens are "DB2 v9.7.0.11", "s150922", "IP23944", and Fix Pack
"11".
Product is installed at "/opt/ibm/db2/V9.7".

開始匯入

db2licm -a db2/license/db2aese_c.lic

LIC1402I License added successfully.

LIC1426I This product is now licensed for use as outlined in your License Agreement. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V9.7/license/en_US.iso88591"

匯入後的授權資訊

db2licm -l

Product name: "DB2 Advanced Enterprise Server Edition"
License type: "CPU Option"
Expiry date: "Permanent"
Product identifier: "db2aese"
Version information: "9.7"
Enforcement policy: "Soft Stop"

TIPs:

若要移除授權可以執行

db2licm -r [Product identifier]

DB2 Instance 啟動
#> su - mydev
$> db2 "update dbm cfg using svcename DB2_mydev"
$> db2set DB2COMM=TCPIP
$> db2set DB2CODEPAGE=950
$> db2set DB2AUTOSTART=NO
$> db2start
$> ps -ef | grep db2sysc

TIPs:

如果要變更預設的 Port,可以修改 /etc/services。


DBM cfg
$> db2 "update dbm cfg using HEALTH_MON OFF"
$> db2 "update dbm cfg using DIAGSIZE 50"
DB cfg
## Turn some AUTO* options off
$> db2 "update db cfg for <db-name> using AUTO_MAINT off"
$> db2 "update db cfg for <db-name> using AUTO_TBL_MAINT off"
$> db2 "update db cfg for <db-name> using AUTO_RUNSTATS off"
$> db2 "update db cfg for <db-name> using AUTO_STMT_STATS off"

## Set the Active 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" 

## If enabled HADR
$> db2 "update db cfg for <db-name> using BLOCKNONLOGGED yes"
重建一個新的 db2dump 目錄

為了要將 db2dump 目錄獨立出來,在新增目錄時必須加上一些特殊權限

$> mkdir db2dump
$> chmod 0777 db2dump
$> chmod g+s db2dump
$> chmod o+t db2dump
$> ls -l db2dump
drwxrwsrwt 3 istdw db2adm 4096 Aug 11 16:40 db2dump/



Revision #7
Created 15 June 2020 03:26:27 by Admin
Updated 29 November 2022 11:11:04 by Admin