安装DB2过程中出现的问题以及解决方法
一次DB2数据库连接失败(SQLSTATE=08001)的解决方法

⼀次DB2数据库连接失败(SQLSTATE=08001)的解决⽅法有⼀次,在使⽤DbVisualizer⼯具连接⾃⼰linux虚拟机上的DB2数据库时,报如下错误:Product: DbVisualizer Pro 9.1Build: #2050 (2013/09/08 11:03)Java VM: Java HotSpot(TM) 64-Bit Server VMJava Version: 1.6.0_43Java Vendor: Sun Microsystems Inc.OS Name: Windows 7OS Arch: amd64OS Version: 6.1An error occurred while establishing the connection:Long Message:[jcc][t4][2043][11550][4.15.82] 异常 .ConnectException:打开端⼝ 50,000 上服务器 /192.168.17.88 的套接字时出错,消息为:Connection timed out: connect。
ERRORCODE=-4499, SQLSTATE=08001 Details:Type: com.ibm.db2.jcc.am.DisconnectNonTransientConnectionExceptionError Code: -4499SQL State: 08001在百度上搜索"DB2 SQLSTATE=08001",找到如下资料:这种问题⼀般的原因:1.DB2COMM=TCPIP2.数据库故障3.端⼝号被禁⽤解决⽅案:1.看看端⼝号有没有配置正确,看⼀下配置参数svcename跟services⽂件中配置的db2端⼝号是否⼀致,windows⼀般⽤50000,unix/linux⼀般⽤60000。
2.连接出错⾸先看看服务器ip 和端⼝写对没有。
DB2安装数据库遇到的问题

1.db2upp@wlaix6b:/home/db2upp>db2 connect to uppSQL1762N Unable to connect to database because there is not enough space toallocate active log files. SQLSTATE=08004解决:执行db2 "update db cfg using newlogpath '/db2log/db2upp/NODE0000/SQL00001/SQLOGDIR/'";指定日志存放位置2.服务端与客户端只有一方能连接数据库:释放IPC资源PRGN=`basename $0`TMPF="/var/tmp/$PRGN.$$"#================## FUNCTION: quit ##================#quit () {rm -f $TMPFexit $1}#===============## MAIN Entrance ##===============## if [ $# -lt 1 ]; then# echo "Usage: $PRGN {process_name}"# quit 1# fiuid=`id -u`if [ $uid -eq 0 ]; thenecho "Superuser cannot use this program !"quit 1fiipcs | grep $LOGNAME > $TMPFcnt=`cat $TMPF | wc -l`while [ $cnt -gt 0 ]; doline=`sed -n "${cnt}p" $TMPF`rnm=`echo $line | cut -d " " -f1`rid=`echo $line | cut -d " " -f2`echo "killing ${rnm} ... ${rid}"ipcrm -$rnm $ridcnt=`expr $cnt - 1`donequit 0重启db2数据库Db2stop forceDb2start3.客户端连接数据库时报:ERRORCODE=-4499, SQLSTA TE=08001解决:db2 get dbm cfg|grep SVCENAME 查看连接端口4.启动/停止数据库报错07/11/2013 16:36:26 0 0 SQL1072C The request failed because the database manager resources are in an inconsistent state. The database manager might have been incorrectly terminated, or another application might be using system resources in a way that conflicts with the use of system resources by the database manager.SQL1025N The database manager was not stopped because databases are still active.删除数据库从新建(未找到解决办法)5.如果容器用的是RAW,当已经在RAW设备上创建容器后,若没有通过正常的步骤删除表空间所在的数据库,也没有直接删除容器或者容器所在的表空间,则再次利用这些RAW设备时,DB2会报:The container is already in use此时应该使用db2untag命令释放container标志如:db2untag -f /dev/rdb2datalv6.DB2无法创建到指定目录时提示SQL1052N 数据库路径XXX/ 不存在解决:db2set DB2_CREA TE_DB_ON_PATH=YES7.无法删除DB2数据库解决:db2 force applications all 先清除所有连接再执行drop db8.服务器关闭,第二天重启后连接数据库报SQL1116N A connection to or activation of database "UPP" cannot be made9.because of BACKUP PENDING. SQLSTATE=57019解决:数据库进入归档模式,执行离线全备份后可恢复正常db2 backup db upp to /tmp/db2upp (/tmp/db2upp是一个有权限操作的位置即可) 恢复正常Db2实用命令:1.启动db2db2start2.停止db2db2stop force3.查看数据库连接:db2 list applications4.强制杀掉所有连接db2 force applications all5.连接数据库例:db2 connect to upp user db2upp using db2upp #连接upp数据库schame db2upp密码db2upp 6.断开数据库连接db2 connect reset6.查看当前实例数据库编目信息db2 list database directory7.查看当前数据库所有表空间db2 list tablespaces show detail8.查看当前用户权限db2 get authorizations9.列出所有用户表db2 list tables10.创建schemaCREATE schema db2upp11.查看当前数据库表空间分配情况db2 list tablespaces show detail。
关于DB2常见性能问题的解决参考

