我是 db2 的新手,但之前在 oracle 上工作过。尝试创建数据库并成功,但我发出数据库创建命令的会话挂起。
我在 64 位 ubuntu 机器上安装了 db2 10.5。
首先,我以实例所有者身份登录db2inst1
,并在命令行上调用 db2 以访问 shell。
alok@mylaptop:~$ su - db2inst1
शब्दकूट:
$ uname -a
Linux cxps044 3.2.0-52-generic #78-Ubuntu SMP Fri Jul 26 16:21:44 UTC 2013 x86_64 x86_64 x86_64 GNU/Linux
$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 10.5.0
You can issue database manager commands and SQL statements from the command
prompt. For example:
db2 => connect to sample
db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
? CATALOG DATABASE for help on the CATALOG DATABASE command
? CATALOG for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
接下来,我将一个实例附加到 db2inst1,考虑到输出,我相信它是成功的。为此,我遵循了db2 cli install的说明。
db2 => attach to db2inst1
Instance Attachment Information
Instance server = DB2/LINUXX8664 10.5.0
Authorization ID = DB2INST1
Local instance alias = DB2INST1
接下来我尝试使用以下命令创建数据库:
db2 => create database mytestdb
这挂起,没有提供任何输出。
几个小时后检查后,我发现数据库确实创建了。
$ db2 list applications
Auth Id Application Appl. Application Id DB # of
Name Handle Name Agents
-------- -------------- ---------- -------------------------------------------------------------- -------- -----
DB2INST1 db2bp 85 *LOCAL.db2inst1.130903105030 MYTESTDB 1
DB2INST1 db2bp 86 *LOCAL.db2inst1.130903105031 EIGHTBYT 1
DB2INST1 db2bp 99 *LOCAL.db2inst1.130903110149 TUT_DB 1
但是,如何计算放弃之前要等待多长时间?是否有任何日志或其他输出可以提示是否继续等待命令完成执行?
我尝试了另一个创建数据库命令,它挂了,然后我在另一个会话中检查,发现数据库确实已经创建。
第 1 节:
$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 10.5.0
You can issue database manager commands and SQL statements from the command
prompt. For example:
db2 => connect to sample
db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
? CATALOG DATABASE for help on the CATALOG DATABASE command
? CATALOG for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
db2 => attach to db2inst1
Instance Attachment Information
Instance server = DB2/LINUXX8664 10.5.0
Authorization ID = DB2INST1
Local instance alias = DB2INST1
db2 => create database mytestd2 automatic storage yes
虽然这挂在这里,会话 2:
$ db2
(c) Copyright IBM Corporation 1993,2007
Command Line Processor for DB2 Client 10.5.0
You can issue database manager commands and SQL statements from the command
prompt. For example:
db2 => connect to sample
db2 => bind sample.bnd
For general help, type: ?.
For command help, type: ? command, where command can be
the first few keywords of a database manager command. For example:
? CATALOG DATABASE for help on the CATALOG DATABASE command
? CATALOG for help on all of the CATALOG commands.
To exit db2 interactive mode, type QUIT at the command prompt. Outside
interactive mode, all commands must be prefixed with 'db2'.
To list the current command option settings, type LIST COMMAND OPTIONS.
For more detailed help, refer to the Online Reference Manual.
db2 => attach to db2inst1
Instance Attachment Information
Instance server = DB2/LINUXX8664 10.5.0
Authorization ID = DB2INST1
Local instance alias = DB2INST1
db2 => list applications
Auth Id Application Appl. Application Id DB # of
Name Handle Name Agents
-------- -------------- ---------- -------------------------------------------------------------- -------- -----
DB2INST1 db2bp 226 *LOCAL.db2inst1.130903115709 MYTESTD2 1
db2 =>
^C
, ^X
,^Z
等在会话 1 中没有影响。
我是 db2 新手,但熟悉 oracle 和 linux/posix。
几分钟后:
我终于在会话 1 中得到了提示:
db2 => create database mytestd2 automatic storage yes
DB20000I The CREATE DATABASE command completed successfully.
db2 =>
所以这个问题有点“自动解决”,但观察结果可能对其他人有用。
嗯,从我之前关于尾随';'的答案开始
我仍然怀疑它“挂起”,因为它不是一个完整的声明,它在等待你完成它。(不幸的是,目前没有可用的 db2 实例进行测试)
尝试这个:
跑步是个好主意
在另一个会话中等待命令完成。这会告诉你是否确实发生了某些事情。