rhel5.8安装DB2V9.7

安装说明:本次安装DB2,采用文字界面交互式安装
前提条件:已安装配置好RHEL5.8系统,从IBM官网下载v9.7_linuxx64_server.tar.gz软件,并上传到系统

一、解压安装包,执行安装

[root@db27v2 Share]# cd /software/
[root@db27v2 software]# ll
total 778332
-rwxr-xr-x 1 root root 796228675 Jan 10 16:31 v9.7_linuxx64_server.tar.gz
[root@db27v2 software]# gunzip v9.7_linuxx64_server.tar.gz
[root@db27v2 software]# ll
total 881256
-rwxr-xr-x 1 root root 901519360 Jan 10 16:31 v9.7_linuxx64_server.tar
[root@db27v2 software]# tar -xf v9.7_linuxx64_server.tar
[root@db27v2 software]# ll
total 881260
drwxr-xr-x 4 root root      4096 Oct 22  2011 server
-rwxr-xr-x 1 root root 901519360 Jan 10 16:31 v9.7_linuxx64_server.tar
[root@db27v2 software]# cd server/
[root@db27v2 server]# ll
total 64
drwxr-xr-x  6 bin bin 4096 Oct 22  2011 db2
-r-xr-xr-x  1 bin bin 5340 Oct 22  2011 db2ckupgrade
-r-xr-xr-x  1 bin bin 5293 Oct 22  2011 db2_deinstall
-r-xr-xr-x  1 bin bin 5163 Oct 22  2011 db2_install
-r-xr-xr-x  1 bin bin 5127 Oct 22  2011 db2ls
-r-xr-xr-x  1 bin bin 5145 Oct 22  2011 db2prereqcheck
-r-xr-xr-x  1 bin bin 5145 Oct 22  2011 db2setup
drwxr-xr-x 15 bin bin 4096 Oct 22  2011 doc
-r-xr-xr-x  1 bin bin 5181 Oct 22  2011 installFixPack
[root@db27v2 server]# ./db2_install
 
Default directory for installation of products - /opt/ibm/db2/V9.7

***********************************************************
Do you want to choose a different directory to install [yes/no] ?
no
 
 
Specify one of the following keywords to install DB2 products.

  AESE
  ESE
  CONSV
  WSE
  EXP
  PE
  CLIENT
  RTCL
 
Enter "help" to redisplay product names.

Enter "quit" to exit.

***********************************************************
aese    (DB2 Advanced Enterprise Server Edition)
DB2 installation is being initialized.

 Total number of tasks to be performed: 49
Total estimated time for all tasks to be performed: 2006

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

...........

The execution completed successfully.

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

出现上面的信息,软件安装完成。


二、创建DB2运行所需的组和用户,并设置密码:

[root@db27v2 ~]# groupadd -g 1001 db2grp
[root@db27v2 ~]# groupadd -g 1002 db2fgrp
[root@db27v2 ~]# groupadd -g 1003 db2agrp
[root@db27v2 ~]# useradd -g db2grp -u 1001 -d /home/db2inst1 -m -s /bin/bash db2inst1
[root@db27v2 ~]# useradd -g db2fgrp -u 1002 -d /home/db2fenc -m -s /bin/bash db2fenc
[root@db27v2 ~]# useradd -g db2agrp -u 1003 -d /home/db2das -m -s /bin/bash db2das
[root@db27v2 ~]# passwd db2inst1
Changing password for user db2inst1.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@db27v2 ~]# passwd db2fenc
Changing password for user db2fenc.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.
[root@db27v2 ~]# passwd db2das
Changing password for user db2das.
New UNIX password:
Retype new UNIX password:
passwd: all authentication tokens updated successfully.


三、创建实例

注释:
Dascrt:创建的是DB2 adminstration server,每台服务器只有一个这种server,为进行DB2管理(比如运行控制中心)所必须,

同时指定其管理用户是db2das。
db2icrt:创建的是实例,其名字一般和管理用户名一样,这里均为db2inst1。

[root@db27v2 instance]# pwd
/opt/ibm/db2/V9.7/instance
[root@db27v2 instance]# ./dascrt -u db2das
SQL4406W  The DB2 Administration Server was started successfully.
DBI1070I  Program dascrt completed successfully.

[root@db27v2 instance]# ./db2icrt -u db2inst1 db2inst1
DBI1070I  Program db2icrt completed successfully.

四、启动DB2

1、启动DB2管理服务器
[root@db27v2 ~]# su - db2das
[db2das@db27v2 ~]$ db2admin start
SQL4409W  The DB2 Administration Server is already active.

2、启动数据库实例
[root@db27v2 ~]# su - db2inst1
[db2inst1@db27v2 ~]$ db2start
01/10/2016 17:05:10     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

3、查看DB2是否成功启动
[root@db27v2 instance]# ps -ef | grep db2


五、配置DB2数据库

1、DB2自启动
[root@db27v2 instance]# pwd
/opt/ibm/db2/V9.7/instance
[root@db27v2 instance]# ./db2iauto -on db2inst1

2、网络配置
[db2inst1@db27v2 ~]$ db2 update dbm cfg using svcename 50000    ----改变DB2的远程访问端口,默认是5000
DB20000I  The UPDATE DATABASE MANAGER CONFIGURATION command completed
successfully.
[db2inst1@db27v2 ~]$ db2set db2comm=tcpip    ----修改DB2的连接方式为TCPIP

注意:也可以通过JDBC,ODBC等方式来访问DB2数据库


六、启动和关闭实例

[db2inst1@db27v2 ~]$ db2 force applications all        ----关闭所有和DB2相关的应用程序
DB20000I  The FORCE APPLICATION command completed successfully.
DB21024I  This command is asynchronous and may not be effective immediately.

[db2inst1@db27v2 ~]$ db2stop    ----关闭数据库实例
01/10/2016 17:16:20     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.
[db2inst1@db27v2 ~]$ db2start    ----启动数据库实例
01/10/2016 17:16:29     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.


七、创建一个测试数据库

[db2inst1@db27v2 ~]$ db2 create database test
DB20000I  The CREATE DATABASE command completed successfully.
[db2inst1@db27v2 ~]$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 9.7.5

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 => connect to test user db2inst1
Enter current password for db2inst1:

   Database Connection Information

 Database server        = DB2/LINUXX8664 9.7.5
 SQL authorization ID   = DB2INST1
 Local database alias   = TEST

db2 =>


八、创建演示数据库

[db2inst1@db27v2 bin]$ pwd
/opt/ibm/db2/V9.7/bin
[db2inst1@db27v2 bin]$ ./db2sampl

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

  'db2sampl' processing complete.

[db2inst1@db27v2 ~]$ db2
....

db2 => connect to sample

   Database Connection Information

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

db2 =>

常用操作命令
db2 =>connect to sample                          ---连接到sample数据库
db2 =>list tables                                 ---查看库下面的所有表
db2 => select * from staff where dept=10             ---查询某张表dept等于10的所有记录
db2 => quit                                     ---退出db2
DB20000I  The QUIT command completed successfully.
 
$ db2ilist;                                      ---查看实例列表
db2inst1
 
$ db2 get instance                               ---查看当前所运行的实例
 
 The current database manager instance is:  db2inst1

来自 “ ITPUB博客 ” ,链接:http://blog.itpub.net/30373263/viewspace-1983501/,如需转载,请注明出处,否则将追究法律责任。

转载于:http://blog.itpub.net/30373263/viewspace-1983501/

评论
添加红包

请填写红包祝福语或标题

红包个数最小为10个

红包金额最低5元

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

抵扣说明:

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

余额充值