关于DB2常见性能问题的解决参考最近一个项目在做性能测试时,在并发达到一定数后,DB2数据库资源占用很大,必须对数据库和应用进行优化。
该项目要求性能指标(CPU<70%,内存占用<70%,IO<60),按照网友介绍的经验,分别针对CPU、内存、IO进行问题排查和分析。
现将过程总结如下:一、CPU分析通过资源监视器查看一个或多个CPU 的使用率,确定确实存在CPU使用率一直居高不下的情况。
1、首先排除掉存在死循环的情况。
(并发下来后,CPU使用率会降下来)。
2、DB2占用CPU的主要行为有:语句编译、大量排序、DB2实用工具运行。
3、先查看是否有大量的语句编译:通过DB2的表函数MON_GET_WORKLOAD,可以查看到:select varchar(workload_name,30) as workload_name,sum(total_cpu_time),sum(total_compile_proc_time),sum(act_rqsts_total),um(total_compilations),sum(total_act_time), sum(pkg_cache_inserts), sum(pkg_cache_lookups) from TABLE(MON_GET_WORKLOAD('',-2)) as T group by workload_name如果compile_proc_time 高于5-10% 的total_cpu_time,并且pkg_cache_inserts/pkg_cache_lookups 高于4-5%,则数据库在语句编译上花费了太多的时间。
必须调大语句集中器STMT_CONC的大小。
采用逐步调大的方式来跟踪效果。
4、查看是否存在大量的SORT首先通过db2的快照,看是否存在大量的sort溢出✓Sort overflows/Total sorts * 100% 表示排序溢出百分比,通常情况下,该值应该小于3。
db2 直接复制过来的文件夹不能加载数据库

db2 直接复制过来的文件夹不能加载数据库1. 引言在数据库管理中,数据迁移是一项重要的任务。
数据的复制是一种常用的迁移方式,它可以将数据库中的内容从一个位置复制到另一个位置。
然而,有时候我们可能会遇到一个问题,即当我们尝试直接复制一个文件夹到DB2数据库时,发现无法加载数据库。
在本文中,我们将探讨这个问题的原因,并提供一些解决方案和建议。
我们将从简单的概念开始,逐步深入,以便更好地理解这个问题。
2. DB2数据库简介DB2是一种关系型数据库管理系统,它由IBM开发和维护。
它被广泛应用于各种企业级应用程序和数据仓库中。
DB2的设计目标是提供高性能、高可靠性和可扩展性的数据库解决方案。
3. 数据迁移方法在数据库管理中,有多种方法可以进行数据迁移,包括复制、备份和还原等。
其中,数据的复制是一种常用且有效的方法。
通过将源数据库中的内容复制到目标数据库,我们可以简化数据迁移过程,并确保数据的完整性和一致性。
4. 直接复制过来的文件夹不能加载数据库的原因如果我们尝试直接复制一个文件夹到DB2数据库中,可能会遇到无法加载数据库的问题。
这是由于DB2数据库的特性所致。
DB2要求我们使用其专用的工具和命令来执行数据库的加载和还原操作。
直接复制文件夹可能会导致数据库的元数据和配置信息缺失或不正确,从而使数据库无法加载。
5. 解决方案和建议要解决直接复制文件夹无法加载数据库的问题,我们可以采取以下措施:5.1 使用DB2的工具和命令进行数据迁移最简单和推荐的方法是使用DB2提供的工具和命令来执行数据迁移操作。
这些工具和命令可以确保数据库的元数据和配置信息正确加载,从而使数据库能够正常运行。
5.2 执行数据库备份和还原操作如果我们已经复制了文件夹到DB2数据库,并且数据库无法加载,我们可以尝试执行备份和还原操作。
我们需要使用DB2的工具和命令对源数据库进行备份。
在目标数据库中执行还原操作,将备份文件中的数据加载到目标数据库中。
【数据库】:关于DB2数据库错误提示说明

