Sou novo no db2, mas já trabalhei no oracle antes. Tentando criar um banco de dados e foi bem-sucedido, mas a sessão em que emiti um comando de criação de banco de dados trava.
Eu instalei o db2 10.5 em uma máquina ubuntu de 64 bits.
Primeiro, loguei como db2inst1
o proprietário da instância e invoquei o db2 na linha de comando para acessar o 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.
Em seguida, anexei uma instância a db2inst1, que acredito ter sido bem-sucedida considerando a saída. Eu segui as instruções da instalação do db2 cli para isso.
db2 => attach to db2inst1
Instance Attachment Information
Instance server = DB2/LINUXX8664 10.5.0
Authorization ID = DB2INST1
Local instance alias = DB2INST1
Em seguida, tentei criar o banco de dados usando este comando:
db2 => create database mytestdb
E isso trava, sem fornecer nenhuma saída.
Depois de verificar algumas horas depois, descobri que o banco de dados foi criado.
$ 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
No entanto, como descobrir quanto tempo esperar antes de desistir? Existe algum log ou outra saída que possa dar uma dica sobre se deve continuar esperando o comando concluir a execução?
Tentei outro comando create database, que travou, e verifiquei em outra sessão para descobrir se o banco de dados foi realmente criado.
Sessão 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
Enquanto isso está pendurado aqui, sessão 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
e assim por diante na sessão 1 não tem impacto.
Sou novo no db2, mas familiarizado com oracle e linux/posix.
Alguns minutos depois:
Eu finalmente recebi o prompt de volta na sessão 1:
db2 => create database mytestd2 automatic storage yes
DB20000I The CREATE DATABASE command completed successfully.
db2 =>
Portanto, esta questão é meio que "resolvida automaticamente", mas as observações podem ser úteis para outra pessoa.
hmm, risque minha resposta anterior sobre um final ';'
Ainda suspeito que esteja "pendurado" porque não é uma declaração completa, está esperando que você a complete. (infelizmente não tenho uma instância db2 disponível no momento para testar)
tente isso:
É uma boa ideia correr
em outra sessão enquanto espera a conclusão do comando. Isso diria a você se algo está realmente acontecendo.