1.下载 安装依赖
链接:https://pan.baidu.com/s/1rpZn3H1oN8O0kn8YQMa-gQ?pwd=8u9d
提取码:8u9d
需要关闭SELinux
修改配置文件vi /etc/selinux/config,将SELinux置为disabled,并重启机器。
安装缺失的32位包
从RHEL 6开始,默认不安装32位包,因此安装之前需要修改配置,直接连32位包也一并安装上。
echo 'multilib_policy=all' >> /etc/yum.conf
yum install -y glibc* libstdc*
yum whatprovides libstdc++.so.5
yum install compat-libstdc++-33
rpm -qf /usr/lib64/libpam.so.0
rpm -qf /usr/lib64/libpam.so.0.83.1
yum install -y pam*
yum install libstdc++.so.6 libpam.so* -y
pureScale feature 问题(TBD)
Prereqcheck msg:
Requirement not matched for DB2 database "Server" with pureScale feature . Version: "9.8.0.2".
这个不用解决,选择安装pureScale feature的时候输入“no”.
2.解压包 放到opt目录下使用命令行安装Db2
./db2_install
默认安装目录为 /opt/ibm/db2/V10.5
配置并创建数据库
创建组、用户及密码
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 # db2inst1
安装License
cd /opt/ibm/db2/V10.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/V10.5/license/en_US.iso88591"
三、使用 db2icrt 创建实例
/opt/ibm/db2/V10.5/instance/db2icrt -p 50001 -u db2fenc1 db2inst1
其中,-p 指定了服务器端口号,不指定默认是 50000。
cd /opt/ibm/db2/V10.5/instance/
# 创建一个叫db2inst1的实例
./db2icrt -u db2fenc1 db2inst1
默认端口是5000 netstat -antp|grep 5000
# 切换用户
su - db2inst1
# 启动数据库实例
db2start
# 创建数据库
db2 create db test
# 查看当前实例下所存在的数据库
db2 list db directory
# 连接到数据库
db2 connect to test
# 查看当前数据库下的表空间
db2 list tablespaces
# 测试数据库
db2 "create table user(id int,name varchar(10))"
db2 "insert into user values(1,'a123')"
db2 "insert into user values(2,'b456')"
db2 "select id,name from user"
查看数据
防火墙放行
firewall-cmd --zone=public --add-port=50000/tcp --permanent
firewall-cmd --reload
firewall-cmd --zone=public --list-ports