linux 环境下db2 V9.7数据库安装、测试、卸载、遇见的问题

    DB2有免费试用版本和商业版本,不同版本都可以在官网进行下载,也可以进行商业版本的购买,本人所在的公司是在13年购买的一套db2 V9.7,大概40万,总共就2套光盘,一套10几张,里边有针对不同机型不同操作系统的db2 v9.7,据领导说序列号是存在单独的一张光盘上的,那张光盘应该是最值钱的,其他的都可以官网上下载。后来我去找序列号那张光盘,硬是没找到。只好问领导要之前拷出来的db2ese_c.lic文件。也可通过 #find / -name db2*.lic 查看当前机器上是否有序列号文件。

   下边就简单介绍我的安装过程:

   本次安装的服务器是从腾讯云上申请的,操作系统为Red Hat 4.8.5-11,安装文件是从光盘里拷出来的DB2_ESE_9_7_0_0_LNXX86_64.iso,也可以将光盘挂载进行安装,序列文件是从领导电脑拷过来的db2ese_c.lic,貌似序列号可以用很多次,不知道IBM是如何限制的。

    1,将安装文件DB2_ESE_9_7_0_0_LNXX86_64.iso拷贝到服务器/ opt下

    2,将安装文件挂载到的/ ​​mnt目录下

    3,进入到/ mnt目录执行安装命令./db2_install

    4,输入“yes”进行软件安装目录更改,输入“no”则默认安装路径

    5,输入“ESE”选择企业商用版本

   6,注册license(将序列文件db 2ese_c.lic拷贝到服务器/ opt下,进入db2安装路径 /opt/ibm/db2/V9.7/adm下执行./db2licm -a /opt/db2ese_c.lic )

    7,db2安装路径/opt/ibm/db2/V9.7/adm下执行(./db2licm -l)查看注册情况

    8,添加用户组,用户(分别是拥有实例的用户,受到防护的用户,DAS用户),为用户组设置密码

    9,创建实例

    10,配置DB2(设置DB2自启动(注:依然在root用户下),修改端口,修改DB2连接方式为TCP / IP)

    11,实例用户下创建数据库

    12,将数据库权限赋给某用户

    13,创建用户临时表空间(在存储过程中使用临时表时需要)

    14,创临时表空间的权限赋予某个用户

    15,设置日志主要参数,重启数据库

    16,建表,查询

    17,测试完毕,删除数据库

    18,停实例,切换root用户,在DB2目录安装执行命令删除实例释放空间

    19,db2安装路径/opt/ibm/db2/V9.7/install下执行#./db2_deinstall -a 命令卸载db2软件

    20,善后 删除用户和组,及主目录

    21,可能遇到的问题及解决办法

下边是具体的执行代码:

[root @ VM_0_17_centos opt]#mount -o loop /opt/DB2_ESE_9_7_0_0_LNXX86_64.iso / mnt
mount:/ dev / loop0被写保护,挂载只读
[root @ VM_0_17_centos opt]#cd / mnt
[root @ VM_0_17_centos mnt] #LS
DB2的db2_deinstall db2_install在db2ls db2prereqcheck的db2setup DOC installFixPack配合nlpack READMEFIRST readmefirst.htm readmefirst.txt
[root@ VM_0_17_centos MNT]#./db2_install
安装的产品的缺省目录- /opt/ibm/db2/V9.7
***** ************************************************** ****
你想选择一个不同的目录来安装[是/否]吗?

no

 指定以下关键字之一来安装DB2产品。

 

  ESE 
  CLIENT 
  RTCL 
 
输入“help”重新显示产品名称。

输入“退出”退出。

************************************************** *********
ESE
DB2安装正在初始化。

 要执行的任务
总数:47要执行  的所有任务的估计时间总计:2019 

任务1启动
描述:检查许可协议的接受情况 
预计时间1秒 
任务#1结束 

任务#2启动
描述:基本客户端支持以root特权进行安装 
预计时间3秒 
任务2结束 

任务3启动
描述:产品消息 - 英文 
预计时间12秒 
任务#3结束 
...........

任务#46开始
描述:注册DB2更新服务 
预计时间30秒 
任务#46结束 

任务#47开始
描述:更新全球配置文件注册表 
预计时间3秒(s) 

 

任务#47结束 

 


此计算机上安装“DB2 Enterprise Server Edition”时发生轻微错误。某些功能可能无法正常运行。

有关更多信息,请参阅位于的DB2安装日志

 

“/tmp/db2_install.log.30503”。

