环境:centos7虚拟机
DB2版本:11.1
最近项目要用到DB2数据库,也没弄过DB2的,下载的dokcer的,有些访问受限制,所以只好自己手动搭一个了。
还好,网上有现成的关于11.1版本的DB2安装。
这篇安装的参考文章:http://www.qingpingshan.com/pc/fwq/235168.html
在官网下载的11.1的版本的。
v11.1_linuxx64_expc.tar.gz
我的软件存放位置在/home/setup下
一、解压:
[[email protected] setup]# tar -zxvf v11.1_linuxx64_expc.tar.gz -C /home/software
解压之后,是一个叫做expc的目录文件
[[email protected] expc]# ls
db2 db2ckupgrade db2_deinstall db2_install db2ls db2prereqcheck db2setup
二,检验安装的先决条件
[[email protected] expc]# ./db2prereqcheck
一下子出来了好多的东西。我的翻页都被从头到尾了。这个时候最好开启个日志,来看究竟缺少的依赖关系。
缺依赖关系,有些东西还是yum也解决不了的。这我也没办法了。就只能这么空着了。
有些已经写明了,缺少什么什么就会缺少什么什么功能,这个大不了不要了吧。
最后,就安装了一个包文件。
所以说,实在安不上的,就不要纠结了,就直接安装得了。
三、然后直接安装了。
[[email protected] expc]# ./db2_install
刚开始的时候,需要输入两次yes,同意协议,同意安装路径。
之后就都自动了。
到#29启动的时候会停顿一下,害得我紧张了一下,还好它自己走完了。
创建用户组,至于为什么是这么个名称,可能是官方要求吧?
[[email protected] expc]# groupadd -g 2000 db2iadm1
[[email protected] expc]# groupadd -g 2001 db2fadm1
[[email protected] expc]# useradd -m -g db2iadm1 -d /home/db2inst1 db2inst1
[[email protected] expc]# useradd -m -g db2fadm1 -d /home/db2fenc1 db2fenc1
[[email protected] expc]# passwd db2inst1
这个密码设置的非常的麻烦。得拿本记下来才行。
四、这时候换到另一个目录下。这个目录是自动生成的。好像就是安装目录吧。。。
这个是给实例用户注册某个协议吧。。。
[[email protected] expc]# cd /opt/ibm/db2/V11.1/adm/
[[email protected] adm]# chmod -R 775 *
这里是自己的软件安装目录。
[[email protected] adm]# ./db2licm -a /home/software/expc/db2/license/db2expc_uw.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.1/license/zh_CN.utf8"
五、继续跳目录
这里绑定了端口号。。。
[[email protected] adm]# cd /opt/ibm/db2/V11.1/instance/
[[email protected] instance]# chmod -R 775 *
[[email protected] instance]# ./db2icrt -p 50000 -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.5871".
DBI1070I Program db2icrt completed successfully.
六、完成了。
要切换到实例用户,才可以登录db2数据库
[[email protected] instance]# su - db2inst1
上一次登录:五 12月 1 15:36:55 CST 2017pts/2 上
创建样本数据库
[[email protected] ~]$ 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.
[[email protected] ~]$ db2start
SQL1063N DB2START processing was successful.
[[email protected] ~]$ db2 connect to sample
Database Connection Information
Database server = DB2/LINUXX8664 11.1.2.2
SQL authorization ID = DB2INST1
Local database alias = SAMPLE
[[email protected] ~]$ db2 "select * from staff"
竟然自带数据,666。
[[email protected] ~]$ db2licm -l
Product name: "DB2 Express-C"
License type: "Unwarranted"
Expiry date: "Permanent"
Product identifier: "db2expc"
Version information: "11.1"
Max number of CPUs: "2"
Max amount of memory (GB): "16"
Max number of cores: "2"
Enforcement policy: "Soft Stop"