本篇内容介绍了“Linux下怎么安装数据库管理系统DB2”的有关知识,在实际案例的操作过程中,不少人都会遇到这样的困境,接下来就让小编带领大家学习一下如何处理这些情况吧!希望大家仔细阅读,能够学有所成!

DB2 是一种关系数据库管理系统(RDBMS),是 Information Management 产品系列的一部分。DB2 被认为是第一种使用 SQL(一种为 RDBMS 提供接口的语言)的数据库产品。DB2 于 1982 年首次发布,现在已经可以用在许多操作系统平台上,包括 Linux、UNIX 和 Windows。

Linux版本:

Linux版本下的DB2数据库采用的官方免费版本,操作系统用的CentOS6.2。

安装过程:

1、下载:db2_v101_linuxia32_expc.tar.gz

2、解压,解压完成后会在当前目录下有一个 ./expc 文件夹

[root@localhostopt]#tar-zxvfdb2_v101_linuxia32_expc.tar.gz

3、进入这个目录

[root@localhostopt]#cdexpc/

4、执行安装

[root@localhostexpc]#./db2_install

5、添加组和用户:

组(用户名) db2iadm1(db2inst1) db2fadm1( db2fenc1)

[root@localhostexpc]#groupadd-g2000db2iadm1[root@localhostexpc]#groupadd-g2001db2fadm1[root@localhostexpc]#useradd-m-gdb2iadm1-d/home/db2inst1db2inst1[root@localhostexpc]#useradd-m-gdb2fadm1-d/home/db2fenc1db2fenc1[root@localhostexpc]#passwddb2inst1[root@localhostexpc]#passwddb2fenc1

6、安装 license(产品许可证) PS:如果是ExpressC版本就不用做

[root@localhostadm]#pwd/opt/ibm/db2/V10.1/adm[root@localhostadm]#chmod-R775*[db2inst1@localhostadm]$./db2licm-a/tmp/seagull/db2v10/license/db2ese_c.lic

7、创建实例和样本数据库

[root@localhostinstance]#pwd/opt/ibm/db2/V10.1/instance[root@localhostinstance]#chmod-R775*[root@localhostinstance]#./db2icrt-p50000-udb2fenc1db2inst1[root@localhostinstance]#su-db2inst1[db2inst1@localhost~]$db2samplCreatingdatabase"SAMPLE"...Connectingtodatabase"SAMPLE"...Creatingtablesanddatainschema"DB2INST1"...CreatingtableswithXMLcolumnsandXMLdatainschema"DB2INST1"...'db2sampl'processingcomplete.[db2inst1@localhost~]$db2startSQL1026NThedatabasemanagerisalreadyactive.[db2inst1@localhost~]$db2connecttosampleDatabaseConnectionInformationDatabaseserver=DB2/LINUX10.1.2SQLauthorizationID=DB2INST1Localdatabasealias=SAMPLE[db2inst1@localhost~]$db2"select*fromstaff"

8、创建 das 管理服务器

为了远程客户端能够用控制中心来控制数据库服务器,需要在数据库服务器上安装 das,当然,如果只是远程连接而不是远程管理,可以不用装,这里我安装了一下。

[root@localhostexpc]#groupadd-g2002db2asgrp[root@localhostexpc]#useradd-m-gdb2asgrp-d/home/db2asdb2as[root@localhostexpc]#passwddb2as[db2as@localhost~]$su-db2as#这里测试新建用户[db2as@localhost~]$su#这里进入root权限[root@localhost~]#cd/opt/ibm/db2/V10.1/instance/[root@localhostinstance]#./dascrt-udb2asDBI1070IProgramdascrtcompletedsuccessfully.[root@localhostinstance]#su-db2as[db2as@localhost~]$db2adminstartSQL4409WTheDB2AdministrationServerisalreadyactive.

9、设置端口号

vim/etc/services

在最后增加一行 # PS:VIM快捷键,在命令模式下输入“G”跳刀最后一行。

db2inst1 50000/tcp

10、db2 配置,要切换到用户 db2inst1 su – db2inst1 db2set DB2_EXTENDED_OPTIMIZATION=ON db2set DB2_DISABLE_FLUSH_LOG=ON db2set AUTOSTART=YES db2set DB2_STRIPED_CONTAINERS=ON db2set DB2_HASH_JOIN=Y db2set DB2COMM=tcpip db2set DB2_PARALLEL_IO=* db2set DB2CODEPAGE=819 # PS:这个地方比较重要 # db2 update database manager configuration using svcename db2inst1

11.将SVCENAME设置成/etc/services中的端口号或者服务名了吗?

[db2inst1@localhost~]$db2getdbmcfg|grepSVCENAMETCP/IPServicename(SVCENAME)=SSLservicename(SSL_SVCENAME)=

找到SVCENAME,如果当前值不是服务器端的端口号或者服务名,进行更新设置。

[db2inst1@localhost~]$db2updatedbmcfgusingSVCENAMEdb2inst1#db2updatedbmcfgusingINDEXRECACCESS[db2inst1@localhost~]$db2getdbmcfg|grepSVCENAMETCP/IPServicename(SVCENAME)=50000SSLservicename(SSL_SVCENAME)=

# PS:svcename 在客户端连接时需要用到

12.在启动DB2之前需要先关闭防火墙,不然的话根本就不能连接(这个地方的疏忽纠结了好久),在root用户下执行:service iptables stop

13.开启DB2,执行:db2start ,如果已经开启状态,那就先停止,执行:db2stop 。

设置查看:

PS:重启机器后遇到了一个问题,就是关闭防火墙无反应,开启关闭数据库无反应,远程不能连接到数据库,解决办法是重启了服务器,然后按照顺序关闭了防火墙,然后重启了DB2数据库。

“Linux下怎么安装数据库管理系统DB2”的内容就介绍到这里了,感谢大家的阅读。如果想了解更多行业相关的知识可以关注亿速云网站,小编将为大家输出更多高质量的实用文章!