[root@VM_0_17_centos V9.7]#cd  /opt/ibm/db2/V9.7/adm
[root@VM_0_17_centos adm]# ls
cieadmsv  cieprcnt  db2audit  db2chparm   db2fmp    db2fmpr32   db2gov    db2havend    db2inidb  db2linkspeed  db2pdcfg  db2rem    db2rstar  db2star2  db2stop2  db2syscr
ciecsdem  cieprisc  db2cacpy  db2dart     db2fmp32  db2fmpterm  db2govd   db2havend32  db2licd   db2path       db2rapp   db2remot  db2rstop  db2start  db2stst   db2trc
cielock   cieprupx  db2cap    db2dasstml  db2fmpr   db2genp     db2govlg  db2iclean    db2licm   db2pd         db2rappl  db2rfpen  db2set    db2stop   db2sysc
[root@VM_0_17_centos adm]# ./db2licm -a /opt/db2ese_c.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/V9.7/license/en_US.iso88591"

 

[root@VM_0_17_centos adm]$ ./db2licm -l
Product name:                     "DB2 Enterprise Server Edition"
License type:                     "CPU Option"
Expiry date:                      "Permanent"
Product identifier:               "db2ese"
Version information:              "9.7"
Enforcement policy:               "Soft Stop"
Features:
DB2 Database Partitioning:        "Not licensed"
DB2 Performance Optimization ESE: "Not licensed"
DB2 Storage Optimization:         "Not licensed"
DB2 Advanced Access Control:      "Not licensed"
DB2 Geodetic Data Management:     "Not licensed"
IBM Homogeneous Replication ESE:  "Not licensed"
[db2inst1@VM_0_17_centos ~]$ db2 create database hnsale using codeset utf-8 territory us
DB20000I  The CREATE DATABASE command completed successfully.db2licm -l
Product name:                     "DB2 Enterprise Server Edition"
License type:                     "CPU Option"
Expiry date:                      "Permanent"
Product identifier:               "db2ese"
Version information:              "9.7"
Enforcement policy:               "Soft Stop"
Features:
DB2 Database Partitioning:        "Not licensed"
DB2 Performance Optimization ESE: "Not licensed"
DB2 Storage Optimization:         "Not licensed"
DB2 Advanced Access Control:      "Not licensed"
DB2 Geodetic Data Management:     "Not licensed"
IBM Homogeneous Replication ESE:  "Not licensed"

[root@VM_0_17_centos adm]# groupadd -g 901 db2iadm1

[root@VM_0_17_centos adm]# groupadd -g 902 db2fadm1
[root@VM_0_17_centos adm]# groupadd -g 903 db2dadm1
[root@VM_0_17_centos adm]# useradd -g db2iadm1 -u 101 -d  /home/db2inst1 -m  db2inst1
[root@VM_0_17_centos adm]# useradd -g db2fadm1 -u 102 -d  /home/db2fenc1 -m  db2fenc1
[root@VM_0_17_centos adm]# useradd -g db2dadm1 -u 103 -d  /home/db2dasusr1 -m  db2dasusr1
[root@VM_0_17_centos adm]# useradd nbadv
[root@VM_0_17_centos adm]# passwd db2inst1
Changing password for user db2inst1.
New password: 
BAD PASSWORD: The password contains the user name in some form
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@VM_0_17_centos adm]# passwd db2fenc1
Changing password for user db2fenc1.
New password: 
BAD PASSWORD: The password contains the user name in some form
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@VM_0_17_centos adm]# passwd db2dasusr1
Changing password for user db2dasusr1.
New password: 
BAD PASSWORD: The password contains the user name in some form
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@VM_0_17_centos adm]# passwd nbadv
Changing password for user nbadv.
New password: 
BAD PASSWORD: The password is shorter than 8 characters
Retype new password: 
passwd: all authentication tokens updated successfully.
[root@VM_0_17_centos adm]# more /etc/group | grep db2
db2iadm1:x:901:
db2fadm1:x:902:
db2dadm1:x:903:
[root@VM_0_17_centos adm]# cd /opt/ibm/db2/V9.7/instance
[root@VM_0_17_centos instance]# ./db2icrt -u db2fenc1 db2inst1 
DBI1070I  Program db2icrt completed successfully.
[root@VM_0_17_centos instance]# ./db2iauto -on db2inst1
[root@VM_0_17_centos instance]# su - db2inst1
Last login: Fri Mar  2 18:35:24 CST 2018 on pts/1
[db2inst1@VM_0_17_centos ~]$ db2set DB2COMM=TCPIP
[db2inst1@VM_0_17_centos ~]$  db2 update dbm cfg using svcename 50000
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed 
successfully.
[db2inst1@VM_0_17_centos ~]$ db2start
03/02/2018 19:19:13     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

[db2inst1@VM_0_17_centos ~]$ db2 create database hnsale using codeset utf-8 territory us
DB20000I  The CREATE DATABASE command completed successfully.
[db2inst1@VM_0_17_centos ~]$ db2 connect to hnsale

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.0
 SQL authorization ID   = DB2INST1
 Local database alias   = HNSALE