【数据库】:关于DB2数据库错误提⽰说明SQLSTATE 消息本节列⽰ SQLSTATE 及其含义。
SQLSTATE 是按类代码进⾏分组的;对于⼦代码,请参阅相应的表。
表 2. SQLSTATE 类代码类代码含义要获得⼦代码,参阅...00 完全成功完成表 301 警告表 402 ⽆数据表 507 动态 SQL 错误表 608 连接异常表 709 触发操作异常表 80A 功能部件不受⽀持表 90D ⽬标类型规范⽆效表 100F ⽆效标记表 110K RESIGNAL 语句⽆效表 1220 找不到 CASE 语句的条件表 1321 基数违例表 1422 数据异常表 1523 约束违例表 1624 ⽆效游标状态表 1725 ⽆效事务状态表 1826 ⽆效 SQL 语句标识表 1928 ⽆效权限规范表 212D ⽆效事务终⽌表 222E ⽆效连接名表 2334 ⽆效游标名表 2436 游标灵敏度异常表 2538 外部函数异常表 2639 外部函数调⽤异常表 273B SAVEPOINT ⽆效表 2840 事务回滚表 2942 语法错误或存取规则违例表 3044 WITH CHECK OPTION 违例表 3146 Java DDL 表 3251 ⽆效应⽤程序状态表 3353 ⽆效操作数或不⼀致的规范表 3454 超出 SQL 限制,或超出产品限制表 3555 对象不处于先决条件状态表 3656 其它 SQL 或产品错误表 3757 资源不可⽤或操作员⼲预表 3858 系统错误表 39类代码 00 完全成功完成表 3. 类代码 00:完全成功完成SQLSTATE 值含义00000 操作执⾏成功,并且未产⽣任何类型的警告或异常情况。
类代码 01 警告表 4. 类代码 01:警告SQLSTATE 值含义01002 发⽣ DISCONNECT 错误。
01003 从列函数的⾃变量消去 NULL 值。
01004 字符串值在指定给具有较短长度的另⼀字符串数据类型时被截断。
db2锁超时解决方案

db2锁超时解决方案DB2是一种流行的关系型数据库管理系统,但在使用过程中,可能会遇到锁超时的问题。
锁超时是指当一个事务请求获取资源的锁时,如果等待的时间超过了设定的阈值,系统会自动放弃获取锁的请求,以避免长时间的阻塞。
本文将介绍一些常见的DB2锁超时解决方案。
1. 优化SQL语句:锁超时通常是由于事务对数据库资源的锁定时间过长导致的。
因此,首先要考虑优化SQL语句,减少事务对资源的锁定时间。
可以通过以下几个方面来优化SQL语句:- 确保只锁定必要的数据行,尽量避免对整个表进行锁定。
- 合理使用索引,以提高查询效率,减少锁定时间。
- 在事务中尽早释放不再需要的资源锁定,避免长时间占用。
2. 调整锁超时参数:DB2提供了一些参数用于调整锁超时的行为。
可以通过调整这些参数来解决锁超时问题。
常用的参数包括:- LOCKTIMEOUT:该参数指定了事务在等待锁的时间超过设定值后,是否放弃锁定请求。
可以通过增加该参数的值来延长锁超时时间。
- DEADLOCK_TIMEOUT:该参数指定了在发生死锁时,系统等待的时间。
可以通过增加该参数的值来延长等待时间,以便系统有更多的时间解决死锁问题。
- LOCKLIST:该参数指定了数据库管理系统为锁定分配的内存量。
可以通过增加该参数的值来提高系统处理锁定的能力。
3. 使用乐观锁机制:乐观锁是一种乐观的思想,即默认认为事务之间不会发生冲突,只有在提交事务时才会检查是否发生了冲突。
使用乐观锁机制可以减少锁超时的概率,提高并发性能。
常用的乐观锁实现方式包括版本控制和时间戳控制。
4. 分析锁超时日志:DB2提供了日志记录锁超时的功能,通过分析这些日志可以了解导致锁超时的原因。
可以通过查看日志中的锁超时事件、事务和资源信息,找出导致锁超时的具体原因,从而有针对性地解决问题。
5. 适当调整事务隔离级别:事务隔离级别可以控制事务对资源的锁定程度。
不同的隔离级别对锁超时的概率有影响。
DB2数据库详细安装图解

