I am new to db2 but have worked on oracle before. Trying to create a database and it succeeds, but the session where I issued a database creation command hangs.
I have installed db2 10.5 on a 64 bit ubuntu machine.
First, I logged in as db2inst1
which is the instance owner, and invoked db2 on the command line, to get to the 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.
Next I attached an instance to db2inst1, which I believe was successful considering the output. I followed instructions from db2 cli install for this.
db2 => attach to db2inst1
Instance Attachment Information
Instance server = DB2/LINUXX8664 10.5.0
Authorization ID = DB2INST1
Local instance alias = DB2INST1
Next I attempted to create the database using this command:
db2 => create database mytestdb
And this hangs, without providing any output.
After checking a few hours later, I found that the database did get created.
$ 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
However, how does one figure out how long to wait before giving up? Is there any log or other output that can give a cue on whether to keep waiting for the command to complete execution?
I tried another create database command, which hanged, and then I checked in another session to find that the database has indeed been created.
Session 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
While this is hanging here, session 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
and so on in session 1 has no impact.
I am new to db2, but familiar with oracle and linux/posix.
A few minutes later:
I finally got the prompt back in session 1:
db2 => create database mytestd2 automatic storage yes
DB20000I The CREATE DATABASE command completed successfully.
db2 =>
So this question is kind of "auto resolved", but the observations might be useful to someone else.