Linux命令行安装Db2

19 篇文章 0 订阅

环境

  • 操作系统: Ubuntu 20.04
  • Db2 image: v11.5.0_linuxx64_server.tar.gz

安装和配置

解压文件 tar -zxvf v11.5.0_linuxx64_server.tar.gz ,生成 server 目录。

进入 server 目录,如下:

➜  server ls
db2  db2checkCOL_readme.txt  db2checkCOL.tar.gz  db2ckupgrade  db2_deinstall  db2_install  db2ls  db2prereqcheck  db2setup  installFixPack

在安装之前,可以先运行 db2prereqcheck 检查一下:

➜  server ./db2prereqcheck 

==========================================================================

Wed Mar 30 14:47:48 2022
Checking prerequisites for DB2 installation. Version "11.5.0.0". Operating system "Linux" 
   
Validating "Linux distribution " ... 
   Required minimum "UBUNTU" version: "16.04" 
   Actual version: "20.04" 
   Requirement matched. 
   
Validating "kernel level " ... 
   Required minimum operating system kernel level: "3.10.0". 
   Actual operating system kernel level: "5.13.0". 
   Requirement matched. 
   
Validating "C++ Library version " ... 
   Required minimum C++ library: "libstdc++.so.6" 
   Standard C++ library is located in the following directory: "/usr/lib/x86_64-linux-gnu/libstdc++.so.6.0.28". 
   Actual C++ library: "CXXABI_1.3.1" 
   Requirement matched. 
   
Validating "32 bit version of "libstdc++.so.6" " ... 
   Found the 64 bit "/lib/x86_64-linux-gnu/libstdc++.so.6" in the following directory "/lib/x86_64-linux-gnu". 
DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "libstdc++.so.6". 

Validating "libaio.so version " ... 
DBT3553I  The db2prereqcheck utility successfully loaded the libaio.so.1 file. 
   Requirement matched. 
   
Validating "libnuma.so version " ... 
DBT3610I  The db2prereqcheck utility successfully loaded the libnuma.so.1 file. 
   Requirement matched. 
   
Validating "/lib/i386-linux-gnu/libpam.so*" ... 
   DBT3514W  The db2prereqcheck utility failed to find the following 32-bit library file: "/lib/i386-linux-gnu/libpam.so*". 
   WARNING : Requirement not matched. 
Requirement not matched for DB2 database "Server" . Version: "11.5.0.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/i386-linux-gnu/libpam.so*". 

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

............

DBT3555E  The db2prereqcheck utility determined that the current platform is not supported by the following version: "9.8.0.4". 
DBT3555E  The db2prereqcheck utility determined that the current platform is not supported by the following version: "9.8.0.3". 
DBT3555E  The db2prereqcheck utility determined that the current platform is not supported by the following version: "9.8.0.2". 

中间省略的部分是对其它Db2版本的检查,从 11.1.9.010.1.0.0 ,检查结果和 11.5.0.0 基本一样。

  • DBT3514W :以 W 结尾,表示warning,此处是说 libstdc++.so.6libpam.so* 有点问题;
  • DBT3555E :以 E 结尾,表示error,此处应该是指不支持Db2版本 9.8.0.4 (以及更低的版本);

对于 libstdc++.so.6libpam.so* ,可以去处理一下,消除warning,但也可以不予理会,暂时没发现对安装和使用Db2有什么影响……

注:如果遇到如下错误:

ERROR:
   The 'strings' utility that is used to detect prerequisite libraries
   is not present on this system.  Please use your package or software
   manager to install the GNU Binary Utilities.

解决方法是安装 build-essential 。运行如下命令:

apt install build-essential

安装好以后,再次运行 db2prereqcheck 检查一下。

接下来,切换到 root 。如果不切换:

  • Db2会安装在当前用户的home目录,无法设置;
  • 安装之后,也会遇到问题,我没具体研究,可能也有办法解决,不过为了避免不必要的麻烦,还是切换到root来安装吧;

运行 db2_install

➜  server ./db2_install 
Requirement not matched for DB2 database "Server" . Version: "11.5.0.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/i386-linux-gnu/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]

首先提示了 DBT3514W 的warning,然后让你接受license,此时输入 yes 回车即可。

接下来让你选择安装目录:

Default directory for installation of products - /opt/ibm/db2/V11.5

***********************************************************
Install into default directory (/opt/ibm/db2/V11.5) ? [yes/no] 

输入 yes ,并回车。

接下来让你选择安装产品:

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 ,并回车。

选择是否安装purescale:

Do you want to install the DB2 pureScale Feature? [yes/no] 

输入 no ,并回车。

最后是总结,并安装Db2:

Requirement not matched for DB2 database "Server" . Version: "11.5.0.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/i386-linux-gnu/libpam.so*". 


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

DB2 installation is being initialized.

............

The execution completed with warnings.

For more information see the DB2 installation log at
"/tmp/db2_install.log.53975".

无需交互,看着安装程序刷屏,一小会儿就好了。

接下来配置Db2用户:

➜  ~ groupadd -g 2000 db2iadm1
➜  ~ groupadd -g 2001 db2fadm1
➜  ~ useradd -m -g db2iadm1 -d /home/db2inst1 db2inst1
➜  ~ useradd -m -g db2fadm1 -d /home/db2fenc1 db2fenc1
➜  ~ passwd db2inst1
New password: 
Retype new password: 
passwd: password updated successfully
➜  ~ passwd db2fenc1
New password: 
Retype new password: 
passwd: password updated successfully

