首页 > 数据库 >db2安装部署

db2安装部署

时间:2024-01-24 13:56:37浏览次数:35  
标签:DB2 db2inst1 Task 部署 host135 install db2 安装

环境:
OS:Centos 7
DB:v11.5.6

1.解压
[root@host135 db2]# tar -xvf v11.5.6_linuxx64_server_dec.tar.gz
[root@host135 db2]# mv server_dec /opt/db2

 

2.检查安装环境
[root@host135 db2]# ./db2prereqcheck

 

3.安装依赖包
yum install libstdc++*
yum install pam*
yum groupinstall 'Infiniband Support'
yum install gcc
yum install cpp
yum install gcc-c++
yum install kernel-devel
yum install ksh
yum install ntp
yum install sg3_utils
yum install pam32*
yum install libcxgb*
yum install m4
yum install binutils-devel
yum install patch
yum install -y pam*
yum install libnuma*
yum install libstdc++.so.6
yum install pam.i686

 

4.关闭selinux
#vi /etc/selinux/config
修改如下:
SELINUX=disabled#

 

5.修改系统内核参数
# vi /etc/sysctl.conf
kernel.shmmax = 8589934592 --设置为物理内存的一半或稍大
kernel.shmall = 67108864
kernel.shmmni = 4096
kernel.sem = 250 32000 100 128
fs.file-max = 65536
net.ipv4.ip_local_port_range = 1024 65000
net.core.rmem_default=262144
net.core.rmem_max=262144
net.core.wmem_default=262144
net.core.wmem_max=262144

 

6.安装

[root@host135 db2]# cd /opt/db2
./db2_install
[root@host135 db2]# ./db2_install
Requirement not matched for DB2 database "Server" . Version: "11.5.6.0". 

Summary of prerequisites that are not met on the current system: 

   DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/libpam.so*". 


DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.6". 


Read the license agreement file in the db2/license directory.

***********************************************************
To accept those terms, enter "yes". Otherwise, enter "no" to cancel the install process. [yes/no]
yes
 
 
Default directory for installation of products - /opt/ibm/db2/V11.5

***********************************************************
Install into default directory (/opt/ibm/db2/V11.5) ? [yes/no] 
Specify one of the following keywords to install DB2 products.

  SERVER 
  CONSV 
  CLIENT 
  RTCL 
 
Enter "help" to redisplay product names.

Enter "quit" to exit.

***********************************************************
SERVER
***********************************************************
Do you want to install the DB2 pureScale Feature? [yes/no] 
no
Requirement not matched for DB2 database "Server" . Version: "11.5.6.0". 

Summary of prerequisites that are not met on the current system: 

   DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/libpam.so*". 


DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.6". 


DB2 installation is being initialized.

 Total number of tasks to be performed: 55 
Total estimated time for all tasks to be performed: 2315 second(s) 

Task #1 start
Description: Checking license agreement acceptance 
Estimated time 1 second(s) 
Task #1 end 

Task #2 start
Description: Base Client Support for installation with root privileges 
Estimated time 3 second(s) 
Task #2 end 

Task #3 start
Description: Product Messages - English 
Estimated time 14 second(s) 
Task #3 end 

Task #4 start
Description: Base client support 
Estimated time 355 second(s) 

Task #5 start
Description: Java Runtime Support 
Estimated time 217 second(s) 
Task #5 end 

Task #6 start
Description: Java Help (HTML) - English 
Estimated time 7 second(s) 
Task #6 end 

Task #7 start
Description: Base server support for installation with root privileges 
Estimated time 6 second(s) 
Task #7 end 

Task #8 start
Description: Global Secure ToolKit 
Estimated time 76 second(s) 
Task #8 end 

Task #9 start
Description: Java support 
Estimated time 11 second(s) 
Task #9 end 

Task #10 start
Description: SQL procedures 
Estimated time 3 second(s) 
Task #10 end 

Task #11 start
Description: ICU Utilities 
Estimated time 59 second(s) 
Task #11 end 

Task #12 start
Description: Java Common files 
Estimated time 18 second(s) 
Task #12 end 

Task #13 start
Description: Base server support 
Estimated time 582 second(s) 

安装选项说明:
SERVER : Install DB2 server product
CONSV : Install DB2 Connect
CLIENT : Install DB2 client
RTCL : Install DB2 runtime client

 

6.创建实例说明
a.要在Linux服务器上创建 DB2 实例,您需要2个操作系统用户(实例 id 和受保护的 id),该用户未与任何其他 DB2 实例映射;
b.DB2实例用户名的长度不应超过8个字符。如果您想对 DB2 实例使用超过 8 个字符长的用户名,请确保您的操作系统支持长ID;
c.DB2 实例用户名不能是 GUESTS、LOCAL、PUBLIC、USERS、ADMINS。不能以 IBM、SQL、SYS 开头创建操作系统用户;

