DB2安裝過程(CentOS) 安裝 ./install 創建實例: groupadd database useradd prod -g database useradd prodfenc -g database cd /opt/ibm/db2/V9.7/instance ./db2icrt -a server -u prodfenc prod 配置實例參數: cd ~prod vi .bashrc #在最後加入 ./sqllib/db2profile 設置實例在每次登錄時自啟動 su prod db2iauto -on prod 啟動實例 db2start #必須用實例擁有者登錄後執行此命令 列出所有實例 db2ilist 查看當前實例 db2 get instance 查看當前實例配置參數 db2 get dbm cfg 創建/查看/連接數據庫 db2 create database LEON db2 list database directory db2 connect to LEON 查看表空間(明細) db2 list tablespaces show detail 創建一個8k頁面大寫的緩沖池 db2 "CREATE BUFFERPOOL LEON_BU_8K IMMEDIATE SIZE 2000 PAGESIZE 8k" db2 drop bufferpool LEON_BU_8K db2 create bufferpool leon_bp_8k immediate size 5000 pagesize 8k 創建表空間(8K頁面大小) mkdir -p /database #只能創建到這一層,container目錄由數據庫自己創建;如果用戶創建的話,那麼在創建表空間時會報以下錯誤 DB21034E The command was processed as an SQL statement because it was not a valid Command Line Processor command. During SQL processing it returned: SQL0298N Bad container path. SQLSTATE=428B2 chown -R prod:database database db2 "create tablespace LEONSPACE0 pagesize 8192 managed by database using (FILE'/database/container1' 5000 ) bufferpool leon_bp_8k"