Install DB2 V9.5 for Linux(64bit)

#Install DB2 V9.5 for Linux(64bit)

[root@localhost DB2_ESE_9.5]# ./db2prereqcheck


###  compat-libstdc++-33-3.2.3-47.3.x86_64.rpm  ###
###  compat-libstdc++-33-3.2.3-47.3.i386.rpm    ###
###  libaio-0.3.105-2.x86_64.rpm                ###
###  libaio-0.3.105-2.i386.rpm                  ###

[root@localhost DB2_ESE_9.5]# ./db2prereqcheck
[root@localhost DB2_ESE_9.5]# ./db2_install

用于安装产品的缺省目录是 /opt/ibm/db2/V9.5

***********************************************************
想要选择另一个目录来进行安装吗 [是/否]?



指定下面的一个或多个关键字
(用空格分隔)以安装 DB2 产品。

  ESE
  CLIENT
  RTCL

输入 "help" 以重新显示产品名。

输入 "quit" 以退出。

***********************************************************
ESE


如出现错误提示:
在此计算机上安装 "DB2 企业服务器版 "
时发生了较小的错误。某些功能部件可能无法正常工作。

有关更多信息,请参阅 "/tmp/db2_install.log.xxxx" 上的 DB2
安装日志。

使用 vi /tmp/db2_install.log.xxxx 查看日志文件,如果只有SMTP服务器没有配置和SA MP Base组件安装失败的故障,可以忽略错误。


#安装结束,开始配置

#添加组及用户并设置密码
[root@localhost DB2_ESE_9.5]# groupadd db2grp1
[root@localhost DB2_ESE_9.5]# useradd -g db2grp1 -d /home/db2inst1 -m db2inst1
[root@localhost DB2_ESE_9.5]# useradd -g db2grp1 -d /home/db2fenc1 -m db2fenc1
[root@localhost DB2_ESE_9.5]# useradd -g db2grp1 -d /home/db2das1 -m db2das1
[root@localhost DB2_ESE_9.5]# passwd db2inst1
[root@localhost DB2_ESE_9.5]# passwd db2fenc1
[root@localhost DB2_ESE_9.5]# passwd db2das1


#创建Administration Server
[root@localhost DB2_ESE_9.5]# cd /opt/ibm/db2/V9.5/instance/
[root@localhost instance]# ./dascrt -u db2das1
SQL4406W  The DB2 Administration Server was started successfully.
DBI1070I  Program dascrt completed successfully.

#创建实例
[root@localhost instance]# ./db2icrt -u db2inst1 db2inst1
DBI1070I  Program db2icrt completed successfully.

#设置DB2 TCP/IP连接模式
[root@localhost instance]# su db2inst1
[db2inst1@localhost instance]$ db2set DB2COMM=TCPIP
[db2inst1@localhost instance]$ db2 update dbm cfg using SVCENAME DB2_db2inst1

#修改连接端口为50000
[db2inst1@localhost instance]$ su root
[root@localhost instance]# vi /etc/services

#添加防火墙开放50000、50001、50002、50003
[root@localhost instance]# vi /etc/sysconfig/iptables

#添加自启动
[root@localhost instance]# vi /etc/rc.d/rc.local

#start db2
cd /home/db2das1
su - db2das1 -c "db2admin start"

cd /home/db2inst1
su - db2inst1 -c "db2start"

#添加license
[root@localhost instance]# /opt/ibm/db2/V9.5/adm/db2licm -a /tmp/db2/db2ese_c_v95.lic

#设置环境变量
[root@localhost ~]# vi /etc/profile

#for db2
export PATH=/home/db2inst1/sqllib/bin:$PATH

#刷新环境变量
[root@localhost ~]# source /etc/profile


#建库
db2 create database test using codeset utf-8 territory CN pagesize 16 K


 

 

 

 

 

 

 

 

 

 

 

 

 

db2问题集锦

 

问题一,

创建实例的时候 [root@db01 db2home]# /opt/ibm/db2/V9.5/instance/db2icrt -a server -u db2fenc1 db2inst1                                                                                                          /opt/ibm/db2/V9.5/instance/db2iutil: line 4700: 24711 Segmentation fault      (core dumped) ${DB2DIR?}/instance/db2isrv -addfcm -i ${INSTNAME?}

 

