Chinaunix首页 | 论坛 | 博客
  • 博客访问: 77822
  • 博文数量: 15
  • 博客积分: 1420
  • 博客等级: 上尉
  • 技术积分: 160
  • 用 户 组: 普通用户
  • 注册时间: 2007-07-12 18:50
文章分类

全部博文(15)

文章存档

2010年(2)

2009年(1)

2007年(12)

我的朋友

分类:

2007-07-26 16:55:05

安装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         =
 
阅读(1286) | 评论(0) | 转发(0) |
给主人留下些什么吧!~~