登录IBM官网,注册IBMid并登录,选择IBM Db2 Database。
Screen Shot 2020-02-21 at 23.08.08.png
选择IBM® Db2 11.5 for Linux® on AMD64 and Intel® EM64T systems (x64)下载后SCP上传至服务器。
解压并安装Db2 precheck依赖
解压Db2安装包
tar -zxvf v11.5_linuxx64_dec.tar.gz
安装缺失的32位包
从RHEL 6开始,默认不安装32位包,因此安装之前需要修改配置,直接连32位包也一并安装上。
echo 'multilib_policy=all' >> /etc/yum.conf
yum install -y glibc* libstdc*
检测环境是否符合Db2安装要求
Db2提供了precheck脚本来检查环境是否满足安装需求:
# 进入解压后目录
cd server_dec/
# 使用root用户运行precheck命令
./db2prereqcheck
解决db2prereqcheck遇到的问题
由于Host环境不同,并非所有问题都会遇到。
缺少 libstdc++.so.5
Prereqcheck msg:
Validating "C++ Library version " ...
Required minimum C++ library: "libstdc++.so.5"
DBT3510E The db2prereqcheck utility was unable to find the following required library file: "libstdc++.so.5".
ERROR : Requirement not matched.
Solution:
yum whatprovides libstdc++.so.5
yum install compat-libstdc++-33
缺少 libstdc++.so.6
Solution类似:
yum install libstdc++.so.6
缺少 libpam.so
Prereqcheck msg:
Validating "/lib/libpam.so*" ...
DBT3514W The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/libpam.so*".
WARNING : Requirement not matched.
Solution:
find / -name libpam.so*
/var/lib/docker/overlay2/7836bf92c4c811abdb81e08154b68f639d2819c030544a159c0455980ff5ba07/diff/usr/lib64/libpam.so.0
/var/lib/docker/overlay2/7836bf92c4c811abdb81e08154b68f639d2819c030544a159c0455980ff5ba07/diff/usr/lib64/libpam.so.0.83.1
/var/lib/docker/overlay2/af7cbccd17e9bff8c66117c4f22c8ab4dd38e7bb0cdf6b20a3a6ee4f71772e93/diff/usr/lib64/libpam.so.0
/var/lib/docker/overlay2/af7cbccd17e9bff8c66117c4f22c8ab4dd38e7bb0cdf6b20a3a6ee4f71772e93/diff/usr/lib64/libpam.so.0.83.1
/usr/lib64/libpam.so.0.83.1
/usr/lib64/libpam.so.0
很明显,缺失32位包,手动安装。
rpm -qf /usr/lib64/libpam.so.0
rpm -qf /usr/lib64/libpam.so.0.83.1
yum install -y pam*
需要关闭SELinux
修改配置文件vi /etc/selinux/config,将SELinux置为disabled,并重启机器。
pureScale feature 问题(TBD)
Prereqcheck msg:
Requirement not matched for DB2 database "Server" with pureScale feature . Version: "9.8.0.2".
Solution:
不是所有问题yum都能解决的,选择安装pureScale feature的时候输入“no”.
使用命令行安装Db2
使用root用户执行安装命令
./db2_install
在install过程中,不安装 pureScale feature
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
配置并创建数据库
创建组、用户及密码
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 # Wenyu0216
安装License
cd /opt/ibm/db2/V11.5/adm/
chmod -R 775 *
./db2licm -a /home/server_dec/db2/license/db2ese_t.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/V11.5/license/en_US.iso88591"
创建实例
cd /opt/ibm/db2/V11.5/instance
chmod -R 775 *
./db2icrt -p 50000 -u db2fenc1 db2inst1
创建数据库
# 切换到实例用户
su - db2inst1
# 创建样本数据库
db2sampl
db2start
db2 connect to sample
db2 "select * from staff"
db2licm -l
Trouble Shooting
DB21019E An error occurred while accessing the directory
在Linux上刚安装完Db2,创建数据库遇到此错误。原因在于应使用su -
,而不是su