[db2inst1@VM_0_17_centos ~]$ db2 grant dbadm on hnsale to user nbadv
DB20000I  The SQL command completed successfully.
[db2inst1@VM_0_17_centos ~]$ su - root
Password: 
Last login: Fri Mar  2 19:29:32 CST 2018 on pts/1
Last failed login: Fri Mar  2 19:30:43 CST 2018 from 14.116.171.252 on ssh:notty
There was 1 failed login attempt since the last successful login.
[root@VM_0_17_centos ~]# cd /
[root@VM_0_17_centos /]# mkdir path
[root@VM_0_17_centos /]# cd path/
[root@VM_0_17_centos path]# mkdir to
[root@VM_0_17_centos path]# cd to
[root@VM_0_17_centos to]# mkdir tmpfile
[root@VM_0_17_centos to]# ls
tmpfile
[root@VM_0_17_centos ~]# chmod 777 /path/to/tmpfile
[root@VM_0_17_centos ~]# su - db2inst1
Last login: Fri Mar  2 19:35:01 CST 2018 on pts/1
[db2inst1@VM_0_17_centos ~]$ db2 connect to hnsale

 

 

   Database Connection Information

 

 Database server        = DB2/LINUXX8664 9.7.0
 SQL authorization ID   = DB2INST1
 Local database alias   = HNSALE
[db2inst1@VM_0_17_centos ~]$  db2 "CREATE USER TEMPORARY TABLESPACE usertmpname1 MANAGED BY SYSTEM USING ('/path/to/tmpfile')"
DB20000I  The SQL command completed successfully.
[db2inst1@VM_0_17_centos ~]$ db2 "GRANT USE OF TABLESPACE usertmpname1 TO USER nbadv"
DB20000I  The SQL command completed successfully.
[db2inst1@VM_0_17_centos ~]$ db2 update db cfg using logfilsiz 10240
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W  One or more of the parameters submitted for immediate modification 
were not changed dynamically. For these configuration parameters, all 
applications must disconnect from this database before the changes become 
effective.
[db2inst1@VM_0_17_centos ~]$ db2 update db cfg using logprimary 50
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
SQL1363W  One or more of the parameters submitted for immediate modification 
were not changed dynamically. For these configuration parameters, all 
applications must disconnect from this database before the changes become 
effective.
[db2inst1@VM_0_17_centos ~]$ db2 update db cfg using applheapsz 1024
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
[db2inst1@VM_0_17_centos ~]$ db2 force application all
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.
[db2inst1@VM_0_17_centos ~]$ ipclean
ipclean: Removing DB2 engine and client's IPC resources for db2inst1.
[db2inst1@VM_0_17_centos ~]$ db2start
03/02/2018 19:53:50     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.
[db2inst1@VM_0_17_centos ~]$ db2 connect to hnsale user nbadv using nbadv


   Database Connection Information


 Database server        = DB2/LINUXX8664 9.7.0
 SQL authorization ID   = NBADV
 Local database alias   = HNSALE
[db2inst1 @ VM_0_17_centos〜] $ db2“CREATE TABLE TEST(ID VARCHAR(12),NAME VARCHAR(12))”
DB20000I SQL命令成功完成。
[db2inst1 @ VM_0_17_centos〜] $ db2“insert into test values(1111,22222)”
DB20000I SQL命令成功完成。
[db2inst1 @ VM_0_17_centos〜] $ db2“select * from test”
ID NAME        
------------ ------------
1111 22222       

 

  已选择1条记录。

[db2inst1 @ VM_0_17_centos〜] $ db2 froce application all

[db2inst1 @ VM_0_17_centos〜] $ db2   “drop db hnsale”

[db2inst1 @ VM_0_17_centos〜] $ su - root

[root @ VM_0_17_centos〜] $./opt/ibm/db2/V9.7/instance / db2idrop db2inst1

卸载软件,及删除创建的用户及用户组

1)开始卸载db2安装软件
cd /opt/ibm/db2/V9.7/install
./db2_deinstall -a
2)删除OS系统用户
userdel -d username
groupdel groupname
3)删除db2数据库安装目录

可能遇到的问题及解决办法:

1)如果安装过程中报如下错误,可以不用管,不影响安装和使用(某些没用用到的数据库组件需要这些包):

$./db2setup 
需求与 DB2 数据库 "Server"  不匹配。版本:"11.1.3.3"。

当前系统上未满足的先决条件的摘要:

DBT3514W  db2prereqcheck 实用程序未能找到以下 32 位库文件:"/lib/libpam.so*"。 
DBT3514W  db2prereqcheck 实用程序未能找到以下 32 位库文件:"libstdc++.so.6"。

2)执行$db2set DB2COMM=TCPIP 报如下错误:

  DBI1309E System error. 
  Explanation: 
  The tool encountered an operating system error. 
  User response: 
  A system error was encountered during registry access. Ensure that there 
  is enough space on the file system where the registry is located, and 
  that there is a valid LAN connection if the registry is remote.

应该是实例用户某些文件夹的权限不够,关闭selinux ,同时/var 和 /var/db2 及下边的文件设置X权限即可解决

 

 

你可能感兴趣的:(java,web,db2,服务器)