IBM Support

How to change the hostname in DB2 HADR and TSA environment system

Question & Answer


Question

What is the best and safe way to change the hostname in DB2 HADR (High Availability and Data Replication) and TSA(Tivoli System Automation) environment ?

Answer

There are many dependencies on hostname, so there is no easier way than recreating TSA environment using db2haicu.
This document describes the steps for changing hostname on both primary and standby server in DB2 HADR and TSA environment.

Following steps are the examples in case of changing the hostname like below.

Primary : 'jshadr01' to 'jshadr1'
Standby : 'jshadr02' to 'jshadr2'

Before starting this work, you should firstly check if the DB2 HADR status is Peer and all TSA status is normal.
$ db2pd -db <dbname> -hadr
$ lssam


Step 1. Delete the TSA Configuration
Execute following command from the standby server first, then do the same on primary server.

<Standby>
v97_06@jshadr02:~> db2haicu -delete

<Primary>
v97_06@jshadr01:~> db2haicu -delete

Step 2. Check if TSA configuration is deleted
 2-1. Make sure dbm cfg "CLUSTER_MGR" is null and ~/sqllib/cfg/db2ha.sys is deleted on both primary and standby system.
 

<Standby>

v97_06@jshadr02:~> db2 get dbm cfg |grep CLUSTER_MGR
 Cluster manager                           (CLUSTER_MGR) = 
v97_06@jshadr02:~> ls ~/sqllib/cfg/db2ha.sys
ls: cannot access /home/v97_06/sqllib/cfg/db2ha.sys: No such file or directory

<Primary>
v97_06@jshadr01:~> db2 get dbm cfg |grep CLUSTER_MGR

 Cluster manager                           (CLUSTER_MGR) = 

v97_06@jshadr01:~> ls ~/sqllib/cfg/db2ha.sys

ls: cannot access /home/v97_06/sqllib/cfg/db2ha.sys: No such file or directory



 

2-2. Check the output of 'lsrpnode' and 'lssam', There should be no TSA configuration.


<Standby>

v97_06@jshadr02:~> lsrpnode
lsrpnode: There are no nodes in the peer domain or an online peer domain does not exist.
v97_06@jshadr02:~> lssam
lssam: No resource groups defined or cluster is offline!

<Primary>
v97_06@jshadr01:~> lsrpnode

lsrpnode: There are no nodes in the peer domain or an online peer domain does not exist.

v97_06@jshadr01:~> lssam

lssam: No resource groups defined or cluster is offline!

Step 3. Deactivate all DB2 HADR databases and stop the instance on both primary and standby.



<Primary>

v97_06@jshadr01:~> db2 deactivate db sample

DB20000I  The DEACTIVATE DATABASE command completed successfully.

v97_06@jshadr01:~> db2 stop hadr on db sample

DB20000I  The STOP HADR ON DATABASE command completed successfully.

v97_06@jshadr01:~> db2stop

05/14/2014 09:23:12     0   0   SQL1064N  DB2STOP processing was successful.

SQL1064N  DB2STOP processing was successful.



<Standby>
v97_06@jshadr02:~> db2 deactivate db sample
DB20000I  The DEACTIVATE DATABASE command completed successfully.
v97_06@jshadr02:~> db2 stop hadr on db sample
DB20000I  The STOP HADR ON DATABASE command completed successfully.
v97_06@jshadr02:~> db2stop 
05/14/2014 09:27:21     0   0   SQL1064N  DB2STOP processing was successful.
SQL1064N  DB2STOP processing was successful.


Step 4. Change the hostname on both system and make sure the new hostname is consistent among hostname, uname, /etc/hosts and db2nodes.cfg".
  
  You may need to reboot the each system depending on the operating system.



<Standby>

jshadr2:~ # hostname

jshadr2


jshadr2:~ # cat /etc/hosts


..........

192.168.153.91  jshadr1


192.168.153.66  jshadr2

 ..........



v97_06@jshadr2:~> cat ~/sqllib/db2nodes.cfg

0 jshadr2 0


<Primary>
jshadr1:~ # hostname

jshadr1

jshadr1:~ # cat /etc/hosts

......

192.168.153.91  jshadr1 

192.168.153.66  jshadr2 

.....snippet.....

 

v97_06@jshadr1:~> cat ~/sqllib/db2nodes.cfg

0 jshadr1 0


Step 5. Start DB2 instances on both system and do not activate databases yet. 
 

