【DB2】 Redhat 5.8 x64 安装 DB2 v9.7 AESE
现在开始系统地学习DB2,相信比过去零零星星的学习方式更容易形成知识体系。还是那句话“工欲善其事,必先利其器”,我们首先来完整地部署一套DB2数据库。Windows下不用多说,现在主要是围绕linux下的部署进行。 目前IBM官网上能够下载到的是DB2-Express v10.1 版本。一.软硬件需求: http://publib.boulder.ibm.com/
特别在博客增加了DB2分类,现在正式系统地学习DB2,相信比过去零零星星的学习方式更容易形成知识体系。还是那句话“工欲善其事,必先利其器”,我们首先来完整地部署一套DB2数据库。Windows下不用多说,现在主要是围绕linux下的部署进行。
一.软硬件需求:
参考链接:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom.ibm.db2.luw.qb.server.doc%2Fdoc%2Fr0008865.html
二. 前置准备工作:
1.验证RPM包:
#rpm -q --qf '%{NAME}-%{VERSION}-%{RELEASE} (%{ARCH})\n' \
openssh \
openssh-server \
rsh-server \
nfs-utils \
pdksh \
ksh93 \
libpam \
libaio \
libstdc++ \
sysstat \
package rsh-server is not installed
package pdksh is not installed
package ksh93 is not installed
package libpam is not installed
package sysstat is not installed
2.手动安装上面缺失的rpm包
[root@ibm1 ~]# rpm -Uvh /media/cdrom1/Server/rsh-server-0.17-40.el5_7.1.x86_64.rpm
[root@ibm1 ~]# rpm -Uvh /media/cdrom1/Server/pdksh-5.2.14-37.el5.x86_64.rpm
[root@ibm1 ~]# rpm -Uvh /media/cdrom1/Server/sysstat-7.0.2-11.el5.x86_64.rpm
3. 配置HOSTS文件与主机名
[root@ibm1 ~]# cat /etc/hosts
# Do not remove the following line, or various programs
# that require network functionality will fail.
127.0.0.1 ibm1.localdomain ibm1 localhost.localdomain localhost
::1 localhost6.localdomain6 localhost6
[root@ibm1 ~]# cat /etc/sysconfig/network
NETWORKING=yes
NETWORKING_IPV6=no
HOSTNAME=ibm1
GATEWAY=10.0.0.1
注意:主机名要与hosts文件对应,保证可以被正确解析。
4. 挂载安装介质,确认源路径
[root@ibm1 ~]# mount /dev/cdrom /media/cdrom/
mount: block device /dev/cdrom is write-protected, mounting read-only
[root@ibm1 ~]# df -h
Filesystem Size Used Avail Use% Mounted on
........................
/dev/hdc 2.0G 2.0G 0 100% /media/cdrom
total 49
dr-xr-xr-x 1 root root 2048 Aug 4 13:02 db2
-r-xr-xr-x 1 root root 5340 Dec 7 2010 db2ckupgrade
-r-xr-xr-x 1 root root 5293 Dec 7 2010 db2_deinstall
-r-xr-xr-x 1 root root 5163 Dec 7 2010 db2_install
-r-xr-xr-x 1 root root 5127 Dec 7 2010 db2ls
-r-xr-xr-x 1 root root 5145 Dec 7 2010 db2prereqcheck
-r-xr-xr-x 1 root root 5145 Dec 7 2010 db2setup
dr-xr-xr-x 1 root root 2048 Aug 4 13:02 doc
-r-xr-xr-x 1 root root 5181 Dec 7 2010 installFixPack
dr-xr-xr-x 1 root root 2048 Aug 4 13:02 nlpack
dr-xr-xr-x 1 root root 2048 Aug 4 13:02 readmefirst
-r-xr-xr-x 1 root root 1503 Dec 7 2010 readmefirst.htm
-r-xr-xr-x 1 root root 678 Dec 7 2010 readmefirst.txt
安装程序在此,准备就绪!
三. 正式安装:
DB2提供了两种安装方式,分别是GUI方式与字符方式,分别使用db2setup与db2_intall进行安装。其中GUI安装方式比较简单,且会自动进行用户,用户组配置,非常方便。但是在一些特殊场景,特别是跨国VPN效率不佳的情况下,GUI基本没有可用性。因此掌握字符安装方式也是尤为重要的,它带宽依赖很小,但是需要手动配置部分内容,不要绕过它哦:-)
A. 使用GUI方式安装
1. 调用db2setup进入GUI安装
[root@ibm1 expc]# ./db2setup
DBI1190I db2setup is preparing the DB2 Setup wizard which will guide
you through the program setup process. Please wait.
........
中间都是向导模式,没什么好说的,但是要注意的是,安装过程中系统为我们自动配置了必要的用户,用户组与环境变量
[root@ibm1 expc]# id dasusr1
uid=500(dasusr1) gid=103(dasadm1) groups=103(dasadm1)
[root@ibm1 expc]# id db2inst1
uid=501(db2inst1) gid=104(db2iadm1) groups=104(db2iadm1),103(dasadm1)
[root@ibm1 expc]# id db2fenc1
uid=502(db2fenc1) gid=105(db2fadm1) groups=105(db2fadm1)
........
2.使用验证工具进行验证:
[root@ibm1 ~]# /opt/ibm/db2/V9.7/bin/db2val
DBI1335I Installation file validation for the DB2 copy installed ates.
/opt/ibm/db2/V9.7 was successful.
DBI1343I The db2val command completed successfully. For details, see
the log file /tmp/db2val-10_17_21:59:14.log.
下面可以看到到db2inst1实例定义的端口号为60000
[root@ibm1 ~]# cat /etc/services | grep db2
ibm-db2 523/tcp # IBM-DB2
ibm-db2 523/udp # IBM-DB2
questdb2-lnchr 5677/tcp # Quest Central DB2 Launchr
questdb2-lnchr 5677/udp # Quest Central DB2 Launchr
DB2_db2inst1 60000/tcp
DB2_db2inst1_1 60001/tcp
DB2_db2inst1_2 60002/tcp
DB2_db2inst1_END 60003/tcp
下面可以注意到实例已经开启并占用了60000端口
tcp 0 0 0.0.0.0:60000 0.0.0.0:* LISTEN 3667/db2sysc 0
tcp 0 0 0.0.0.0:1920 0.0.0.0:* LISTEN 3189/kuddb2
tcp 0 0 0.0.0.0:59532 0.0.0.0:* LISTEN 3189/kuddb2
tcp 0 0 0.0.0.0:3661 0.0.0.0:* LISTEN 3189/kuddb2
tcp 0 0 0.0.0.0:45041 0.0.0.0:* LISTEN 3189/kuddb2
tcp 0 0 127.0.0.1:45045 0.0.0.0:* LISTEN 3189/kuddb2
tcp 0 0 0.0.0.0:6014 0.0.0.0:* LISTEN 3189/kuddb2
tcp 0 0 127.0.0.1:39634 127.0.0.1:45045 ESTABLISHED 3189/kuddb2
tcp 0 0 127.0.0.1:45045 127.0.0.1:39634 ESTABLISHED 3189/kuddb2
db2的后台进程已经启动
[root@ibm1 ~]# ps -elf | grep db2
0 S db2inst1 3189 1 3 78 0 - 64276 futex_ 21:57 ? 00:00:16 /opt/ibm/db2/V9.7/itma/lx8266/ud/bin/kuddb2 ibm1_db2inst1
0 S root 3241 1 0 78 0 - 22099 - 21:57 ? 00:00:00 /opt/ibm/db2/V9.7/bin/db2fmcd
4 S root 3665 1 0 77 0 - 206079 184466 21:58 ? 00:00:00 db2wdog 0
4 S db2inst1 3667 3665 0 83 0 - 207693 futex_ 21:58 ? 00:00:00 db2sysc 0
1 S root 3668 3667 0 81 0 - 140543 msgrcv 21:58 ? 00:00:00 db2ckpwd 0
1 S root 3669 3667 0 84 0 - 140543 msgrcv 21:58 ? 00:00:00 db2ckpwd 0
1 S root 3670 3667 0 85 0 - 140543 msgrcv 21:58 ? 00:00:00 db2ckpwd 0
0 S db2inst1 3674 3667 0 85 0 - 74131 pipe_w 21:58 ? 00:00:00 db2vend (PD Vendor Process - 1)
4 S db2inst1 3683 3665 0 78 0 - 134620 semtim 21:58 ? 00:00:00 db2acd 0 ,0,0,0,1,0,0,0000,1,0,8a66dc,14,1e014,2,0,1,11fc0,0x210000000,0x210000000,1600000,2a0009,2,90010
0 R root 30394 3312 0 78 0 - 15295 - 22:04 pts/1 00:00:00 grep db2
3. 使用FirstStep创建示例数据库。
4. 将/opt/ibm/db2/V9.7/instance/ 加入ROOT环境变量,方便实例管理的命令调用
[root@ibm1 ~]# cat ~/.bash_profile
# .bash_profile
# Get the aliases and functions
if [ -f ~/.bashrc ]; then
. ~/.bashrc
fi
# User specific environment and startup programs
PATH=$PATH:$HOME/bin
PATH=$PATH:/opt/ibm/db2/V9.7/instance/
export PATH
unset USERNAME
B.使用响应文件安装(v10.1 express演示)
1.GUI安装过程中可以保存 response file:
此处的选择将会仅仅按照当前配置生成相应文件而不进行软件安装。
2.默认不创建instance的response file:
*-----------------------------------------------------
* Generated response file used by the DB2 Setup wizard
* generation time: 7/18/13 10:25 PM
*-----------------------------------------------------
* Product Installation
LIC_AGREEMENT = ACCEPT
PROD = EXPRESS_C
FILE = /opt/ibm/db2/V10.1
INSTALL_TYPE = TYPICAL
*-----------------------------------------------
* Das properties
*-----------------------------------------------
DAS_CONTACT_LIST = LOCAL
DAS_SMTP_SERVER = ibm1
* DAS user
DAS_USERNAME = dasusr1
DAS_GROUP_NAME = dasadm1
DAS_HOME_DIRECTORY = /home/dasusr1
DAS_PASSWORD = 744622525793295481719179525871125264426162673461416649651243956279369792338985372492640445210243501423472736622566535570718324682638313632627796224763282611536041426358306513742662448343242295662864356553243852537290322351414625050426771388014713423666301993958353520465668590172058333142993303532177714564428945556370818033648141664844233229892215367211785212351376054464190246337748033498014424372133533355073264292235238132453580806285296609454896099777349354267317033305204423954847862944656382494643614457900636384024685424574755681133606228539591854898943406337382436885633333606465487512355397486544088332794275829953164584836894148233612465016063565179881822264023030206062440823232260051061439512465884285605523936939827248248162334636252460343389284932712291
ENCRYPTED = DAS_PASSWORD
*-----------------------------------------------
* Installed Languages
*-----------------------------------------------
LANG = EN
3.默认要创建instance的reponse file:
*-----------------------------------------------------
* Generated response file used by the DB2 Setup wizard
* generation time: 7/18/13 10:22 PM
*-----------------------------------------------------
* Product Installation
LIC_AGREEMENT = ACCEPT
PROD = EXPRESS_C
FILE = /opt/ibm/db2/V10.1
INSTALL_TYPE = TYPICAL
*-----------------------------------------------
* Das properties
*-----------------------------------------------
DAS_CONTACT_LIST = LOCAL
DAS_SMTP_SERVER = ibm1
* DAS user
DAS_USERNAME = dasusr1
DAS_GROUP_NAME = dasadm1
DAS_HOME_DIRECTORY = /home/dasusr1
DAS_PASSWORD = 526544590559331192593262337434304697153653472534357430304231325582146259524731700725652180438164628443545419468632635474183282752724373081053042004982745939442216433563563724852475214468191043863846130278365826595465053133039425047726376033225415624132634475956692124974442312744008831155752091418520486074204399627955272595196957606242384923547096361693832222172021414243454532347878484436194461224393862684725193660213623126665464488216868349413166609886131223228733747242478752055424065446635382766649142214261374186614907270431211557317192774335550574312452193925822834594694568540504162698448402039166654361032524423438195620438369376163289343255506533337414221478715793386654045017550345256586537613666340839370964969941455314500655578086312658313116990312324266
ENCRYPTED = DAS_PASSWORD
* ----------------------------------------------
* Instance properties
* ----------------------------------------------
INSTANCE = inst1
inst1.TYPE = wse
* Instance-owning user
inst1.NAME = db2inst1
inst1.GROUP_NAME = db2iadm1
inst1.HOME_DIRECTORY = /home/db2inst1
inst1.PASSWORD = 033430383531472327745625913692398532233766190056823469342492474640942464559815713053859434537989653954255516689318123260223368440425507643067755559883902151064502563940314552737615120575136537344434968718223022445965264438583941929130216974259350266382252453411245552463874544557244954952231607645622218767923052532614362973667361951076195122474543238292293445287462716323615842076035225051849414614370665644999088145125026976168535194486096316211342527647444696114686344029120264276426375386431265422633219832476121320635486317564942182679243654343151585232636548552038364994410537843286093405429152239393633933394392341503892645884575443723523362673118240906488454756302005173803375165626614300737386344244753836641671745914496734585972576413345426653952310065264204
ENCRYPTED = inst1.PASSWORD
inst1.AUTOSTART = YES
inst1.SVCENAME = db2c_db2inst1
inst1.PORT_NUMBER = 50000
inst1.CONFIGURE_TEXT_SEARCH = NO
* Fenced user
inst1.FENCED_USERNAME = db2fenc1
inst1.FENCED_GROUP_NAME = db2fadm1
inst1.FENCED_HOME_DIRECTORY = /home/db2fenc1
inst1.FENCED_PASSWORD = 048194309735354922712264548675341794127362774555355158251362344271122707123935683454224612203135594844232176151372353546774934132421001627254632921336346207675560414742452872169565414290210611502111741812554565583933319435129377706402343152133952114313255316649465101422119893523337561076333164490980234882398221775959043471516291186554435622423404592355460632242625750110950583317540496539286222995224548483530404471126156304669216048832284264679430617108061902012355155653123147114966452516322048441660634422640476511352086032492872694309743743333361957235486369505483254556766012474222623359594035415841532230520645383745926520366745999294595566415303631542573314996938623111852692457086244754308397454916282323753354623437245453022524336262296172484265532376522441
ENCRYPTED = inst1.FENCED_PASSWORD
* Contact properties
CONTACT = contact1
contact1.CONTACT_NAME = db2inst1
contact1.EMAIL = db2inst1@ibm1
contact1.PAGER = false
contact1.NEW_CONTACT = YES
contact1.INSTANCE = inst1
*-----------------------------------------------
* Installed Languages
*-----------------------------------------------
LANG = EN
4.Linux下调用response file进行安装:
[root@ibm1 expc]# ./db2setup -r /root/db2expc.rsp
DBI1191I db2setup is installing and configuring DB2 according to the
response file provided. Please wait.
The execution completed successfully.
For more information see the DB2 installation log at "/tmp/db2setup.log".
参考链接:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom.ibm.db2.luw.admin.cmd.doc%2Fdoc%2Fr0008889.html
C.使用字符界面安装DB2
参考链接:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom.ibm.db2.luw.admin.cmd.doc%2Fdoc%2Fr0008889.html
1. 使用db2_install发起字符安装
[root@ibm1 ~]# /media/cdrom1/aese/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
CLIENT
RTCL
Enter "help" to redisplay product names.
Enter "quit" to exit.
***********************************************************
AESE
DB2 installation is being initialized.
Total number of tasks to be performed: 47
Total estimated time for all tasks to be performed: 2099
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
Task #3 start
Description: Product Messages - English
Estimated time 12 second(s)
Task #3 end
.......................................................
.......................................................
Task #46 start
Description: Initializing instance list
Estimated time 5 second(s)
Task #46 end
Task #47 start
Description: Registering DB2 Update Service
Estimated time 30 second(s)
Task #47 end
Task #48 start
Description: Updating global profile registry
Estimated time 3 second(s)
Task #48 end
The execution completed successfully.
For more information see the DB2 installation log at
"/tmp/db2_install.log.2857".
2. 配置用户,用户组
# groupadd db2iadm1 #instance owner所属组
# groupadd db2fadm1 #db2fenc1用户所属组
# groupadd dasadm1 #dasusr1 用户所属组
# useradd -g dasadm1 -G dasadm1 dasusr1
# useradd -g db2iadm1 -G db2iadm1,dasadm1 db2inst1
# useradd -g db2fadm1 -G db2fadm1 db2fenc1
#passwd dasusr1
#passwd db2inst1
#passwd db2fenc1
注意:
实例owner的环境变量在用户手动建立后不需要进行配置,因为在该用户下建立instance时,该用户下的~/.bashrc会被自动写入db2环境变量信息。然后.bashrc会被.bash_profile引用!
3. 在db2inst1下创建实例
[root@ibm1 ~]# cd /opt/ibm/db2/V9.7/instance/
[root@ibm1 instance]# ./db2icrt -u db2fenc1 db2inst1
DBI1070I Program db2icrt completed successfully.
4. 导入licence
[root@ibm1 instance]# su - db2inst1
[db2inst1@ibm1 ~]$ db2licm -l
Product name: "DB2 Advanced Enterprise Server Edition"
License type: "License not registered"
Expiry date: "License not registered"
Product identifier: "db2aese"
Version information: "9.7"
[db2inst1@ibm1 ~]$ db2licm -a /media/cdrom1/aese_u/db2/license/db2aese_u.lic
LIC1402I License added successfully.
LIC1426I This product is now licensed for use as outlined in your License Agreement. USE OF THE PRODUCT CONSTITUTES ACCEPTANCE OF THE TERMS OF THE IBM LICENSE AGREEMENT, LOCATED IN THE FOLLOWING DIRECTORY: "/opt/ibm/db2/V9.7/license/en_US.iso88591"
[db2inst1@ibm1 ~]$ db2licm -l
Product name: "DB2 Advanced Enterprise Server Edition"
License type: "Authorized User Option"
Expiry date: "Permanent"
Product identifier: "db2aese"
Version information: "9.7"
Enforcement policy: "Soft Stop"
Number of licensed authorized users: "25"
Features:
DB2 Geodetic Data Management: "Not licensed"
5. 创建sample数据库:
[db2inst1@ibm1 ~]$ db2sampl -dbpath $HOME
参看链接:
http://publib.boulder.ibm.com/infocenter/db2luw/v9r5/index.jsp?topic=%2Fcom.ibm.db2.luw.admin.cmd.doc%2Fdoc%2Fr0001934.html
注意:如果要使用windows下的control center,务必将被attach的系统标注在 c:\windows\system32\drivers\etc\host 内
关于instance与database的详细管理,请见下回分解!
更多推荐
所有评论(0)