Linux下安装DB2数据库

1.下载DB2数据库软件包v10.5_DB2_linuxx64_expc.tar_.gz

2.解压 tar -zxvf db2软件包(放在/opt/db2v10.5目录下)

[root@localhost opt]# cd  db2v10.5/
[root@localhost db2v10.5]# ls
v10.5_DB2_linuxx64_expc.tar_.gz
[root@localhost db2v10.5]# tar -zxvf v10.5_DB2_linuxx64_expc.tar_.gz

3.开始安装软件包

[root@localhost db2v10.5]# ls
expc  v10.5_DB2_linuxx64_expc.tar_.gz
[root@localhost db2v10.5]# cd expc/
[root@localhost expc]# ls
db2  db2ckupgrade  db2_deinstall  db2_install  db2ls  db2prereqcheck  db2setup
[root@localhost expc]# ./db2_install
Default directory for installation of products - /opt/ibm/db2/V10.5

***********************************************************
Install into default directory (/opt/ibm/db2/V10.5) ? [yes/no]
是否选择默认目录安装,选择yes
*************************************************
The execution completed successfully.
安装命令执行完成
[root@localhost opt]# ls
db2v10.5  ibm  mqm  redis  rh

4.注册license

[root@localhost adm]# pwd
/opt/ibm/db2/V10.5/adm
[root@localhost adm]# ls
cielock   db2cap     db2dasstml  db2fmpr     db2genp  db2govlg   db2ida    db2licm  db2pdcfg  db2rocme  db2set    db2stop   db2sysc
db2audit  db2chparm  db2fmp      db2fmpr32   db2gov   db2havend  db2inidb  db2path  db2rfpen  db2rstar  db2star2  db2stop2  db2syscr
db2cacpy  db2dart    db2fmp32    db2fmpterm  db2govd  db2iclean  db2licd   db2pd    db2rocm   db2rstop  db2start  db2stst   db2trc

[root@localhost adm]# ./db2licm -a /opt/db2v10.5/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/V10.5/license/en_US.iso88591"
[root@localhost adm]#

5.创建三个用户组

[root@localhost adm]# groupadd -g 901 db2iadm1
[root@localhost adm]# groupadd -g 902 db2fadm1
[root@localhost adm]# groupadd -g 903 db2dadm1

6.创建三个用户(分别是拥有实例的用户,受防护的用户,DAS用户)且指定对应的用户组

[root@localhost adm]# useradd -g db2iadm1 -u 101 -d  /home/db2inst1 -m  db2inst1
[root@localhost adm]# useradd -g db2fadm1 -u 102 -d  /home/db2fenc1 -m  db2fenc1
[root@localhost adm]# useradd -g db2dadm1 -u 103 -d  /home/db2dasusr1 -m  db2dasusr1

参数说明:
-u uid  使用者的ID值,必须为唯一的ID值,除非用-o选项可以不唯一,数字不可为负值,0~999传统上是保留给系统帐号使用。
-d path 使用者目录
-m  使用者目录如不存在则自动建立
-s shell  使用者登入后使用shell名称作为提示符,如果不写系统会帮你指定预设的登入shell

7.添加三个用户的密码

[root@localhost adm]# passwd db2inst1
Changing password for user db2inst1.
New password: 
BAD PASSWORD: it is based on a dictionary word
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost adm]# passwd db2fenc1
Changing password for user root.
New password: 
BAD PASSWORD: it is based on a dictionary word
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost adm]# passwd db2dasusr1
Changing password for user db2dasusr1.
New password: 
BAD PASSWORD: it is based on a dictionary word
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@localhost adm]#

8.检查用户组和用户是否创建成功

[root@localhost adm]# more /etc/group | grep db2
db2iadm1:x:901:
db2fadm1:x:902:
db2dadm1:x:903:
[root@localhost adm]# more /etc/passwd | grep db2
db2inst1:x:101:901::/home/db2inst1:/bin/bash
db2fenc1:x:102:902::/home/db2fenc1:/bin/bash
db2dasusr1:x:103:903::/home/db2dasusr1:/bin/bash

9.创建实例

[root@localhost instance]# pwd
/opt/ibm/db2/V10.5/instance
[root@localhost instance]# ./dascrt -u db2dasusr1 (注:创建DB2管理服务器)
 [root@localhost instance]# ./db2icrt -u db2fenc1 db2inst1 (注:创建DB2实例)

10.配置DB2
(1)设置DB2自启动(注:依然在root用户下)

[root@localhost instance]# pwd
/opt/ibm/db2/V10.5/instance
 [root@localhost instance]# ./db2iauto -on db2inst1
 db2set MsgRC=1306, P1='', P2=''
 [root@localhost instance]# 
设置对db2inst1在Linux启动时自动启动。

(2)修改网络服务端口(注:在db2inst1用户下)
修改DB2的服务端口为50658,默认情况下端口是50000

 [root@localhost instance]# su - db2inst1
 [db2inst1@localhost ~]$ db2 update dbm cfg using SVCENAME 50658
 DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed 
 successfully.
 [db2inst1@localhost ~]$ 

(3)修改DB2连接方式为TCP/IP

 [db2inst1@localhost ~]$ db2set DB2COMM=TCPIP
 [db2inst1@localhost ~]$
 修改DB2连接方式为TCPIP,然后可通过JDBCODBC等访问本DB2服务器上的数据库,安装了DB2客户端的其它机器也可访问数据库。

11.查看DB2许可证情况

[db2inst1@localhost ~]$ db2licm -l
Product name:                     "DB2 Express-C"
License type:                     "Unwarranted"
Expiry date:                      "Permanent"
Product identifier:               "db2expc"
Version information:              "10.5"
Max number of CPUs:               "2"
Max amount of memory (GB):        "16"
Enforcement policy:               "Soft Stop"
注:上面为官网下载的免费DB2版本

[root@localhost ~]$ su - db2inst1
 [db2inst1@localhost ~]$ db2licm -l
 Product Name                            = "DB2 Universal Database Express Edition"
 Product Identifier                      = "DB2EXP"
 Version Information                     = "8.2"
 Expiry Date                             = "Permanent"
 Registered User Policy                  = "Disabled"
 Enforcement Policy                      = "Soft Stop"
 Number of processors                    = "1"
 Number of licensed processors           = "2"
 Annotation                              = ""
 Other information                       = ""

[db2inst1@localhost ~]$ db2licm -l
注:上面为商业使用中的付费DB2版本

转载自:http://blog.csdn.net/sunrier/article/details/7826233

你可能感兴趣的:(Linux下安装DB2数据库)