db2 9.7 for linux 5.4 安装详细步骤
时间:2016-10-28 23:15 来源:linux.it.net.cn 作者:IT
db2 9.7 for linux 5.4安装详细步骤
1、解压缩安装包
#gunzip v9.7_linuxia32_server.tar.gz
#tar -xvf v9.7_linuxia32_server.tar
2、进入解压后的文件目录,执行安装:(我们选择手动安装)
注意:DB2_install为手动安装 db2_setup为图形安装
www.2cto.com
#./Db2_install-------no-----aese
3、创建DB2运行所需的组和用户:
#groupadd -g 901 db2grp
#groupadd -g 902 db2fgrp
#groupadd -g 903 db2agrp
#useradd -g db2grp -u 801 -d /home/db2inst1-m -s /bin/bash db2inst1 --管理当前实例
#useradd -g db2fgrp -u 802 -d /home/db2fenc-m -s /bin/bash db2fenc
#useradd -g db2agrp -u 803 -d /home/db2das-m -s /bin/bash db2das --管理所有实例
4、设置密码:
passwd db2inst1
passwd db2fenc
passwd db2das
5、创建实例
#cd /opt/ibm/db2/V9.7/instance
#./dascrt -u db2das
#./db2icrt -u db2inst1 db2inst1
注意:DBI1922N The host name is not valid.报无法解析错误,在/etc/hosts文件中添加解析参数即可 www.2cto.com
注释:
Dascrt:创建的是DB2 adminstration server,每台服务器只有一个这种server,为进行DB2管理(比如运行控制中心)所必须,同时指定其管理用户是db2das。
db2icrt:创建的是实例,其名字一般和管理用户名一样,这里均为db2inst1。
6、启动DB2
# su - db2das
$ db2admin start ----启动DB2管理服务器
SQL4409W The DB2 Administration Server is already active.
$su - db2inst1
$ db2start ----启动数据库实例
05/07/2012 01:30:04 0 0 SQL1063N DB2START processing was successful.
SQL1063N DB2START processing was successful.
7、检查DB2是否起来,状态如下:
[db2inst1@jetsen ~]$ ps -ef|grep db2
db2das 10828 1 0 01:23 ? 00:00:00 /home/db2das/das/adm/db2dasrrm
root 11345 1 0 01:23 ? 00:00:00 /opt/ibm/db2/V9.7/bin/db2fmcd
db2das 11354 1 0 01:23 ? 00:00:00/opt/ibm/db2/V9.7/das/bin/db2fmd -i db2das -m/opt/ibm/db2/V9.7/das/lib/libdb2dasgcf.so.1
root 17267 2768 0 01:29 pts/1 00:00:00 su - db2das
db2das 17268 17267 0 01:29 pts/1 00:00:00 -bash
root 17329 17268 0 01:29 pts/1 00:00:00 su - db2inst1
db2inst1 17332 17329 0 01:29 pts/1 00:00:00 -bash
root 17446 1 1 01:29 pts/1 00:00:01 db2wdog 0
db2inst1 17448 17446 1 01:29 pts/1 00:00:01 db2sysc 0
root 17449 17448 0 01:29 pts/1 00:00:00 db2ckpwd 0
root 17450 17448 0 01:29 pts/1 00:00:00 db2ckpwd 0 www.2cto.com
root 17451 17448 0 01:29 pts/1 00:00:00 db2ckpwd 0
db2inst1 17455 17448 1 01:30 pts/1 00:00:01 db2vend (PD Vendor Process -1)
db2inst1 17462 17446 0 01:30 pts/1 00:00:01 db2acd 0,0,0,0,1,0,0,0000,1,0,8a67a4,14,1e014,2,0,1,11fd0,0x125f0000,0x125f0000,1600000,588003,2,b5800b
db2inst1 17494 17332 0 01:32 pts/1 00:00:00 ps -ef
db2inst1 17495 17332 0 01:32 pts/1 00:00:00 grep db2
[db2inst1@jetsen ~]$
8、配置DB2自动启动,用root用户登录
#cd /opt/ibm/db2/V9.7/instance/
# ./db2iauto -on db2inst1
9、配置网络
#su - db2inst1
$db2 update dbm cfg using SVCENAME50000 ----改变DB2的远程访问端口,默认是5000
$db2set DB2COMM=TCPIP ----修改DB2的连接方式为TCPIP,
注意:也可以通过JDBC,ODBC等方式来访问DB2数据库
10、实例的启动和关闭
#su - db2inst1
$db2 force applications all ----关闭所有和DB2相关的应用程序
$db2stop ----关闭数据库实例
$db2start ----启动数据库实例
11、创建数据库
#su - db2inst1
$db2 create database test ----创建数据库实例
DB20000I The CREATE DATABASE command completed successfully.
12、连接到我们刚才创建的数据库
#su - db2inst1
$db2 www.2cto.com
db2 => Connect to test user db2inst1
Enter current password for db2inst1:
Database Connection Information
Database server = DB2/LINUX 9.7.5
SQLauthorization ID = DB2INST1
Local database alias = TEST
db2 =>
附录:
1、创建演示数据库
#su - db2inst1
$ $cd /opt/ibm/db2/V9.7/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.
2、访问刚创建的数据库
$ db2
www.2cto.com
db2 => connect to sample
Database Connection Information
Database server = DB2/LINUX 9.7.5
SQLauthorization ID = DB2INST1
Local database alias = SAMPLE
db2 =>
3、常用操作命令
db2 =>connect to sample ---连接到sample数据库
db2 =>list tables ---查看库下面的所有表
db2 => select * from staff wheredept=10 ---查询某张表dept等于10的所有记录
db2 => quit www.2cto.com ---退出db2
DB20000I The QUIT command completed successfully.
$ db2ilist; ---查看实例列表
db2inst1
$ db2 get instance ---查看当前所运行的实例
Thecurrent database manager instance is: db2inst1
(责任编辑:IT)
db2 9.7 for linux 5.4安装详细步骤 1、解压缩安装包 #gunzip v9.7_linuxia32_server.tar.gz #tar -xvf v9.7_linuxia32_server.tar 2、进入解压后的文件目录,执行安装:(我们选择手动安装) 注意:DB2_install为手动安装 db2_setup为图形安装 www.2cto.com #./Db2_install-------no-----aese 3、创建DB2运行所需的组和用户: #groupadd -g 901 db2grp #groupadd -g 902 db2fgrp #groupadd -g 903 db2agrp #useradd -g db2grp -u 801 -d /home/db2inst1-m -s /bin/bash db2inst1 --管理当前实例 #useradd -g db2fgrp -u 802 -d /home/db2fenc-m -s /bin/bash db2fenc #useradd -g db2agrp -u 803 -d /home/db2das-m -s /bin/bash db2das --管理所有实例 4、设置密码: passwd db2inst1 passwd db2fenc passwd db2das 5、创建实例 #cd /opt/ibm/db2/V9.7/instance #./dascrt -u db2das #./db2icrt -u db2inst1 db2inst1 注意:DBI1922N The host name is not valid.报无法解析错误,在/etc/hosts文件中添加解析参数即可 www.2cto.com 注释: Dascrt:创建的是DB2 adminstration server,每台服务器只有一个这种server,为进行DB2管理(比如运行控制中心)所必须,同时指定其管理用户是db2das。 db2icrt:创建的是实例,其名字一般和管理用户名一样,这里均为db2inst1。 6、启动DB2 # su - db2das $ db2admin start ----启动DB2管理服务器 SQL4409W The DB2 Administration Server is already active. $su - db2inst1 $ db2start ----启动数据库实例 05/07/2012 01:30:04 0 0 SQL1063N DB2START processing was successful. SQL1063N DB2START processing was successful. 7、检查DB2是否起来,状态如下: [db2inst1@jetsen ~]$ ps -ef|grep db2 db2das 10828 1 0 01:23 ? 00:00:00 /home/db2das/das/adm/db2dasrrm root 11345 1 0 01:23 ? 00:00:00 /opt/ibm/db2/V9.7/bin/db2fmcd db2das 11354 1 0 01:23 ? 00:00:00/opt/ibm/db2/V9.7/das/bin/db2fmd -i db2das -m/opt/ibm/db2/V9.7/das/lib/libdb2dasgcf.so.1 root 17267 2768 0 01:29 pts/1 00:00:00 su - db2das db2das 17268 17267 0 01:29 pts/1 00:00:00 -bash root 17329 17268 0 01:29 pts/1 00:00:00 su - db2inst1 db2inst1 17332 17329 0 01:29 pts/1 00:00:00 -bash root 17446 1 1 01:29 pts/1 00:00:01 db2wdog 0 db2inst1 17448 17446 1 01:29 pts/1 00:00:01 db2sysc 0 root 17449 17448 0 01:29 pts/1 00:00:00 db2ckpwd 0 root 17450 17448 0 01:29 pts/1 00:00:00 db2ckpwd 0 www.2cto.com root 17451 17448 0 01:29 pts/1 00:00:00 db2ckpwd 0 db2inst1 17455 17448 1 01:30 pts/1 00:00:01 db2vend (PD Vendor Process -1) db2inst1 17462 17446 0 01:30 pts/1 00:00:01 db2acd 0,0,0,0,1,0,0,0000,1,0,8a67a4,14,1e014,2,0,1,11fd0,0x125f0000,0x125f0000,1600000,588003,2,b5800b db2inst1 17494 17332 0 01:32 pts/1 00:00:00 ps -ef db2inst1 17495 17332 0 01:32 pts/1 00:00:00 grep db2 [db2inst1@jetsen ~]$ 8、配置DB2自动启动,用root用户登录 #cd /opt/ibm/db2/V9.7/instance/ # ./db2iauto -on db2inst1 9、配置网络 #su - db2inst1 $db2 update dbm cfg using SVCENAME50000 ----改变DB2的远程访问端口,默认是5000 $db2set DB2COMM=TCPIP ----修改DB2的连接方式为TCPIP, 注意:也可以通过JDBC,ODBC等方式来访问DB2数据库 10、实例的启动和关闭 #su - db2inst1 $db2 force applications all ----关闭所有和DB2相关的应用程序 $db2stop ----关闭数据库实例 $db2start ----启动数据库实例 11、创建数据库 #su - db2inst1 $db2 create database test ----创建数据库实例 DB20000I The CREATE DATABASE command completed successfully. 12、连接到我们刚才创建的数据库 #su - db2inst1 $db2 www.2cto.com db2 => Connect to test user db2inst1 Enter current password for db2inst1: Database Connection Information Database server = DB2/LINUX 9.7.5 SQLauthorization ID = DB2INST1 Local database alias = TEST db2 => 附录: 1、创建演示数据库 #su - db2inst1 $ $cd /opt/ibm/db2/V9.7/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. 2、访问刚创建的数据库 $ db2 www.2cto.com db2 => connect to sample Database Connection Information Database server = DB2/LINUX 9.7.5 SQLauthorization ID = DB2INST1 Local database alias = SAMPLE db2 => 3、常用操作命令 db2 =>connect to sample ---连接到sample数据库 db2 =>list tables ---查看库下面的所有表 db2 => select * from staff wheredept=10 ---查询某张表dept等于10的所有记录 db2 => quit www.2cto.com ---退出db2 DB20000I The QUIT command completed successfully. $ db2ilist; ---查看实例列表 db2inst1 $ db2 get instance ---查看当前所运行的实例 Thecurrent database manager instance is: db2inst1 (责任编辑:IT) |