来到安装目录 /opt/ibm/db2/V11.5/instance ,运行:

chmod -R 755 *

接下来运行:

./db2icrt -p 50000 -u db2fenc1 db2inst1

接下来切到 db2inst1 用户,并创建 SAMPLE 数据库:

$ 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.

查看DB:

$ db2 list db directory

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/db2inst1
 Database release level               = 15.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

查看Db2版本:

$ db2level
DB21085I  This instance or install (instance name, where applicable: 
"db2inst1") uses "64" bits and DB2 code release "SQL11050" with level 
identifier "0601010F".
Informational tokens are "DB2 v11.5.0.0", "s1906101300", "DYN1906101300AMD64", 
and Fix Pack "0".
Product is installed at "/opt/ibm/db2/V11.5".

启动Db2:

$ db2start
03/30/2022 14:39:21     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

连接到 SAMPLE 数据库:

$ db2 connect to sample

   Database Connection Information

 Database server        = DB2/LINUXX8664 11.5.0.0
 SQL authorization ID   = DB2INST1
 Local database alias   = SAMPLE

运行SQL:

$ db2 "select * from sysibm.sysdummy1"

IBMREQD
-------
Y      

  1 record(s) selected.

大功告成!

  • 3
    点赞
  • 8
    收藏
    觉得还不错? 一键收藏
  • 3
    评论
### 回答1: 在Linux安装DB2,可以按照以下步骤进行: 1. 下载DB2安装包,可以从IBM官网下载。 2. 解压安装包,进入解压后的目录。 3. 执行安装程序,可以使用命令行或者图形界面进行安装。 4. 在安装过程中,需要选择安装路径、创建DB2实例等配置信息。 5. 安装完成后,需要进行初始化操作,包括创建DB2实例、配置数据库等。 6. 最后,可以使用DB2命令行或者图形界面管理数据库。 需要注意的是,在安装和配置过程中,需要按照官方文档进行操作,避免出现错误。 ### 回答2: DB2是一个非常流行的关系型数据库管理系统,在Linux安装DB2是非常方便的。下面是步骤: 1. 下载DB2安装包。可以在IBM的官网上下载所需版本的安装包。 2. 安装依赖包。安装DB2需要一些依赖包,可以通过以下命令来安装: ``` sudo apt-get update sudo apt-get install libpam0g:i386 libaio1 numactl ``` 3. 安装DB2。将下载的DB2安装包解压缩后,进入文件夹并运行安装程序。在开始安装前,需要选择安装方式(典型安装或自定义安装),以及安装目录等。 4. 配置DB2实例。安装完成后,运行“db2setup”命令,并选择创建数据库实例。在这一步中,需要设置实例名称、端口号、管理权限密码等。完成后,会生成一个实例目录。 5. 启动DB2。运行以下命令来启动DB2: ``` db2start ``` 6. 连接到DB2实例。运行以下命令来连接到DB2: ``` db2 connect to <实例名称> ``` 这些就是在Linux安装DB2的主要步骤。在安装过程中,可以参考DB2安装文档,以便更加详细地了解每个步骤的操作方法。安装完成后,可以使用db2指令来管理数据库。 ### 回答3: DB2是一款流行的关系型数据库管理系统,支持多种操作系统平台。在Linux安装DB2可以提供高效的数据库管理和性能,以满足企业的业务需求。为了在Linux平台上安装DB2,可以采用如下步骤: 首先,在IBM官网上下载DB2安装包,例如db2_v11.5fp5_linuxx64_server_t.tar.gz,其中11.5表示DB2版本号,fp5表示补丁版本号,linuxx64表示Linux 64位平台。 下载后,使用tar命令解压缩安装包文件,例如tar -xf db2_v11.5fp5_linuxx64_server_t.tar.gz。 进入解压后的目录,例如cd server_t目录,运行db2setup命令,开始DB2安装向导。 在安装向导中,选择需要安装的组件,例如Server或者Client,根据需要进行选择。 设置DB2实例的名称、安装路径、用户和用户组等参数,保证其与系统环境兼容。 设置DB2数据库的管理员密码和其他配置信息,例如数据库监听端口、时间区域等。 在安装向导完成后,根据需要启动或者停止DB2实例,例如使用db2start命令启动、db2stop命令停止。 最后,可以进行DB2的配置和管理,例如创建用户、数据库和表等操作,以及备份、恢复和性能优化等。 总之,在Linux安装DB2需要了解其基本的安装步骤和相关参数设置,以便在企业中进行高效的数据库管理和应用开发。同时,还需要了解DB2的相关技术特点和应用实践,以满足企业的业务需求和技术挑战。

“相关推荐”对你有帮助么?

  • 非常没帮助
  • 没帮助
  • 一般
  • 有帮助
  • 非常有帮助
提交
评论 3
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

当前余额3.43前往充值 >
需支付:10.00
成就一亿技术人!
领取后你会自动成为博主和红包主的粉丝 规则
hope_wisdom
发出的红包
实付
使用余额支付
点击重新获取
扫码支付
钱包余额 0

抵扣说明:

1.余额是钱包充值的虚拟货币,按照1:1的比例进行支付金额的抵扣。
2.余额无法直接购买下载,可以购买VIP、付费专栏及课程。

余额充值