[root@host135 instance]#groupadd gdb2iadm1                   
[root@host135 instance]#groupadd gdb2fadm1                                         
[root@host135 instance]#useradd db2inst1 -G gdb2iadm1          
[root@host135 instance]#useradd db2fenc1 -G gdb2fadm1       
[root@host135 instance]#cd /opt/ibm/db2/V11.5/instance
[root@host135 instance]# ./db2icrt -a server -p 50000 -u db2fenc1 db2inst1
DBI1446I  The db2icrt command is running.


DB2 installation is being initialized.

 

7.激活license
以下操作全部以 db2inst1 用户执行查看license信息

[root@host135 instance]# su - db2inst1                                 
[db2inst1@host135 ~]$ db2licm -l
Product name:                     "DB2 Community Edition"
License type:                     "Community"
Expiry date:                      "Permanent"
Product identifier:               "db2dec"
Version information:              "11.5"
Max amount of memory (GB):        "16"
Max number of cores:              "4"
Features:
IBM DB2 Performance Management Offering:              "Not licensed"





license激活
[root@host135 ~]# find / -name db2ese_c.lic
[root@host135 ~]# find / -name *.lic       
/opt/db2/db2/linuxamd64/tsamp/license/sam41.lic
/opt/db2/db2/license/db2dec.lic
/opt/db2/db2/license/db2consv_t.lic
/opt/db2/db2/license/db2ese_t.lic
/opt/db2/db2/license/db2trial.lic
/opt/ibm/db2/V11.5/.licbkup/lic00000001.lic


db2ese_t.lic      DB2 Enterprise Server Edition(试用)
db2dec.lic        Db2 Community Edition (非生产)
db2consv_t.lic    Db2 Connect Server Edition (试用)
db2trial.lic:   Db2 Advanced Edition 90 天試用軟體授權

执行激活
[db2inst1@host135 ~]$ db2licm -a /opt/db2/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/V11.5/license/en_US.iso88591"

再次查看授权信息
[db2inst1@host135 ~]$ db2licm -l
Product name:                     "DB2 Enterprise Server Edition"
License type:                     "Trial"
Expiry date:                      "04/22/2024"
Product identifier:               "db2ese"
Version information:              "11.5"

Product name:                     "DB2 Community Edition"
License type:                     "Community"
Expiry date:                      "Permanent"
Product identifier:               "db2dec"
Version information:              "11.5"
Max amount of memory (GB):        "16"
Max number of cores:              "4"
Features:
IBM DB2 Performance Management Offering:              "Not licensed"

 

8.启动

su - db2inst1
[db2inst1@host135 sqllib]$ which db2start
~/sqllib/adm/db2start
[db2inst1@host135 sqllib]$ db2start
01/24/2024 09:58:29     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

 

9.查看端口

[db2inst1@host135 sqllib]$ ss -nlp|grep 50000
tcp    LISTEN     0      128       *:50000                 *:*                   users:(("db2sysc",pid=20530,fd=6))

 

10.创建数据库

[root@host135 instance]# su - db2inst1
[db2inst1@host135 ~]$ db2 create db db_hxl using codeset utf-8 territory CN
SQL1043C  Database Services could not initialize the system catalogs.  Error 
"-902" was returned.

再次执行就可以成功
[db2inst1@host135 ~]$ db2 create db db_hxl using codeset utf-8 territory CN


DB20000I  The CREATE DATABASE command completed successfully.

 

11.链接数据库并创建表

[db2inst1@host135 ~]$ db2 connect to db_hxl
db2 "
create table tb_test(
    id bigint not null generated by default as identity (start with 1,increment by 1),
    name varchar(20),
    user_ages int
)
"

DB20000I  The SQL command completed successfully.

查看库中的表
[db2inst1@host135 ~]$ db2 list tables

Table/View                      Schema          Type  Creation time             
------------------------------- --------------- ----- --------------------------
TB_TEST                         DB2INST1        T     2024-01-24-10.58.45.374637

  1 record(s) selected.
  
查看表结构
[db2inst1@host135 ~]$ db2 describe table tb_test

                                Data type                     Column
Column name                     schema    Data type name      Length     Scale Nulls
------------------------------- --------- ------------------- ---------- ----- ------
ID                              SYSIBM    BIGINT                       8     0 No    
NAME                            SYSIBM    VARCHAR                     20     0 Yes   
USER_AGES                       SYSIBM    INTEGER                      4     0 Yes   

  3 record(s) selected.
  
  
写入数据
db2 "
insert into tb_test(name,user_ages) values('test01',10);
"

查询数据
db2 "
select * from tb_test;
"
ID                   NAME                 USER_AGES  
-------------------- -------------------- -----------
                   2 test01                        10

  1 record(s) selected.

 

12.创建账号并赋予权限

DB2没有数据库级别的用户,只能使用操作系统级别的用户;所以要新建DB2用户,要先在数据库服务器上新建操作系统用户.
例如要给数据库新建一个testuser用户
su - root
useradd testuser
passwd testuser

登录原来创建实例账户登录进行授权
[root@host135 tmp]# su - db2inst1
[db2inst1@host135 ~]$ db2 connect to db_hxl

