db2top -n

Continuing with the command line options from the last post, we have the -n option that takes one argument which is the node name or instance name. This becomes useful when you want to pass to the -d option the name of a database that exists under a different node than the default node.

For example, say you have a database named sample under a node named thekguy and your $DB2INSTANCE environment variable is set to thekguy. Say you catalog another node node1 and catalog the sample database under that node with a new alias data1 as follows:

db2 catalog local node node1
db2 catalog db sample as data1 at node node1

If you attempt to run db2top with a -d data1 option and do not specify the -n option, it fails with a message like the following:

SQL1428N The application is already attached to "THEKGUY" while the command
issued requires an attachment to "NODE1" for successful execution.

Exiting...

If instead, you specify db2top with the -d data1 and the -n node1 options, db2top loads successfully.

If you specify the -n option without an argument, you get the following message:

*************************************************************************

***                                                                   ***
*** Error: -n needs a node name                                       ***
***                                                                   ***
*************************************************************************

If you specify a node name that does not exist, you get an error message, as below:

db2top -d sample -n nonexist

*** Attaching to nonexist

SQL1097N The node name was not found in the node directory. SQLSTATE=42720

Exiting...