当前位置:数据库 > DB2 >>

怎么在linux上咱装DB2

刚刚接触DB2,想在linux上搭个DB2的环境做练习用。不知道该怎么装,哪位高手给个详细的步骤。 谢谢!!
答案:我网上复制来的,可以稍微看下,其实DB2也有安装脚本的

安装DB2 
DB2的安装可以算是再各个数据库里面最简单的了。除了sqlite。
下载安装包,解压
[root@Enterprise tmp]# tar xvf DB2_V82_PE_LNX_32_NLV.tar
解开以后的文件都被放置在当前目录下的pe文件夹中。  
开始安装:  
[root@Enterprise tmp]# cd pe
[root@Enterprise pe]# ls
db2  db2_deinstall  db2_install  db2setup  doc
[root@Enterprise pe]# ./db2_install
Specify one or more of the following keywords,
separated by spaces, to install DB2 products.

选择自己要安装的产品,输入名字后回车。等待安装完成。
我们现在需要做的是,对数据库的初始化工作。包括安装授权文件和创建一个实例并运行它。  
首先,我们安装授权文件。  
不安装授权文件的话,则是评估版,九十天后就要过期。授权文件,在安装包已经有了。我们用下面的命令安装它:  
[root@Enterprise pe]# /opt/IBM/db2/V8.2/adm/db2licm -a /tmp/pe/db2/lic
ense/db2pe.lic  
如果没有db2pe.lic  文件。可以去网上找找。
我们需要创建一个用户。  
[root@Enterprise pe]# useradd db2inst1  
[root@Enterprise pe]# passwd db2inst1 

开始创建实例:  
[root@Enterprise pe]# /opt/IBM/db2/V8.2/instance/db2icrt -u db2inst1 db2inst1  
这样,我们就创建了一个实例db2ins1。  

[root@Enterprise pe]# su db2inst1
[db2inst1@Enterprise pe]$ db2start
07/26/2007 16:45:10     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

这样我们数据库就启动成功。
[db2inst1@Enterprise pe]$ db2
(c) Copyright IBM Corporation 1993,2002
Command Line Processor for DB2 SDK 8.2.0
You can issue database manager commands and SQL statements from the command
prompt. For example:
    db2 => connect to sample
    db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
 ? CATALOG DATABASE for help on the CATALOG DATABASE command
 ? CATALOG          for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
db2 =>

创建一个最简单的数据库
db2 => create database testdb
DB20000I  The CREATE DATABASE command completed successfully.

查看本instance下有哪些database
db2 => list database directory
 System Database Directory
 Number of entries in the directory = 2
Database 1 entry:
 Database alias                       = TESTDB
 Database name                        = TESTDB
 Local database directory             = /home/db2inst1
 Database release level               = a.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =
Database 2 entry:
 Database alias                       = OMNIDB
 Database name                        = OMNIDB
 Local database directory             = /home/db2inst1/data
 Database release level               = a.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

上一个:db2 java 创建临时表报错
下一个:IBM的Lotus, WebSphere, DB2, Rational, Tivoli五大品牌都是用来做什么的?

CopyRight © 2022 站长资源库 编程知识问答 zzzyk.com All Rights Reserved
部分文章来自网络,