DB2: Enabling support for high availability data replication
Optional: To prevent data loss on DB2®, modify the JCR schema to support high availability data replication (HADR).
Before you begin
About this task
Tip: Read the following tips before you enable support for high availability data replication:
- Do NOT set the custom property enableClientAffinitiesList to true. It is not necessary with newer DB2 versions. Setting this value to true in DB2 10.1 means that ONLY servers that are listed in the alternative server names list are used for connecting to the database.
- The db2inst1 and lcuser values need to be the same passwords on both DB2 servers.
Procedure
- Stop the portal server. Depending on your environment, you might have multiple portal servers to stop.
- Back up the JCR database. The reconfigure-jcr-for-hadr task permanently changes the JCR schema.
- Open a command prompt and change to the wp_profile_root\ConfigEngine directory.
- Run the reconfigure-jcr-for-hadr task to convert columns in ICMUTMWIDE0
table from NOT LOGGED BLOB (Binary Large Object) TO LOGGED BLOB. Note: For clustered environments, run this task only from one node.
- AIX® HP-UX Linux Solaris: ./ConfigEngine.sh reconfigure-jcr-for-hadr -DTransferDomainList=jcr -DWasPassword=password
- Windows: ConfigEngine.bat reconfigure-jcr-for-hadr -DTransferDomainList=jcr -DWasPassword=password
- Start the portal server.
- Complete the following steps on the primary databases:
- Add ports for each portal database and for both database servers in the
/etc/services file:
DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END 60003/tcp db2c_db2inst1 50000/tcp DB2_HADR_COM_1 50003/tcp DB2_HADR_COM_2 50004/tcp DB2_HADR_JCR_1 50005/tcp DB2_HADR_JCR_2 50006/tcp DB2_HADR_LIK_1 50007/tcp DB2_HADR_LIK_2 50008/tcp DB2_HADR_FEE_1 50009/tcp DB2_HADR_FEE_2 50010/tcp DB2_HADR_REL_1 50011/tcp DB2_HADR_REL_2 50012/tcp DB2_HADR_CUS_1 50013/tcp DB2_HADR_CUS_2 50002/tcp
DB2_HADR_DB_1 represents a database on the primary server. DB2_HADR_DB_2 represents a database on the standby server.
- Run the following command, for each portal database, to enable log archiving in the
databases:
db2 update db cfg for DBNAME using LOGARCHMETH1 LOGRETAIN
The archive logs are stored in the log directory. The databases are placed into the backup pending state, which is required for the standby server.
- Run the following command for each portal database to take an offline backup:
db2 "backup database DBNAME"
- Enter the following commands to configure the HADR parameters:
db2 update db cfg for DBNAME using HADR_LOCAL_HOST IP_ADDRESS_OF_PRIMARY db2 update db cfg for DBNAME using HADR_LOCAL_SVC PORT_NUMBER_OF_PRIMARY db2 update db cfg for DBNAME using HADR_REMOTE_HOST IP_ADDRESS_OF_STNDBY db2 update db cfg for DBNAME using HADR_REMOTE_SVC PORT_NUMBER_OF_STNDBY db2 update db cfg for DBNAME using HADR_REMOTE_INST INSTNAME_OF_STNDBY db2 update db cfg for DBNAME using HADR_TIMEOUT 120 db2 update db cfg for DBNAME using HADR_SYNCMODE NEARSYNC db2 update db cfg for DBNAME using HADR_SPOOL_LIMIT 0 db2 update db cfg for DBNAME using HADR_REPLAY_DELAY 0 db2 update db cfg for DBNAME using HADR_PEER_WINDOW 0 db2 update db cfg for DBNAME using LOGINDEXBUILD ON
For example:db2 update db cfg for COM85DB using HADR_LOCAL_HOST psvtclc08.rtp.raleigh.ibm.com db2 update db cfg for COM85DB using HADR_LOCAL_SVC 50003 db2 update db cfg for COM85DB using HADR_REMOTE_HOST 9.37.17.237 db2 update db cfg for COM85DB using HADR_REMOTE_SVC 50004 db2 update db cfg for COM85DB using HADR_REMOTE_INST db2inst1 db2 update db cfg for COM85DB using HADR_TIMEOUT 120 db2 update db cfg for COM85DB using HADR_SYNCMODE NEARSYNC db2 update db cfg for COM85DB using HADR_SPOOL_LIMIT 0 db2 update db cfg for COM85DB using HADR_REPLAY_DELAY 0 db2 update db cfg for COM85DB using HADR_PEER_WINDOW 0 db2 update db cfg for COM85DB using LOGINDEXBUILD ON
- Enter the following command to update the database catalog with alternative server
information:
UPDATE ALTERNATE SERVER FOR DATABASE database USING HOSTNAME hostname PORT instance_portnumber
For example:db2 UPDATE ALTERNATE SERVER FOR DATABASE COM85DB USING HOSTNAME 9.37.17.237 PORT 50000
- Run the following command for each portal database to take an offline backup:
db2 "backup database DBNAME"
- Add ports for each portal database and for both database servers in the
/etc/services file:
- Complete the following steps on the standby databases:
- Ensure that both the primary and standby servers are on the same DB2 level so that a mismatch situation does not occur. Run the db2level command on both servers to check whether they are on the same DB2 version and fix pack.
- Add ports for each portal database and for both database servers in the
/etc/services file:
DB2_db2inst1 60000/tcp DB2_db2inst1_1 60001/tcp DB2_db2inst1_2 60002/tcp DB2_db2inst1_END 60003/tcp db2c_db2inst1 50000/tcp DB2_HADR_COM_1 50003/tcp DB2_HADR_COM_2 50004/tcp DB2_HADR_JCR_1 50005/tcp DB2_HADR_JCR_2 50006/tcp DB2_HADR_LIK_1 50007/tcp DB2_HADR_LIK_2 50008/tcp DB2_HADR_FEE_1 50009/tcp DB2_HADR_FEE_2 50010/tcp DB2_HADR_REL_1 50011/tcp DB2_HADR_REL_2 50012/tcp DB2_HADR_CUS_1 50013/tcp DB2_HADR_CUS_2 50002/tcp
DB2_HADR_DB_1 represents a database on the primary server. DB2_HADR_DB_2 represents a database on the standby server.
- Copy the backup images from the primary server to the standby server.
- Run the following command to restore the database:
db2 "restore database DBNAME"
- Enter the following commands to configure the HADR parameters:
db2 update db cfg for DBNAME using HADR_LOCAL_HOST IP_ADDRESS_OF_STNDBY db2 update db cfg for DBNAME using HADR_LOCAL_SVC PORT_NUMBER_OF_STNDBY db2 update db cfg for DBNAME using HADR_REMOTE_HOST IP_ADDRESS_OF_PRIMARY db2 update db cfg for DBNAME using HADR_REMOTE_SVC PORT_NUMBER_OF_PRIMARY db2 update db cfg for DBNAME using HADR_REMOTE_INST INSTNAME_OF_PRIMARY db2 update db cfg for DBNAME using HADR_TIMEOUT 120 db2 update db cfg for DBNAME using HADR_SYNCMODE NEARSYNC db2 update db cfg for DBNAME using HADR_SPOOL_LIMIT 0 db2 update db cfg for DBNAME using HADR_REPLAY_DELAY 0 db2 update db cfg for DBNAME using HADR_PEER_WINDOW 0 db2 update db cfg for DBNAME using LOGINDEXBUILD ON
For example:db2 update db cfg for COM85DB using HADR_LOCAL_HOST 9.37.17.237 db2 update db cfg for COM85DB using HADR_LOCAL_SVC 50004 db2 update db cfg for COM85DB using HADR_REMOTE_HOST psvtclc08.rtp.raleigh.ibm.com db2 update db cfg for COM85DB using HADR_REMOTE_SVC 50003 db2 update db cfg for COM85DB using HADR_REMOTE_INST db2inst1 db2 update db cfg for COM85DB using HADR_TIMEOUT 120 db2 update db cfg for COM85DB using HADR_SYNCMODE NEARSYNC db2 update db cfg for COM85DB using HADR_SPOOL_LIMIT 0 db2 update db cfg for COM85DB using HADR_REPLAY_DELAY 0 db2 update db cfg for COM85DB using HADR_PEER_WINDOW 0 db2 update db cfg for COM85DB using LOGINDEXBUILD ON
- Enter the following command to update the database catalog with alternative server
information:
UPDATE ALTERNATE SERVER FOR DATABASE database USING HOSTNAME hostname PORT instance_portnumber
For example:db2 UPDATE ALTERNATE SERVER FOR DATABASE COM85DB USING HOSTNAME psvtclc08.rtp.raleigh.ibm.com PORT 50000
- Run the following command to start the HADR on the standby server for each portal
database:
db2 start hadr on database DBNAME as standby
- Complete the following steps on the primary server:
- Run the following command to activate the database:
db2 activate database DBNAME
- Run the following command for each portal database to start the HADR:
db2 start hadr on database DBNAME as primary
- Run the following command to activate the database:
- Run the following command to verify that the HADR is running:
db2pd -db DBNAME -hadr
- Complete the following steps to set up the IBM® WebSphere® Application Server
JDBC connections:
Go to FAQ: How to configure the JDBC driver for automatic client re-route, option 2, for information and the latest updates.
- Log in to the WebSphere Integrated Solutions Console.
- Go to Resources > JDBC > JDBC providers > wpdbJDBC_db2 > Data sources > JCR85DBLADS > WebSphere Application Server data source properties.
- Go to the Advanced DB2 features section.
- Ensure that the following information is set:
- Retry interval for client reroute: Enter a minimum of 5 seconds.
- Maximum retries for client reroute: Enter a minimum of 3 retries.
- Alternate server names: Enter an alternative server.
- Alternate port numbers: For example, enter 50000.
- Save your changes.
- Restart the WebSphere Application Server application servers.
- Validate the connection by testing it for each data source.