1. 安装包下载
官网下载地址(需要登录IBM账号)
步骤1:检查以下链接以了解最新的安装要求
https://www.ibm.com/support/pages/node/612045
步骤2:从下面的链接下载 DB2 LUW 产品映像
https://www.ibm.com/support/pages/download-db2-fix-packs-version-db2-linux-unix-and-window
2. 安装包解压
安装包名称是v12.1.1_linuxx64_server_dec.tar.gz
先解压
[root@99host ~]# tar -zxvf v12.1.1_linuxx64_server_dec.tar.gz
[root@99host ~]# cd server_dec/
[root@99host server_dec]# ls
db2 db2checkCOL.tar.gz db2_deinstall db2ls db2setup
db2checkCOL_readme.txt db2ckupgrade db2_install db2prereqcheck installFixPack
3. 环境预检查
执行db2prereqcheck,进行预安装环境检查,发现缺少两
[root@99host server_dec]# ./db2prereqcheck -l
[root@99host server_dec]# ./db2prereqcheck -l
Requirement not matched for DB2 database "Server" . Version: "12.1.1.0".
Summary of prerequisites that are not met on the current system:
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file only required to support 32-bit non-sql routines: "/lib/libpam.so*" provided by the "pam.i686" package.
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file only required to support 32-bit non-sql routines: "libstdc++.so.6" provided by the "libstdc++.i686" package.
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.
Requirement not matched for DB2 database "Server" with pureScale feature . Version: "12.1.1.0".
Summary of prerequisites that are not met on the current system:
DBT3622E The db2prereqcheck utility failed to verify the prerequisites for PCMK. Ensure your machine meets all the PCMK installation prerequisites. For detailed information, please check /tmp/db2prereqPCMK.log.*
DBT3507E The db2prereqcheck utility failed to find the following package or file: "kernel-source".
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.
安装组件,禁用selinux,后重启服务器
dnf install pam.i686 libstdc++.i686
dnf install ksh
dnf install gcc-c++ gcc
vi /etc/selinux/config
SELINUX=disabled
重新检查
[root@99host server_dec]# ./db2prereqcheck -l
Requirement not matched for DB2 database "Server" with pureScale feature . Version: "12.1.1.0".
Summary of prerequisites that are not met on the current system:
DBT3622E The db2prereqcheck utility failed to verify the prerequisites for PCMK. Ensure your machine meets all the PCMK installation prerequisites. For detailed information, please check /tmp/db2prereqPCMK.log.*
DBT3507E The db2prereqcheck utility failed to find the following package or file: "kernel-source".
这两个问题的严重程度以及是否可以忽略,取决于你对 DB2 的使用需求,下面为你分别分析:
DBT3622E
:PCMK 先决条件验证失败
- 生产环境:在生产环境中,不建议忽略这个问题。因为生产环境对数据库的可用性和稳定性要求很高,DB2 pureScale 特性通常是为了满足这些需求而使用的。如果忽略此问题,可能会导致数据库在运行过程中出现故障,影响业务的正常运行。
- 测试环境:如果只是在测试环境中简单测试 DB2 的基本功能,不使用 pureScale 特性,那么可以考虑忽略这个问题。但在这种情况下,建议在安装 DB2 时选择不安装 pureScale 相关组件,以避免后续出现不必要的错误。
DBT3507E
:缺少kernel-source
包
- 生产环境:在生产环境中,不建议忽略这个问题。因为 DB2 的某些高级功能可能依赖于
kernel-source
包,缺少该包可能会导致这些功能无法正常使用,或者在系统升级、维护等过程中出现问题。- 测试环境:如果只是进行简单的功能测试,不涉及到需要编译内核模块等依赖
kernel-source
的操作,那么可以考虑忽略这个问题。但如果后续需要使用这些功能,还是需要安装kernel-source
包。
添加license
[root@99host sqllib]# cd /opt/ibm/db2/V12.1/
[root@99host V12.1]# ls
adm bin cfg db2tss doc function gskit ha infopop instance json lib64 logs misc pd python Readme security32 tools
adsm bnd conv desktop federation gse guardium include install java lib32 license map msg properties R samples security64
[root@99host V12.1]# cd adm
[root@99host adm]# ls
cielock db2cap db2dart db2fmpr db2genp db2ida db2licm db2pd db2rappl db2rfpen db2rocme db2set db2stop db2syscr runr.sh
db2audit db2chparm db2fmp db2fmpr32 db2havend db2inidb db2linkspeed db2pdcfg db2rem db2rocm db2rstar db2star2 db2stop2 db2trc
db2cacpy db2credman db2fmp32 db2fmpterm db2iclean db2licd db2path db2rapp db2remot db2rocmc db2rstop db2start db2sysc runpy.sh
[root@99host adm]# ./db2licm -a /root/server_dec/db2/license/db2dec.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/V12.1/license/en_US.iso88591"
4. 创建用户
getent group db2iadm1
getent group db2fsdm1
useradd -u 1004 -g db2iadm1 -m -d /home/db2inst1 db2inst1
useradd -u 1003 -g db2fsdm1 -m -d /home/db2fenc1 db2fenc1
或者
groupadd -g 2000 db2iadm1
groupadd -g 2001 db2fadm1
useradd -m -g db2iadm1 -d /home/db2inst1 db2inst1
useradd -m -g db2fadm1 -d /home/db2fenc1 db2fenc1
passwd db2inst1
passwd db2fenc1
5. DB2安装
5.1 安装
[root@99host server_dec]# ./db2_install
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]
yes
DBT3557E The db2prereqcheck utility determined that the current platform is not supported with the DB2 pureScale Feature.
Aborting the current installation ...
Run installation with the option "-f sysreq" parameter to force the installation.
[root@99host server_dec]# ./db2_install
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]
yess
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: 54
Total estimated time for all tasks to be performed: 2790 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: Spatial Extender server support
Estimated time 20 second(s)
Task #23 end
Task #24 start
Description: DB2 Instance Setup wizard
Estimated time 12 second(s)
Task #24 end
Task #25 start
Description: JDBC data source support
Estimated time 260 second(s)
Task #25 end
Task #26 start
Description: Application data sources
Estimated time 4 second(s)
Task #26 end
Task #27 start
Description: Command Line Processor Plus
Estimated time 9 second(s)
Task #27 end
Task #28 start
Description: SQL Server data source support
Estimated time 4 second(s)
Task #28 end
Task #29 start
Description: Informix data source support
Estimated time 4 second(s)
Task #29 end
Task #30 start
Description: Communication support - TCP/IP
Estimated time 3 second(s)
Task #30 end
Task #31 start
Description: IBM Software Development Kit (SDK) for Java(TM)
Estimated time 448 second(s)
Task #31 end
Task #32 start
Description: DB2 LDAP support
Estimated time 4 second(s)
Task #32 end
Task #33 start
Description: Structured file data sources
Estimated time 5 second(s)
Task #33 end
Task #34 start
Description: ODBC data source support
Estimated time 258 second(s)
Task #34 end
Task #35 start
Description: DB2 Text Search
Estimated time 109 second(s)
Task #35 end
Task #36 start
Description: EnterpriseDB code
Estimated time 3 second(s)
Task #36 end
Task #37 start
Description: Sybase data source support
Estimated time 3 second(s)
Task #37 end
Task #38 start
Description: Connect support
Estimated time 3 second(s)
Task #38 end
Task #39 start
Description: Spatial Extender client
Estimated time 3 second(s)
Task #39 end
Task #40 start
Description: Parallel Extension
Estimated time 3 second(s)
Task #40 end
Task #41 start
Description: Base application development tools
Estimated time 36 second(s)
Task #41 end
Task #42 start
Description: Guardium Installation Manager Client
Estimated time 3 second(s)
Task #42 end
Task #43 start
Description: First Steps
Estimated time 3 second(s)
Task #43 end
Task #44 start
Description: Federated Data Access Support
Estimated time 3 second(s)
Task #44 end
Task #45 start
Description: Product Signature for DB2 Server Edition
Estimated time 8 second(s)
Task #45 end
Task #46 start
Description: Setting DB2 library path
Estimated time 180 second(s)
Task #46 end
Task #47 start
Description: Executing control tasks
Estimated time 20 second(s)
Task #47 end
Task #48 start
Description: Updating global registry
Estimated time 20 second(s)
Task #48 end
Task #49 start
Description: Starting DB2 Fault Monitor
Estimated time 10 second(s)
Unit db2fmcd.service could not be found.
Task #49 end
Task #50 start
Description: Updating the db2ls and db2greg link
Estimated time 1 second(s)
Task #50 end
Task #51 start
Description: Registering DB2 licenses
Estimated time 5 second(s)
Task #51 end
Task #52 start
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #52 end
Task #53 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #53 end
Task #54 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #54 end
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2_install.log.2651".
[root@99host server_dec]# cd /opt/ibm/db2/V12.1
5.2 创建实例
./db2icrt -u
[root@99host instance]# chmod -R 755 *
[root@99host instance]# ./db2icrt -p 25010 -u db2fenc1 db2inst1
DBI1446I The db2icrt command is running.
DB2 installation is being initialized.
Total number of tasks to be performed: 4
Total estimated time for all tasks to be performed: 309 second(s)
Task #1 start
Description: Setting default global profile registry variables
Estimated time 1 second(s)
Task #1 end
Task #2 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #2 end
Task #3 start
Description: Configuring DB2 instances
Estimated time 300 second(s)
Task #3 end
Task #4 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #4 end
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2icrt.log.35945".
DBI1070I Program db2icrt completed successfully.
创建sample实例
[db2inst1@99host sqllib]$ db2sampl
Starting the DB2 instance...
Creating database "SAMPLE"...
Connecting to database "SAMPLE"...
Creating tables and data in schema "DB2INST1"...
Creating tables with XML columns and XML data in schema "DB2INST1"...
Stopping the DB2 instance...
'db2sampl' processing complete.
[db2inst1@99host sqllib]$ db2start
02/28/2025 01:35:10 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
[db2inst1@99host sqllib]$ db2 connect to sample
Database Connection Information
Database server = DB2/LINUXX8664 12.1.1.0
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
6. 验证安装
将工作目录更改为 DB2 安装路径并运行 ls -lrt
您应该看到以下目录,并且所有目录都必须属于 bin 所有。
[root@99host server_dec]# cd /opt/ibm/db2/V12.1
[root@99host V12.1]# ls
adm bin cfg db2tss doc function gskit ha infopop instance json lib64 logs misc pd python Readme security32 tools
adsm bnd conv desktop federation gse guardium include install java lib32 license map msg properties R samples security64
[root@99host V12.1]# ls -lrt
total 84
drwxr-xr-x 30 bin bin 4096 Dec 17 06:28 samples
drwxr-xr-x 4 bin bin 4096 Dec 17 06:28 java
drwxr-xr-x 5 bin bin 4096 Dec 17 06:28 include
drwxr-xr-x 2 bin bin 8192 Dec 17 06:28 bnd
drwxr-xr-x 4 bin bin 27 Dec 17 06:28 conv
drwxr-xr-x 2 bin bin 189 Dec 17 06:28 Readme
lrwxrwxrwx 1 root root 12 Dec 17 06:28 logs -> install/logs
drwxr-xr-x 5 bin bin 57 Dec 17 06:28 json
drwxr-xr-x 2 bin bin 63 Dec 17 06:28 map
drwxr-xr-x 3 bin bin 17 Dec 17 06:28 R
drwxr-xr-x 3 bin bin 20 Dec 17 06:28 security32
drwxr-xr-x 4 bin bin 49 Dec 17 06:28 python
drwxr-xr-x 3 bin bin 116 Dec 17 06:28 security64
drwxr-xr-x 5 bin bin 44 Dec 17 06:28 ha
drwxr-xr-x 3 bin bin 4096 Dec 17 06:28 pd
drwxr-xr-x 2 bin bin 4096 Dec 17 06:28 misc
drwxr-xr-x 2 bin bin 76 Dec 17 06:28 adsm
drwxr-xr-x 6 bin bin 64 Dec 17 06:28 federation
drwxr-xr-x 4 bin bin 4096 Dec 17 06:28 tools
drwxr-xr-x 5 bin bin 80 Dec 17 06:28 desktop
drwxr-xr-x 3 bin bin 8192 Dec 17 06:28 bin
drwxr-xr-x 3 bin bin 62 Dec 17 06:29 gskit
drwxr-xr-x 2 bin bin 24 Dec 17 06:29 guardium
drwxr-xr-x 2 bin bin 26 Dec 17 06:29 gse
drwxr-xr-x 3 bin bin 52 Dec 17 06:29 function
drwxr-xr-x 3 bin bin 21 Dec 17 06:29 properties
drwxr-xr-x 4 bin bin 4096 Dec 17 06:29 instance
drwxr-xr-x 3 bin bin 20 Dec 17 06:29 doc
drwxr-xr-x 3 bin bin 28 Dec 17 06:29 msg
drwxr-xr-x 2 bin bin 4096 Dec 17 06:29 adm
drwxr-xr-x 7 bin bin 70 Dec 17 06:29 db2tss
drwxr-xr-x 4 bin bin 57 Dec 17 06:29 infopop
drwxr-xr-x 3 bin bin 4096 Feb 27 21:22 lib32
drwxr-xr-x 4 bin bin 12288 Feb 27 21:22 lib64
drwxr-xr-x 5 bin bin 4096 Feb 27 21:25 cfg
drwxr-xr-x 41 bin bin 4096 Feb 27 21:25 license
drwxr-xr-x 4 bin bin 143 Feb 27 21:25 install
db2ls 输出应该列出您的安装条目。
[root@99host instance]# db2ls
Install Path Level Fix Pack Special Install Number Install Date Installer UID
---------------------------------------------------------------------------------------------------------------------
/opt/ibm/db2/V12.1 12.1.1.0 0 Fri Feb 28 01:20:12 2025 EST 0
db2licm 查看信息
[db2inst1@99host sqllib]$ 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"
7. 配置环境变量
切换到root,添加环境变量
vi /etc/profile
export PATH=$PATH:/home/db2inst1/sqllib/adm
source /etc/profile
到此,DB2 V12.1 安装完成。