Step 6. Change the DB2 configuration for 'HADR_LOCAL_HOST' and 
'HADR_REMOTE_HOST' as new hostname.
You should do the same for all databases in HADR.
 

  $ db2 update db cfg for sample using HADR_LOCAL_HOST <New hostname>
 
  $ db2 update db cfg for sample using HADR_REMOTE_HOST <New hostname>




Output :
<Standby>

v97_06@jshadr2:~> db2start
05/14/2014 09:59:58     0   0   SQL1063N  DB2START processing was successful.
SQL1063N  DB2START processing was successful.

v97_06@jshadr2:~> db2 get db cfg for sample |grep HADR |grep HOST
 HADR local host name                  (HADR_LOCAL_HOST) = jshadr02
 HADR remote host name                (HADR_REMOTE_HOST) = jshadr01

v97_06@jshadr2:~> db2 update db cfg for sample USING HADR_LOCAL_HOST jshadr2
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
v97_06@jshadr2:~> db2 update db cfg for sample USING HADR_REMOTE_HOST jshadr1
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

v97_06@jshadr2:~> db2 get db cfg for sample |grep HADR |grep HOST
 HADR local host name                  (HADR_LOCAL_HOST) = jshadr2
 HADR remote host name                (HADR_REMOTE_HOST) = jshadr1
 

<Primary>

v97_06@jshadr1:~> db2start

05/14/2014 10:03:25     0   0   SQL1063N  DB2START processing was successful.

SQL1063N  DB2START processing was successful.

v97_06@jshadr1:~> db2 get db cfg for sample |grep HADR |grep HOST

 HADR local host name                  (HADR_LOCAL_HOST) = jshadr01

 HADR remote host name                (HADR_REMOTE_HOST) = jshadr02
 

v97_06@jshadr1:~> db2 update db cfg for sample USING HADR_LOCAL_HOST jshadr1
DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.

v97_06@jshadr1:~> db2 update db cfg for sample USING HADR_REMOTE_HOST jshadr2DB20000I  The UPDATE DATABASE CONFIGURATION command completed successfully.
 

v97_06@jshadr1:~> db2 get db cfg for sample |grep HADR |grep HOST

 HADR local host name                  (HADR_LOCAL_HOST) = jshadr1

 HADR remote host name                (HADR_REMOTE_HOST) = jshadr2

 

Step 7. If there is existing configuration for ACR alternate server, update the hostname as new one for each databases.

 $ db2 "update alternate server for database <DBNAME> using hostname <New hostname> port <DBM instance port>



Output :
<Standby>

v97_06@jshadr2:~> db2 list db directory

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = SAMPLE
 
Database name                        = SAMPLE
 
Local database directory             = /home/v97_06
 
Database release level               = d.00
 
Comment                              =
 
Directory entry type                 = Indirect
 
Catalog database partition number    = 0
 
Alternate server hostname            =
jshadr01
 
Alternate server port number         = 60116

v97_06@jshadr2:~> db2 "update alternate server for database SAMPLE using hostname jshadr1 port 60116"

DB20000I  The UPDATE ALTERNATE SERVER FOR DATABASE command completed 
successfully.

DB21056W  Directory changes may not be effective until the directory cache is 
refreshed.


v97_06@jshadr2:~> db2 list db directory

 System Database Directory

 Number of entries in the directory = 1

Database 1 entry:

 Database alias                       = SAMPLE
 
Database name                        = SAMPLE
 
Local database directory             = /home/v97_06
 
Database release level               = d.00
 
Comment                              =
 
Directory entry type                 = Indirect
 
Catalog database partition number    = 0
 
Alternate server hostname            =
jshadr1
 
Alternate server port number         = 60116


<Primary>

v97_06@jshadr1:~> db2 "update alternate server for database sample using hostname jshadr2 port 60116"

DB20000I  The UPDATE ALTERNATE SERVER FOR DATABASE command completed successfully.

DB21056W  Directory changes may not be effective until the directory cache is refreshed.

 

v97_06@jshadr1:~> db2 list db directory

 System Database Directory

 Number of entries in the directory = 1 

Database 1 entry:

 Database alias                       = SAMPLE
 Database name                        = SAMPLE
 Local database directory             = /home/v97_06
 Database release level               = d.00
 Comment                              =
 Directory entry type                 = Indirect
 Catalog database partition number    = 0
 Alternate server hostname            = jshadr2
 Alternate server port number         = 60116

 

Step 8. Start Databases and make sure that it is DB2 HADR peer status.



Output :
<Standby>

v97_06@jshadr2:~> db2 start hadr on db sample as standby
DB20000I  The START HADR ON DATABASE command completed successfully.
<Primary>
 
v97_06@jshadr1:~> db2 start hadr on db sample as primary

