四、创建实例
1)创建管理服务器实例
# cd /home/dasadm1
# /opt/IBM/db2/V8.1/instance/dascrt -u dasadm1
2)创建数据库实例
# cd /home/db2inst1
# >.profile
# chown db2inst1:db2grp1 .profile
# /opt/IBM/db2/V8.1/instance/db2icrt -s ese -u db2inst1 db2inst1
注意:这个命令有一些可选的参数。特别地,选项允许我们指定一个不同于缺省的“SERVER”
特别注意的是:
在 RHEL5 中,如果创建 db2inst1 不成功,返回 22 号错误,错误信息内容为:
[Copy to clipboard][ - ]
CODE:
tail: cannot open `+2' for reading: No such file or directory
lcount = 0
DBI1069E Unexpected error. Function = chk_fsystype, Return code =
22.
Explanation:
An unexpected error occurred during the execution of this
program.
User Response:
If the problem persists, contact IBM Support with the following
information:
o Message number
o Function name
o Return code
o Problem description
DBI1079I Output is saved in the log file /tmp/db2icrt.log.13346.
Explanation:
All processed and failed operations have been saved into this log
file.
User Response:
Do not modify this file in any way. This file is for IBM
Technical Support reference.
的时候,你需要对创建实例的配置文件做如下修改:
修改 /opt/IBM/db2/V8.1/instance/db2iutil 文件,将其中的 tail +2 修改成 tail -n +2 即可。
如果 dasadm1 管理实例无法起来,可以删除 /home/dasadm1 目录下的 das ,然后重建 DB2ADMIN,然后再创建 INSTANCE。创建后可能会出现 db2cc 起不来的现象,可以在 IBM 网站上下载一个 IBMJava-1.4.2 安装到 /opt/目录下,然后换名为 IBMJava-1.4.1 欺骗系统即可。
#LD_ASSUME_KERNEL=2.2.5
#export LD_ASSUME_KERNEL
#db2set DB2ENVLIST=LD_ASSUME_KERNEL
xhost + [host_name]
export DISPLAY=[host_name]:0 or 1
db2 update dbm cfg using JDK_PATH /opt/IBMJava2-14
http://www.dbforums.com/showthread.php?threadid=789822
五、创建共享库链接
# cd /home/db2inst1
# /opt/IBM/db2/V8.1/cfg/db2ln
八、设置 db2 实例中的服务端口:
(以 db2inst1 用户操作)
1)首先需要启动 db2inst1 实例
$ db2start
2)输入DB2命令,进入DB2命令行模式
db2 => update database manager configuration using svcename server1|60000
这里是有错误德,应该先updaet dbm cfg using svcename 60000,然后db2start,要不会报
SQL5043N Support for one or more communications protocols failed to start successfully. However, core database manager functionality started successfully.
SQL1063N DB2START processing was successful.
十一、客户端连接测试(使用 db2inst1 用户操作)
在命令行模式输入如下命令即可
DB2 CATALOG TCPIP NODE mynode REMOTE hostname SERVER 60000
DB2 CATALOG DATABASE dbname AS dbname AT NODE mynode
十二、在客户端添加 ODBC 数据源测试
略:
十三、添加另一个可以使用 db2 的用户
1)用 root 用户操作,添加一个用户,如 db2 ,用户组属于 db2grp1
# useradd -g db2grp1 -m -d /home/db2 -p “” db2
2)修改 db2 用户的启动信息配置文件,设置 db2 的用户环境变量。
# cd /home/db2
# vi .bashrc
在其中加入如下信息:
# User specific aliases and function
# The following three lines have been added by UDB DB2.
if [ -f /home/db2inst1/sqllib/db2profile ]; then
. /home/db2inst1/sqllib/db2profile
fi
经过以上设置后,你就可以使用 db2 用户注册,使用 db2 了。
db2start port使用问题
http://www-01.ibm.com/support/docview.wss?rs=71&uid=swg21264632
$ db2 update dbm cfg using svcename 30542
$ db2start
$ netstat -Aan | grep 30542
f10000f303321b58 tcp4 0 0 *.30542 *.* LISTEN
The netstat command, above, shows that the port 30542 is being used for listening. To confirm that it is DB2 LUW that's using the port, run rmsock as root like following.
$ rmsock f10000f303321b58 tcpcb
The socket 0x3321800 is being held by proccess 692476 (db2sysc).
This shows that it's db2sysc process that's using the port, and its PID is 692476.
Windows Command
1. netstat -aon | findstr "<port number>"
This shows if the specified <port number> is being used. The number in the last column is the process id (PID) of the process holding the socket. Once PID is determined, one can refer to "Windows Task Manager" to determine which application corresponds to the PID.
Windows Example
C:\>netstat -aon | findstr "50000"
TCP 0.0.0.0:50000 0.0.0.0:0 LISTENING 2564
C:\>pslist 2564
pslist v1.28 - Sysinternals PsList
Copyright ⌐ 2000-2004 Mark Russinovich
Sysinternals
Process information for MACHINENAME:
Name Pid Pri Thd Hnd Priv CPU Time Elapsed Time
db2syscs 2564 8 15 366 30912 0:00:02.859 2:12:08.564
The example above shows the use of pslist to determine the name of the process. Note that pslist is a free command available from Microsoft Sysinternals at http://www.microsoft.com/technet/sysinternals/default.mspx