如果您没有DB2的安装软件,那么您可以到IBM的官方网站上下载免费试用版,网址如下:/cn/software/db2/图1获得的安装文件是一个压缩包:图2DB2的安装1、解压DB2安装压缩包解压获得的DB2安装压缩包:图32、安装DB2 V8.2双击解压后安装文件目录中的“setup.exe”文件,开始安装。
图4第一步:首先进入安装界面:后续安装步骤请参见------>图解:IBM DB2 安装完整过程 ( 二 )将鼠标移动到安装界面不同项,会提示您不同的信息:Ø安装先决条件:显示安装DB2的软硬件需求,先决条件和安装说明。
图6Ø发行说明:显示本产品的最新信息,包括与本产品相关的书籍的自述文件。
图7Ø安装产品:展示可安装的产品列表,可以从列表中进行选择。
图8¨退出安装:关闭此窗口。
图9第二步:点击“安装产品”,进入选择安装产品界面。
图10我们的演示版本只有一个可选项,即:DB2 UDB企业服务器版。
选中此项。
点击“下一步”进入下一步安装。
图11第三步:安装程序进入“欢迎使用DB2安装向导”界面。
点击“下一步”。
图12第四步:安装进入“许可证协议”界面,选择“我接受许可证协议中的全部条款”,否则,安装程序将被终止。
点击“下一步”。
图2.13第五步:安装进入“选择安装类型”界面Ø典型安装:安装程序按照缺省的配置进行安装,您可以在附加功能一栏中添加如“数据仓库”或“卫星管理功能”的功能。
对于大多数的开发环境,选择“典型安装”就可以了。
Ø压缩安装:这个类型只是安装DB2最基本的功能部件和功能,执行最小的配置。
Ø定制安装:您可以自己决定安装什么功能和功能部件,但是,这个类型要求您对DB2的功能部件和设置都比较了解。
我们这里选择“典型安装”,点击“下一步”。
图14第六步:安装程序进入“选择安装操作”界面¨第一项:是否在计算机上安装DB2 企业服务器版本,这个必须被选中。
为什么db2频现“锁等待”或“911”错误