DB20000I  The START HADR ON DATABASE command completed successfully.
 

v97_06@jshadr1:~> db2pd -db sample -hadr

 

Database Partition 0 -- Database SAMPLE -- Active -- Up 0 days 00:00:48 -- Date 2014-05-14-10.12.24.441763

 

HADR Information:

Role    State                SyncMode   HeartBeatsMissed   LogGapRunAvg (bytes)

Primary Peer                 Sync     0                  820382              

 


Step 9. On each node, run below command as root user:
         
 # /usr/sbin/rsct/install/bin/recfgct
         
 # preprpnode <newhost1> <newhost2>


Output :
<Standby>
 

jshadr2:~ # /usr/sbin/rsct/install/bin/recfgct
0513-071 The ctcas Subsystem has been added.
0513-071 The ctrmc Subsystem has been added.
0513-059 The ctrmc Subsystem has been started. Subsystem PID is 6762.

jshadr2:~ # preprpnode jshadr1 jshadr2 

<Primary>
 
jshadr1:~ # /usr/sbin/rsct/install/bin/recfgct

0513-071 The ctcas Subsystem has been added.

0513-071 The ctrmc Subsystem has been added.

0513-059 The ctrmc Subsystem has been started. Subsystem PID is 6257.

 

jshadr1:~ # preprpnode jshadr1 jshadr2

 

Step 10. Configure TSA on HADR using 'db2haicu' command with new hostname.

'db2haicu' command should be executed by db2 instance user.


Perform the 'db2haicu' command on the standby system first and do the same on primary system.

Output :
<Standby>

v97_06@jshadr2:~> db2haicu

<Primary>
v97_06@jshadr1:~> db2haicu
 

Step 11. Check the new TSA configurations with new hostname.

Output :

v97_06@jshadr1:~> lssam

Online IBM.ResourceGroup:db2_v97_06+jshadr1+0-rg Nominal=Online

        '- Online IBM.Application:db2_v97_06+jshadr1+0-rs

                '- Online IBM.Application:db2_v97_06+jshadr1+0-rs:jshadr1

Online IBM.ResourceGroup:db2_v97_06+jshadr2+0-rg Nominal=Online

        '- Online IBM.Application:db2_v97_06+jshadr2+0-rs

                '- Online IBM.Application:db2_v97_06+jshadr2+0-rs:jshadr2

Online IBM.ResourceGroup:db2_v97_06+v97_06+SAMPLE-rg Nominal=Online

        |- Online IBM.Application:db2_v97_06+v97_06+SAMPLE-rs

                |- Online IBM.Application:db2_v97_06+v97_06+SAMPLE-rs:jshadr1

                '- Offline IBM.Application:db2_v97_06+v97_06+SAMPLE-rs:jshadr2

        '- Online IBM.ServiceIP:db2ip_192_168_153_200-rs

                |- Online IBM.ServiceIP:db2ip_192_168_153_200-rs:jshadr1

                '- Offline IBM.ServiceIP:db2ip_192_168_153_200-rs:jshadr2

Online IBM.Equivalency:db2_public_network_0

        |- Online IBM.NetworkInterface:eth1:jshadr2

        '- Online IBM.NetworkInterface:eth1:jshadr1

Online IBM.Equivalency:db2_v97_06+jshadr1+0-rg_group-equ

        '- Online IBM.PeerNode:jshadr1:jshadr1

Online IBM.Equivalency:db2_v97_06+jshadr2+0-rg_group-equ

        '- Online IBM.PeerNode:jshadr2:jshadr2

Online IBM.Equivalency:db2_v97_06+v97_06+SAMPLE-rg_group-equ

        |- Online IBM.PeerNode:jshadr1:jshadr1

        '- Online IBM.PeerNode:jshadr2:jshadr2

 

Related Information

[{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"High Availability - HADR","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"}],"Version":"9.7;9.5;10.1;10.5","Edition":"","Line of Business":{"code":"LOB10","label":"Data and AI"}},{"Product":{"code":"SSEPGG","label":"Db2 for Linux, UNIX and Windows"},"Business Unit":{"code":"BU058","label":"IBM Infrastructure w\/TPS"},"Component":"High Availability - HADR","Platform":[{"code":"PF002","label":"AIX"},{"code":"PF016","label":"Linux"}],"Version":"9.7;9.5;10.1;10.5","Edition":"Advanced Enterprise Server;Advanced Workgroup Server;Enterprise Server;Workgroup Server","Line of Business":{"code":"LOB10","label":"Data and AI"}}]

Document Information

Modified date:
16 June 2018

UID

swg21673628