DB2 terminal session – change the instance

You are connected with a terminal session to your database server and just executing the good known db2profile.
In the next step you want to execute db2 connect to blabla, but you get an error message, database is unknown – but you know, the database exists on that server… but not in that instance. You are connected to the wrong instance, because your DB server has more than one instance on it (lets call them db2inst1 and db2inst2).

You can see the error, what’s next?

Ok, lets change the value set via db2profile (or shell config), lets „overwrite“ that. For that we use the environment variable DB2INSTANCE.

export DB2INSTANCE=db2inst2

Now, executing db2 connect to blabla again, same result as before. The reason for that is, DB2 is creating a background process, which remembers the instance.

ps -ef | grep db2bp

This statement should deliver in minimum on process as result. So, how can we get to the other instance? You need to kill this process in a clean way. There is a DB2 statement for that:

db2 terminate

If this was executed, the process db2bp is gone and you can connect to the database, on the correct instance.

Some more information for db2 terminate on DB2 9.7 you can find here.

Schreibe einen Kommentar

Deine E-Mail-Adresse wird nicht veröffentlicht. Erforderliche Felder sind mit * markiert.