Db2

oracle 使用者的 db2 LUW 幫助:創建數據庫掛起,沒有任何輸出,但數據庫已創建

  • September 4, 2013

我是 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 實例進行測試)

嘗試這個:

CREATE DATABASE mytestdb
 AUTOMATIC STORAGE YES

跑步是個好主意

db2 list applications

在另一個會話中等待命令完成。這會告訴你是否確實發生了某些事情。

引用自:https://dba.stackexchange.com/questions/49145