Changing the Hostname for a DB2 Server

Posted by Frank Fillmore on November 14, 2008 under DB2 for Linux Unix Windows. Tags: , , .

Sorry I haven’t posted in a little while.  October was a 250 hour month with a critical customer project and the IBM Information OnDemand Conference (IOD – you know all about IOD from Kim).  My VP of Biz Dev is all about trying to make her “number”, so it’s been busy.

The Fillmore Group is an IBM Authorized Training Partner (ATP) so we use a product called Acronis to create a single image of our student lab machines and then deploy that image to multiple PCs.  Since these are Windows XP PCs running DB2 9 for Linux, Unix, Windows Fixpack (FP) 2, the computer name must be unique within the domain.  However, once you change the computer name, DB2 stops working.  The common error is SQL1042C.  Here’s how to fix that problem.

First, there is a file in each DB2 instance subdirectory (e.g. “c:\Program Files\IBM\SQLLIB\DB2”) called db2nodes.cfg; in this post we’re only going to address single-node (i.e. not Data Partitioning Feature or DPF) databases.  Open this file for each DB2 instance on the server – I use WordPad – and change the imbedded hostname to the current computer name for that PC.  The same hostname will be repeated twice on a single line in the db2nodes.cfg file.  Change both.  This used to be all you needed to do to fix the problem.  Now, there are a few more steps.

If you installed using the extended operating system security option, you likely will now receive an SQL1652N file I/O error.  In DB2 9.1 FP 2, support was added for domain userids and groups.  Use the db2extsec command to correct the authorities for the installation-defined groups DB2ADMNS and DB2USERS.  For example, let’s say the PC image was created using a computer name of TFGXP01.  We’ve deployed this image to another PC and changed the Windows computer name to TFGXP02.  Enter the command:

db2extsec -a TFGXP02\DB2ADMNS -u TFGXP02\DB2USERS

The last step involves correcting the DB2 registry variables.  Use the db2set -all command to examine the current registry variables.  In our example, you likely will have seen three variables with TFGXP01 as part of the value.  Issue the following commands:

db2set db2accountname=TFGXP02\db2admin

db2set db2instowner=TFGXP02

db2set db2system=TFGXP02

At this point, you should be able to start the DB2 instances.