在/etc/hosts中添加 ip 和主机名即可

 

问题二

[db2inst1@db01 ~]$ db2start
02/03/2012 23:25:57     0   0   SQL1042C  An unexpected system error occurred.
SQL1032N  No start database manager command was issued.  SQLSTATE=57019


关闭selinux 即可

 

问题三

$ db2 connect to database user user using password

SQL1084C  Shared memory segments cannot be allocated.  SQLSTATE=57019

sysctl 中增加kernel.shmmax 直到可以登录数据库为止。

或者减小db2 dbm的 INSTANCE_MEMORY 的值用db2 update dbm cfg using INSTANCE_MEMORY 100000(这个值自己定义)

 

问题四

$ db2 connect to database_name user user using password

SQL30082N  Security processing failed with reason "24" ("USERNAME AND/OR
PASSWORD INVALID").  SQLSTATE=08001

 

解决方法:linux下db2用户名不能超过8个字符,windows下不能超过30个字符。

 

问题五:DB2 SQL error: SQLCODE: -1218, SQLSTATE: 57011
  db2 force application all
  db2stop
  db2set DB2_OVERRIDE_BPF=100000   #这是把默认bufferpool大小设置为400M , 4kx100000
  db2start

 

 

问题六:SQL1117N A connection to or activation of database "databasename" cannot be made

because ofROLL-FORWARD PENDING. SQLSTATE=57019

db2 => rollforward database databasename to end of logs and stop

Rollforward Status

Input database alias = databasename

Number of nodes have returned status = 1

Node number = 0

Rollforward status = not pending

Next log file to be read =

Log files processed =S0000001.LOG - S0000001.LOG

Last committed transaction = 2010-08-04-11.39.27.000000 UTC

DB20000I The ROLLFORWARD command completed successfully.

然后就可以connect to databasename了

参考: http://www.kuniel.net/2009/09/29/db2-restore-with-rollforward/

 

 

问题七:Resolving Error 3: DB2 return code is -4214

  1. Check that the user name and password are specified correctly.

  2. Check that the password does not contain special characters, such as the dollar sign ($).

  3. PS:个人认为,加密方式如果抱错的话,密码改短点,别用特殊符号。

 

问题八:查看锁表以及解锁

方法一:
使用SecureCRT
db2 "get snapshot for locks on 数据库名"
db2 "force application(进程hander)"
杀掉死锁进程

方法二:
用管理员帐户登陆,在"管理员模式下"
使用select agent_id,tabname,lock_mode from table(snap_get_lock('BL_DEVP')) as aa
查看:进程hander,表名,锁模式
然后进控制中心,选择对应数据库,右键选择"应用程序",找到对应进程hander,选"强制"杀掉死锁进程

 

问题九:

SQL0964C errors because the DB2 transaction log is full

If you receive an SQL0964C error, adjust the DB2® log file settings.

Description
In enterprise environments where the amount of raw log data exceeds 30 GB per day, the default DB2 log file setting might be insufficient and result in the following error:SQL0964C The transaction log for the database is full.  SQLSTATE=57011
WorkaroundSet the DB2 log file size to a larger size and increase the number of secondary log files. You must restart DB2 after making these changes.

Connect to the Tivoli® Security Information and Event Manager database, CIFDB.

Set the log file size to 65536.   

 

update db cfg for db_nameusing LOGFILSIZ 65536

 

Increase the number of secondary log files to 160.

 

update db cfg for db_nameusing LOGSECOND 160

 

Restart the DB2 service.

db2stop

db2start

 

For example:

                    update db cfg for CIFDB using LOGFILSIZ 65536 

                    update db cfg for CIFDB using LOGSECOND 160

 

问题十:db2 v9 解锁 
db2 update monitor switches using lock on
db2 get snapshot for locks on xxxxx > lock.txt
找到进程后
db2 "force application(XXXXX)"

posted @ 2012-05-11 18:51  SimPapaya  阅读(1907)  评论(0编辑  收藏  举报