In DB2 pureScale, when you run the command db2instance -list, it shows the DB2 pureScale topology and which member is up and running and which CF is in PRIMARY mode and which one is in PEER mode.
If you want to change the role of CF from PRIMARY to PEER or from PEER to PRIMARY, you have two ways to do this.
Run db2instance -list command and find out the CF host which is in PRIMARY mode. You need to find out the node number which will be either 128 or 129.
$ db2instance -list ID TYPE STATE HOME_HOST CURRENT_HOST -- ---- ----- --------- ------------ 0 MEMBER STARTED node02 node02 1 MEMBER STARTED node03 node03 128 CF PRIMARY node02 node02 129 CF PEER node03 node03 HOSTNAME STATE INSTANCE_STOPPED ALERT -------- ----- ---------------- ----- node03 ACTIVE NO NO node02 ACTIVE NO NO
CAUTION: You should never switch the role of PRIMARY CF if the second CF shows in CATCHUP mode. This will trigger a GROUP RESTART. You should always confirm before switching the role if the second CF is in PEER mode and then only switch the role.
For example, node id 128 shows that it is primary. Then to change the role of the CF, stop the primary and this will trigger a failover and other CF (which was in PEER mode) will become primary.
$ db2stop 128
Confirm by using db2instance -list command if the CF is stopped or not. Wait for the CF to stop and then wait for the failover to take place. When db2instance -list shows that the other CF has become primary then run db2start to start the stopped CF done in the previous step.
$ db2start 128
Note: You need root authority to do this or you should have sudo authority to run the TSA commands.
Find out the name of the primary resource group which controls PRIMARY and STANDBY CFs.
# lssam | grep primary Online IBM.ResourceGroup:primary_db2psc_900-rg Nominal=Online '- Online IBM.Application:primary_db2psc_900-rs |- Online IBM.Application:primary_db2psc_900-rs:node02 '- Offline IBM.Application:primary_db2psc_900-rs:node03 Online IBM.Equivalency:primary_db2psc_900-rg_group-equ
Please notice in above that node02 host is Online and node03 host is offline. If you run db2instance -list command, it will show that node02 is the PRIMARY CF and node03 is the STANDBY CF.
In our example shown above, please notice that our primary resource name is primary_db2psc_900-rg. The following TSA command will switch the role of the CF. I am again writing that in order to avoid the GROUP RESTART, please make sure that the CFs are in PRIMARY and PEER mode and then only run the following command which will switch the role.
# rgreq -o move primary_db2psc_900-rg
Which one you should use DB2 way or TSA way?
It is better to use the DB2 way to change the role even though it is the longer process. I have used both the methods but I was advised to stick to the DB2 way.