# IBM DB2 12 學習之旅1: 安裝
## 1.說明
在本文中,我將在 Red Hat Enterprise 9.5 上安裝 IBM Db2 12.1。
Db2 Community Edition 可從 IBM Db2 Web 網站(https://www.ibm.com/account/reg/us-en/signup?formid=urx-33669)下載
## 2.安裝前準備
- 建立一個名為 db2inst1 的使用者和一個名為 dba 的組作為 root。
>``` shell!
>groupadd dba
>useradd -d /home/db2inst1 -g dba -s /bin/bash db2inst1
- 解壓縮 Db2 安裝檔
>``` shell!
>tar xzf v12.1.1_linuxx64_server_dec.tar.gz
>cd server_dec/
>redhat@server:/home/redhat/software/server_dec>
>$ ls -lrt
>total 84
>-r-xr-xr-x. 1 redhat redhat 5254 Apr 17 12:15 db2ckupgrade
>-r-xr-xr-x. 1 redhat redhat 5041 Apr 17 12:16 db2ls
>-r--r--r--. 1 redhat redhat 4987 Apr 17 12:16 db2checkCOL_readme.txt
>-r-xr-xr-x. 1 redhat redhat 5207 Apr 17 12:16 db2_deinstall
>-r--r--r--. 1 redhat redhat 16925 Apr 17 12:16 db2checkCOL.tar.gz
>-r-xr-xr-x. 1 redhat redhat 5095 Apr 17 12:16 installFixPack
>-r-xr-xr-x. 1 redhat redhat 5059 Apr 17 12:16 db2setup
>-r-xr-xr-x. 1 redhat redhat 5059 Apr 17 12:16 db2prereqcheck
>-r-xr-xr-x. 1 redhat redhat 5077 Apr 17 12:16 db2_install
>drwxr-xr-x. 6 redhat redhat 134 Apr 17 12:16 db2
## 3.安裝前檢查(db2prereqcheck)
- 執行 pre-req 腳本 db2prereqcheck,會看到許多警告,因此,必須執行以下命令才能安裝先決條件。
>``` shell!
>./db2prereqcheck -v 12.1.1.0
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "elfutils-libelf-devel".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "patch".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "make".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "perl".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "kernel-headers".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "kernel-devel".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "m4".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "gcc-c++".
>DBT3507E The db2prereqcheck utility failed to find the following package or file: "gcc".
>DBT3563E The db2prereqcheck utility determined that SELinux is enabled, which is not supported with IBM Storage Scale.
>DBT3618E The db2prereqcheck utility detected that ksh is not linked to ksh, ksh93 or mksh or lksh. This is required for Db2 High Availability Feature.
>...類似這樣的,會跟你說缺了什麼東西
- 補齊套件(這裡以yum為範例)
>``` shell!
>yum install -y gcc gcc-c++ patch make perl m4 kernel-devel kernel-headers ksh libstdc++.i686 python3-dnf-plugin-versionlock pam.i686 NetworkManager-config-server
- 禁用SELinux
>``` shell!
>DBT3563E The db2prereqcheck utility determined that SELinux is enabled, which is not supported with IBM Storage Scale.
>``` shell!
>vi /etc/selinux/config
>改 SELINUX=disabled
>reboot
- 上面的動作都做完後,再跑一次db2prereqcheck,確定沒有缺少套件,也沒有看到警告,就可以開始安裝DB2了
## 4.開始安裝
>``` shell!
>./db2_install
以下是安裝紀錄(有點長,可以直接拉到最後看成功訊息)
>``` shell!
>Read the license agreement file in the db2/license directory.
>
>***********************************************************
>To accept those terms, enter "yes". Otherwise, enter "no" to cancel the install process. [yes/no]
>yes
>
>
>Default directory for installation of products - /opt/ibm/db2/V12.1
>
>***********************************************************
>Install into default directory (/opt/ibm/db2/V12.1) ? [yes/no]
>yes
>
>
>Specify one of the following keywords to install DB2 products.
>
> SERVER
> CONSV
> CLIENT
> RTCL
>
>Enter "help" to redisplay product names.
>
>Enter "quit" to exit.
>
>***********************************************************
>SERVER
>***********************************************************
>Do you want to install the DB2 pureScale Feature? [yes/no]
>no
>DB2 installation is being initialized.
>
> Total number of tasks to be performed: 56
>Total estimated time for all tasks to be performed: 2910 second(s)
>
>Task #1 start
>Description: Checking license agreement acceptance
>Estimated time 1 second(s)
>Task #1 end
>
>Task #2 start
>Description: Product Messages - English
>Estimated time 14 second(s)
>Task #2 end
>
>Task #3 start
>Description: Base Client Support for installation with root privileges
>Estimated time 3 second(s)
>Task #3 end
>
>Task #4 start
>Description: Base client support
>Estimated time 312 second(s)
>Task #4 end
>
>Task #5 start
>Description: Java Runtime Support
>Estimated time 191 second(s)
>Task #5 end
>
>Task #6 start
>Description: Java Help (HTML) - English
>Estimated time 7 second(s)
>Task #6 end
>
>Task #7 start
>Description: Global Secure ToolKit
>Estimated time 75 second(s)
>Task #7 end
>
>Task #8 start
>Description: SQL procedures
>Estimated time 3 second(s)
>Task #8 end
>
>Task #9 start
>Description: Java Common files
>Estimated time 18 second(s)
>Task #9 end
>
>Task #10 start
>Description: Base server support for installation with root privileges
>Estimated time 3 second(s)
>Task #10 end
>
>Task #11 start
>Description: ICU Utilities
>Estimated time 43 second(s)
>Task #11 end
>
>Task #12 start
>Description: Java support
>Estimated time 11 second(s)
>Task #12 end
>
>Task #13 start
>Description: Base server support
>Estimated time 729 second(s)
>Task #13 end
>
>Task #14 start
>Description: Relational wrappers common
>Estimated time 3 second(s)
>Task #14 end
>
>Task #15 start
>Description: DB2 data source support
>Estimated time 7 second(s)
>Task #15 end
>
>Task #16 start
>Description: Control Center Help (HTML) - English
>Estimated time 13 second(s)
>Task #16 end
>
>Task #17 start
>Description: Scientific Data Sources
>Estimated time 5 second(s)
>Task #17 end
>
>Task #18 start
>Description: Sample database source
>Estimated time 4 second(s)
>Task #18 end
>
>Task #19 start
>Description: Replication tools
>Estimated time 61 second(s)
>Task #19 end
>
>Task #20 start
>Description: itlm
>Estimated time 3 second(s)
>Task #20 end
>
>Task #21 start
>Description: Oracle data source support
>Estimated time 5 second(s)
>Task #21 end
>
>Task #22 start
>Description: Teradata data source support
>Estimated time 3 second(s)
>Task #22 end
>
>Task #23 start
>Description: Pacemaker
>Estimated time 100 second(s)
>Task #23 end
>
>Task #24 start
>Description: Spatial Extender server support
>Estimated time 20 second(s)
>Task #24 end
>
>Task #25 start
>Description: DB2 Instance Setup wizard
>Estimated time 12 second(s)
>Task #25 end
>
>Task #26 start
>Description: JDBC data source support
>Estimated time 260 second(s)
>Task #26 end
>
>Task #27 start
>Description: Application data sources
>Estimated time 4 second(s)
>Task #27 end
>
>Task #28 start
>Description: Command Line Processor Plus
>Estimated time 9 second(s)
>Task #28 end
>
>Task #29 start
>Description: SQL Server data source support
>Estimated time 4 second(s)
>Task #29 end
>
>Task #30 start
>Description: Informix data source support
>Estimated time 4 second(s)
>Task #30 end
>
>Task #31 start
>Description: Communication support - TCP/IP
>Estimated time 3 second(s)
>Task #31 end
>
>Task #32 start
>Description: IBM Software Development Kit (SDK) for Java(TM)
>Estimated time 448 second(s)
>Task #32 end
>
>Task #33 start
>Description: DB2 LDAP support
>Estimated time 4 second(s)
>Task #33 end
>
>Task #34 start
>Description: Structured file data sources
>Estimated time 5 second(s)
>Task #34 end
>
>Task #35 start
>Description: ODBC data source support
>Estimated time 258 second(s)
>Task #35 end
>
>Task #36 start
>Description: DB2 Text Search
>Estimated time 109 second(s)
>Task #36 end
>
>Task #37 start
>Description: EnterpriseDB code
>Estimated time 3 second(s)
>Task #37 end
>
>Task #38 start
>Description: Sybase data source support
>Estimated time 3 second(s)
>Task #38 end
>
>Task #39 start
>Description: Connect support
>Estimated time 3 second(s)
>Task #39 end
>
>Task #40 start
>Description: Spatial Extender client
>Estimated time 3 second(s)
>Task #40 end
>
>Task #41 start
>Description: Parallel Extension
>Estimated time 3 second(s)
>Task #41 end
>
>Task #42 start
>Description: Base application development tools
>Estimated time 36 second(s)
>Task #42 end
>
>Task #43 start
>Description: Guardium Installation Manager Client
>Estimated time 3 second(s)
>Task #43 end
>
>Task #44 start
>Description: First Steps
>Estimated time 3 second(s)
>Task #44 end
>
>Task #45 start
>Description: Federated Data Access Support
>Estimated time 3 second(s)
>Task #45 end
>
>Task #46 start
>Description: Product Signature for DB2 Server Edition
>Estimated time 8 second(s)
>Task #46 end
>
>Task #47 start
>Description: Setting DB2 library path
>Estimated time 180 second(s)
>Task #47 end
>
>Task #48 start
>Description: Enabling the watchdog
>Estimated time 20 second(s)
>Task #48 end
>
>Task #49 start
>Description: Installing or updating Db2 resource agent scripts for Pacemaker
>Estimated time 20 second(s)
>Task #49 end
>
>Task #50 start
>Description: Executing control tasks
>Estimated time 20 second(s)
>Task #50 end
>
>Task #51 start
>Description: Updating global registry
>Estimated time 20 second(s)
>Task #51 end
>
>Task #52 start
>Description: Starting DB2 Fault Monitor
>Estimated time 10 second(s)
>Unit db2fmcd.service could not be found.
>Task #52 end
>
>Task #53 start
>Description: Updating the db2ls and db2greg link
>Estimated time 1 second(s)
>Task #53 end
>
>Task #54 start
>Description: Registering DB2 licenses
>Estimated time 5 second(s)
>Task #54 end
>
>Task #55 start
>Description: Setting default global profile registry variables
>Estimated time 1 second(s)
>Task #55 end
>
>Task #56 start
>Description: Initializing instance list
>Estimated time 5 second(s)
>Task #56 end
>
>Task #57 start
>Description: Updating global profile registry
>Estimated time 3 second(s)
>Task #57 end
>
>The execution completed successfully.
>
>For more information see the DB2 installation log at
>"/tmp/db2_install.log.5985".
- 使用 db2ls 列出已安裝的 Db2 產品
>``` shell!
>cd /opt/ibm/db2/V12.1/install
>db2ls
>Install Path Level Fix Pack >Special Install Number Install Date Installer UID
>---------------------------------------------------------------------------------------------------------------------
>/opt/ibm/db2/V12.1 12.1.1.0 0 ...後面省略
- 列出db2授權狀態
>``` shell!
>cd /opt/ibm/db2/V12.1/adm/
>db2licm -l
>Product name: "DB2 Community Edition"
>License type: "Community"
>Expiry date: "Permanent"
>Product identifier: "db2dec"
>Version information: "12.1"
>Max amount of memory (GB): "8"
>Max number of cores: "4"
>Enforcement policy: "Hard Stop"
>Features:
>IBM DB2 Performance Management Offering: "Not >licensed"
## 下一篇:
- 建立DB2 Instance
- 建立SAMPLE資料庫
- 設定開機自動啟動資料庫服務