0

I have some databases on DB2 on an AIX server.

I login as the DB2 instance user id "chandroo" (having the db2profile set automatically when i login) and issue a command as below and get no result.

chandroo@xxxxxxxx::/db2/chandroo> db2 list db directory
chandroo@xxxxxxxx::/db2/chandroo>

However if I invoke the db2 directly from the installation directory I am able to see the entries , and I have no clue as to why it happens.

chandroo@xxxxxxxxx::/opt/IBM/db2/V9.5/bin> ./db2 list db directory

 System Database Directory

 Number of entries in the directory = 2

Database 1 entry:

 Database alias                       = CHANDB
 Database name                        = CHANDB
 Local database directory             = /db2/chandroo/db
 Database release level               = c.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

Database 2 entry:

 Database alias                       = CHAN
 Database name                        = CHAN
 Local database directory             = /db2/chandroo/db
 Database release level               = c.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            =
 Alternate server port number         =

chandroo@xxxxxxxxx::/opt/IBM/db2/V9.5/bin>
Chandru
  • 336
  • 1
  • 5
  • 14
  • I also note that none of the db2 commands are working for this instance, chandroo@xxxxxxxx::/db2/chandroo> db2 get dbm cfg chandroo@xxxxxxxx::/db2/chandroo> – Chandru Aug 07 '13 at 23:48
  • 1
    When you log in as the user chandroo, what do you get from the command `which db2` ? – Ian Bjorhovde Aug 09 '13 at 06:14
  • @IanBjorhovde : I guess you have caught a point. `chandroo@XXXXXXXX::/db2/chandroo> which db2 ./db2` But if I give some other instance as shown below, I get a path as result. Perhaps is that the reason ? `instant1@XXXXXXXXX::/home/instant1> which db2` `/home/instant1/sqllib/bin/db2` – Chandru Aug 10 '13 at 08:43
  • What is the file /db2/chandroo/db2 ? Is it a binary, shell script, etc? I would make it non-executable (`chmod a-x /db2/chandroo/db2`), validate that `which db2` returns the correct executable (`/db2/chandroo/sqllib/bin/db2`) and then see if everything works again. – Ian Bjorhovde Aug 11 '13 at 19:40
  • @IanBjorhovde : you saved my day !!! I am unable to upvote as i cliked on vote button twice and get the error : "You've already undone your vote on this comment; you cannot upvote it again" – Chandru Aug 12 '13 at 10:30

1 Answers1

2

It sounds like the db2profile script isn't being sourced properly. The environment variables defined in that script need to be set for your current AIX shell process, not a temporary subprocess started by sh, ksh, or bash. This is accomplished by specifying a single dot instead of a program name to run the db2profile script. The difference is subtle, but important.

If that is the problem, running this command will fix the problem by properly initializing your current shell process:

. ~chandroo/sqllib/db2profile

and commands like db2 list db directory will start working.

The next step is to determine what is keeping that from happening in your $HOME/.profile startup script. If you see the call to db2profile using the proper syntax as shown above, there might be a problem with the execution permissions on $HOME/.profile.

Fred Sobotka
  • 5,252
  • 22
  • 32
  • I tried your advice but still the issue persists. Here is my .profile file below : `chandroo@a25cirdb022::/db2/chandroo> cat .profile PATH=/usr/bin:/etc:/usr/sbin:/usr/ucb:$HOME/bin:/usr/bin/X11:/sbin:. export PATH if [ -f /db2/chandroo/sqllib/db2profile ]; then . /db2/chandroo/sqllib/db2profile fi` – Chandru Aug 10 '13 at 08:32
  • Additionally, I notice these unusual things as below : `chandroo@a25cirdb022::/db2/chandroo> db2 asdasd chandroo@a25cirdb022::/db2/chandroo> db2 some argument out of space chandroo@a25cirdb022::/db2/chandroo> db2 xyz chandroo@a25cirdb022::/db2/chandroo>` No Error is thrown for invalid argument by the DB2 – Chandru Aug 10 '13 at 08:46