| Lock Intents
| | Table: Intent Exclusive
| | Row : Update
| Sargable Predicate(s)
| | #Predicates = 1
Update: Table Name = CWGLADM.T ID = 2,4
DB20000I UPDATE COMMAND OPTIONS 命令成功完成。
db2 => set current isolation = ur
DB20000I SQL 命令成功完成。
================================================================
| Index Prefetch: None
| Lock Intents
| | Table: Intent Exclusive
| | Row : Update
| Sargable Predicate(s)
| | #Predicates = 1
Update: Table Name = CWGLADM.T ID = 2,4
| | Start Key: Inclusive Value
| | | | 1: 00001
| | | | 2: 00001
| | Stop Key: Inclusive Value
| | | | 1: 00001
| | | | 2: 00001
| Data Prefetch: None
| | Index Colum | 2: ID2 (Ascending)
- 1、下载文档前请自行甄别文档内容的完整性,平台不提供额外的编辑、内容补充、找答案等附加服务。
- 2、"仅部分预览"的文档,不可在线预览部分如存在完整性等问题,可反馈申请退款(可完整预览的文档不适用该条件!)。
- 3、如文档侵犯您的权益,请联系客服反馈,我们会尽快为您处理(人工客服工作时间:9:00-18:30)。
安装DB2的过程中出现的问题//出现问题一[root@localhost server]# ./db2_installERROR:The required library file libaio.so.1 is not found on the system.Check the following web site for the up-to-date system requirementsof IBM DB2 9.7/software/data/db2/udb/sysreqs.html/data/db2/linux/validateAborting the current installation ...Run installation with the option "-f sysreq" parameter to force the installation.//解决[root@localhost server]# cd ..[root@localhost /]# cd /home/chenweidan/Desktop/ftp/upload[root@localhost upload]# lsdb2client serverlibaio-0.3.106-3.2.x86_64.rpm v9.7fp2_linuxx64_server.tar.gz[root@localhost upload]# rpm -ivh libaio-0.3.106-3.2.x86_64.rpmwarning: libaio-0.3.106-3.2.x86_64.rpm: Header V3 DSA signature: NOKEY, key ID a 83bd72ePreparing... ########################################### [100%] 1:libaio ########################################### [100%][root@localhost upload]# cd server[root@localhost server]# ./db2_installDefault directory for installation of products - /opt/ibm/db2/V9.7***********************************************************Do you want to choose a different directory to install [yes/no] ?noSpecify one of the following keywords to install DB2 products.ESECONSVWSEEXPPECLIENTRTCLEnter "help" to redisplay product names.Enter "quit" to exit.***********************************************************ESEDB2 installation is being initialized.***********Total number of tasks to be performed: 47Total estimated time for all tasks to be performed: 2078……Task #46 startDescription: Registering DB2 Update ServiceEstimated time 30 second(s)Task #46 endTask #47 startDescription: Updating global profile registryEstimated time 3 second(s)Task #47 endA minor error occurred while installing "DB2 Enterprise Server Edition " onthis computer. Some features may not function correctly.//该问题尚未解决************//出现问题二[root@localhost server]# cd[root@localhost ~]# groupadd -g 999db2iadm1bash: groupadd: command not found[root@localhost ~]# useradd -u 1001 -g db2iadm1 -m -d /home/db2inst1 db2inst1bash: useradd: command not found//解决[root@localhost ~]# echo $PATH/usr/kerberos/sbin:/usr/kerberos/bin:/usr/local/bin:/usr/bin:/bin:/usr/bin:/usr/games:/home/chenwei dan/bin[root@localhost ~]# whereis groupaddgroupadd: /usr/sbin/groupadd /usr/share/man/man8/groupadd.8.gz[root@localhost ~]# ln -s /usr/sbin/groupadd /usr/kerberos/bin[root@localhost ~]# ln -s /usr/sbin/useradd /usr/kerberos/bin[root@localhost ~]# cd /usr/kerberos/bin[root@localhost bin]# lsftp gss-client kinit kpasswd krlogin ksu rcp rsh telnet v4rcpgroupadd kdestroy klist krb524init krsh kvno rlogin sim_client uuclient [root@localhost bin]# lltotal 748-rwxr-xr-x 1 root root 109472 Apr 15 2009 ftplrwxrwxrwx 1 root root 18 Oct 20 05:35 groupadd -> /usr/sbin/groupadd-rwxr-xr-x 1 root root 19568 Apr 15 2009 gss-client-rwxr-xr-x 1 root root 8744 Apr 15 2009 kdestroy-rwxr-xr-x 1 root root 23904 Apr 15 2009 kinit-rwxr-xr-x 1 root root 20424 Apr 15 2009 klist-rwxr-xr-x 1 root root 9008 Apr 15 2009 kpasswd-rwxr-xr-x 1 root root 8544 Apr 15 2009 krb524init-rwxr-xr-x 1 root root 43 Apr 15 2009 krlogin-rwxr-xr-x 1 root root 40 Apr 15 2009 krsh-rwsr-xr-x 1 root root 48736 Apr 15 2009 ksu-rwxr-xr-x 1 root root 11880 Apr 15 2009 kvno-rwxr-xr-x 1 root root 45016 Apr 15 2009 rcp-rwxr-xr-x 1 root root 40648 Apr 15 2009 rlogin-rwxr-xr-x 1 root root 32816 Apr 15 2009 rsh-rwxr-xr-x 1 root root 11216 Apr 15 2009 sim_client-rwxr-xr-x 1 root root 226408 Apr 15 2009 telnet-rwxr-xr-x 1 root root 11240 Apr 15 2009 uuclient-rwxr-xr-x 1 root root 20896 Apr 15 2009 v4rcp[root@localhost bin]# cd[root@localhost ~]# groupadd -g 999 db2iadm1[root@localhost ~]# groupadd -g 998 db2fadm1[root@localhost ~]# groupadd -g 997 dasadm1[root@localhost ~]# useradd -u 1001 -g db2iadm1 -m -d /home/db2inst1 db2inst1 [root@localhost ~]# useradd -u 1002 -g db2fadm1 -m -d /home/db2fenc1 db2fenc1 [root@localhost ~]# useradd -u 1003 -g dasadm1 -m -d /home/dasusr1 dasusr1//出现问题三[root@localhost ~]# cd /opt/ibm/db2/V9.7/instance[root@localhost instance]# dascrt -u dasusr1bash: dascrt: command not found// 解决[root@localhost instance]# ./dascrt -u dasusr1SQL4409W The DB2 Administration Server is already active.DBI1070I Program dascrt completed successfully.[root@localhost instance]# ./db2icrt -a SERVER -u db2fenc1 db2inst1DBI1766W Cannot change the secondary group list of db2inst1.Explanation:A code, 127, is returned when attempting to change the secondarygroup list of the given user ID. One of the following situations hasoccurred:* NIS is running.* One or more processes are currently being executed under the givenuser ID.User response:You must add the group ID, dasadm1, to the secondary group list ofthe user ID, db2inst1, so that the Adminstration Server can functionproperly.* If there happens to be any process run under the given user ID,terminate all of these processes and follow the instructions above tosetup the secondary group list of this user ID.* If you are running this command on an NIS client, try the aboveinstructions to setup the secondary group list of this user ID onyour NIS server.DBI1070I Program db2icrt completed successfully.[root@localhost ~]# su -l db2inst1[db2inst1@localhost ~]$ db2start10/20/2013 08:19:37 0 0 SQL1063N DB2START processing was successful. SQL1063N DB2START processing was successful.[db2inst1@localhost ~]$ db2set DB2_SKIPDELETED=ON[db2inst1@localhost ~]$ db2set DB2_HASH_JOIN=YES[db2inst1@localhost ~]$ db2set DB2_RR_TO_RS=YES[db2inst1@localhost ~]$ db2set DB2CODEPAGE=1386[db2inst1@localhost ~]$ DB2COMM=TCPIP[db2inst1@localhost ~]$ db2set DB2CODEPAGE=1386DB2COMM=TCPIP[db2inst1@localhost ~]$ db2set DB2COMM=TCPIP[db2inst1@localhost ~]$ db2set DB2_PARALLEL_IO=*[db2inst1@localhost ~]$ db2set update dbm cfg using svcename 50000DBI1302E Invalid parameter detected.[db2inst1@localhost ~]$ db2 update dbm cfg using svcename 50000DB20000I The UPDATE DA TABASE MANAGER CONFIGURATION command completed successfully.[db2inst1@localhost ~]$ db2start10/20/2013 08:30:29 0 0 SQL1026N The database manager is already active. SQL1026N The database manager is already active.[db2inst1@localhost ~]$ db2samplCreating 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@localhost ~]$ db2 connect to sampleDatabase Connection InformationDatabase server = DB2/LINUXX8664 9.7.2SQL authorization ID = DB2INST1Local database alias = SAMPLE[db2inst1@localhost ~]$ db2 "select *from staff where dept=20"ID NAME DEPT JOB YEARS SALARY COMM------ --------- ------ ----- ------ --------- ---------10 Sanders 20 Mgr 7 98357.50 -20 Pernal 20 Sales 8 78171.25 612.4580 James 20 Clerk - 43504.60 128.20190 Sneider 20 Clerk 8 34252.75 126.504 record(s) selected.[root@localhost db2inst1]# passwd db2inst1Changing password for user db2inst1.New UNIX password:Retype new UNIX password:passwd: all authentication tokens updated successfully.出师表两汉:诸葛亮先帝创业未半而中道崩殂,今天下三分,益州疲弊,此诚危急存亡之秋也。