授权
[db2inst1@host135 ~]$ db2 grant connect,DBADM on database to user testuser
DB20000I  The SQL command completed successfully.

使用testuser进行登录
[db2inst1@host135 ~]$ db2 connect to db_hxl user testuser using testuser

   Database Connection Information

 Database server        = DB2/LINUXX8664 11.5.6.0
 SQL authorization ID   = TESTUSER
 Local database alias   = DB_HXL

查询数据
db2 "
select * from db2inst1.tb_test;
"

[db2inst1@host135 ~]$ db2 "
> select * from db2inst1.tb_test;
> "

ID                   NAME                 USER_AGES  
-------------------- -------------------- -----------
                   2 test01                        10

  1 record(s) selected.

这里查询需要带上用户

 

标签:DB2,db2inst1,Task,部署,host135,install,db2,安装
From: https://www.cnblogs.com/hxlasky/p/17984526

相关文章

  • Ubuntu安装Ansible AWX
    环境:AWSEC2,UbuntuServer22.04+桌面环境1.-安装dockersudoaptinstallapt-transport-httpsca-certificatescurlsoftware-properties-commoncurl-fsSLhttps://download.docker.com/linux/ubuntu/gpg|sudoapt-keyadd-sudoadd-apt-repository"deb[arch=amd64]......
  • 源码包的部署
    例:安装nginx1、解压nginx[root@fishman-160~]#tar-zxvfnginx-1.25.1.tar.gz2、编译[[email protected]]#./configure--prefix=/usr/local/nginx#prefiex指定安装路径checkingforOS+Linux4.18.0-500.el8.x86_64x86_64checkingforCcompiler........
  • DataGrip 2023.3.2 安装教程(附最新激活码,亲测有效)
    DataGrip是JetBrains公司开发的一款多引擎数据库环境,支持MySQL,MariaDB,PostgreSQL,SQLite,HyperSQL,ApacheDerby,H2,HSQLDB,MSSQLServer,Oracle,DB2,InterSystemsCache,Informix,Firebird,Derby和SQLServerExpress。它提供了单一的、集成的开发环境,用于......
  • SublimeText(下载、安装和设置)
    1.下载和注册SublimeText4107下载链接:https://download.sublimetext.com/sublime_text_build_4107_x64_setup.exe—–BEGINLICENSE—–MifengUserSingleUserLicenseEA7E-1184812C0DAA9CD6BE825B5FF9356921750523AEDF59D3FA3BD6C96F8D338663F1CCCEA1C25BE4D......
  • centos7部署kafka服务
    centos7下面安装kafka服务,用于自己测试1.安装JAVA环境yum-yinstalljava-1.8.0-openjdk2.下载代码curl-okafka_2.13-3.6.1.tgzhttps://downloads.apache.org/kafka/3.6.1/kafka_2.13-3.6.1.tgz3.更改配置运行tar-xfkafka_2.13-3.6.1.tgzcdkafka_2.13-3.6.1se......
  • Fedora使用dnf安装package的时候遇到报错:Curl error (37): Couldn't read a file:// f
    问题描述在使用dnf包管理器下载软件包的过程中,多次遇到了以下错误Curlerror(37):Couldn'treadafile://fileforfile:///etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64[Couldn'topenfile/etc/pki/rpm-gpg/RPM-GPG-KEY-fedora-x86_64]系统是新配置的Fedora39WorkSt......
  • Vite安装React TS Tailwind项目
    安装Vitenpminstallvite@latest或者yarncreatevite##Vite安装React项目+TS安装完vite之后,我们就可以使用vite来创建项目了,vite为我们提供了很多模版,我们只需要选择我们需要的就可以了。我们可以在创建项目的时候在命令当中指定对应的模版。```sh#npm安装npm......
  • VMware虚拟机部署Linux Ubuntu系统的方法
      本文介绍基于VMwareWorkstationPro虚拟机软件,配置LinuxUbuntu操作系统环境的方法。  首先,我们需要进行VMwareWorkstationPro虚拟机软件的下载与安装。需要注意的是,VMwareWorkstationPro软件是一个收费软件,而互联网中有很多可以下载后直接免费激活、使用这一软件的方......
  • 服务器上mysql安装 ,以及客户端Navicat连接
    1.官网下载mysql8.0https://dev.mysql.com/downloads/installer/ 2.安装mysql8.0参考https://blog.csdn.net/weixin_47406082/article/details/131867849?ops_request_misc=&request_id=&biz_id=102&utm_term=mysql%E6%9C%80%E6%96%B0%E7%89%88%E5%AE%89%E8%A3%85%E......
  • docker安装pg(postgresql)
    拉取镜像dockerpullpostgres:15.5创建本地卷或创建挂载目录(/docker/postgresql/data)dockervolumecreatepgdata数据卷可以在容器之间共享和重用,默认会一直存在,即使容器被删除(dockervolumeinspectpgdata可查看数据卷的本地位置,如果使用该方式创建可查看创建成功......