FAQ: How to configure the JDBC driver for automatic client re-route
FAQ: How to configure the JDBC driver for automatic client re-route
https://www.ibm.com/support/pages/faq-how-configure-jdbc-driver-automatic-client-re-route
Recommended Resources
Abstract
There are multiple methods to configure the JDBC driver (db2jcc.jar/db2jcc4.jar) for automatic client reroute. What are the pros and cons of each method? How does this relate to High Availability Disaster Recovery (HADR)?
Content
For configuring non-Java applications refer to HOWTO: Configure non-Java for automatic client reroute.
What is Automatic Client Reroute (ACR) ?
Automatic client reroute is an IBM® Data Server feature that redirects client applications from a failed server to an alternate server so the applications can continue their work with minimal interruption.
How is ACR related to High Availability And Disaster Recovery (HADR) ?
The ACR functionality is entirely separate from HADR. They are two different functionalities which are independent of each other. Some configurations use only the ACR portion without HADR because the application performs SELECT queries without any INSERT/UPDATE/DELETEs.
How is ACR configured with DB2 pureScale or DB2 for z/OS SYSPLEX?
For more information, see the following articles:
What are the methods to configure ACR ?
There are three methods to configure ACR, each with their advantage/disadvantage.
There are three methods to configure ACR, each with their advantage/disadvantage.
For methods (1) and (2) below lets assume that:
The port number is port used by DB2 to listen for connections (DBM CFG SVCENAME parameter).
Primary: test1.ibm.com:50000
Secondary: test2.ibm.com:60000
Database is named SAMPLE on both systems.
(1) DB2 Alternate Server
Pros: Easy to implement.
If the client is unable to make an initial connection to test1.ibm.com to retrieve the alternate server list, then the client checks to see what values are set in the parameters clientRerouteAlternateServerName and clientRerouteAlternatePortNumber. If the connection to test1.ibm.com is successful, then the retrieved alternate server information overrides clientRerouteAlternateServerName and clientRerouteAlternatePortNumber.
On the Client system:
clientRerouteAlternateServerName=test2.ibm.com
clientRerouteAlternatePortNumber=60000
On the DB2 Primary system:
db2 "update alternate server for sample using hostname test2.ibm.com port 60000"
Check the configuration to confirm that the alternate server information has been set.
db2 "list db directory"
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = -1
Alternate server hostname = test2.ibm.com
Alternate server port number = 60000
On the DB2 Secondary system:
db2 "update alternate server for sample using hostname test1.ibm.comport 50000"
Check the configuration to confirm the alternate server information has been set.
db2 "list db directory"
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = -1
Alternate server hostname = test1.ibm.com
Alternate server port number = 50000
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = -1
Alternate server hostname = test2.ibm.com
Alternate server port number = 60000
On the DB2 Secondary system:
db2 "update alternate server for sample using hostname test1.ibm.comport 50000"
Check the configuration to confirm the alternate server information has been set.
db2 "list db directory"
Database 1 entry:
Database alias = SAMPLE
Database name = SAMPLE
Database release level = d.00
Comment =
Directory entry type = Indirect
Catalog database partition number = -1
Alternate server hostname = test1.ibm.com
Alternate server port number = 50000
(2) JDBC Driver Properties
Pros: Easy to implement
enableClientAffinitiesList=1
clientRerouteAlternateServerName=test1.ibm.com,test2.ibm.com
clientRerouteAlternatePortNumber=50000,60000
Note: If you are setting the JDBC driver properties from the Websphere Admin Console:
enableClientAffinitiesList Integer type
clientRerouteAlternateServerName String type
clientRerouteAlternatePortNumber String type
See "JDBC Driver Properties" for other JDBC property data types
This method hard codes the primary and secondary connectivity information in the JDBC client. There are no server-side dependencies, but it may be labor intensive to set these values if there are many JDBC clients.
For more information, see Client affinities for Db2 on Linux, UNIX, and Windows systems.
clientRerouteAlternateServerName String type
clientRerouteAlternatePortNumber String type
See "JDBC Driver Properties" for other JDBC property data types
This method hard codes the primary and secondary connectivity information in the JDBC client. There are no server-side dependencies, but it may be labor intensive to set these values if there are many JDBC clients.
For more information, see Client affinities for Db2 on Linux, UNIX, and Windows systems.
(3) JNDI via Websphere
Pros: Alternate server information is persistent
Cons: More complex to implement
For more information, see Building a high availability database environment using Websphere Part1.
Cons: More complex to implement
For more information, see Building a high availability database environment using Websphere Part1.
Additional ACR Parameters
For more details on the keywords below please refer to JDBC Driver Configuration Keywords in the Related Links section.
enableSeamlessFailover: Determines if application receives SQLException to let it know that ACR has occurred.
maxRetriesForClientReroute: Controls number of tries to primary system
retryIntervalForClientReroute: Amount of time to wait before retries
interruptProcessingMode: See notes in regards to how Statement.cancel() is handled with ACR
TCP/IP keepalive parameters may also have to be adjusted. These are outside the scope and expertise of DB2 Defect Support.
Additional Notes:
If using hostnames for the alternate servers, ensure these hostnames are valid on the client side.
nslookup <host name>
If hostname cannot be found add it to the Domain Name Server or:
Linux/Unix: /etc/hosts
Windows: %WINDIR%\System32\drivers\etc\hosts
自然语言处理爱好者,欢迎交流。QQ: 7214218
分类:
DB2
【推荐】国内首个AI IDE,深度理解中文开发场景,立即下载体验Trae
【推荐】编程新体验,更懂你的AI,立即体验豆包MarsCode编程助手
【推荐】抖音旗下AI助手豆包,你的智能百科全书,全免费不限次数
【推荐】轻量又高性能的 SSH 工具 IShell:AI 加持,快人一步
· 被坑几百块钱后,我竟然真的恢复了删除的微信聊天记录!
· 没有Manus邀请码?试试免邀请码的MGX或者开源的OpenManus吧
· 【自荐】一款简洁、开源的在线白板工具 Drawnix
· 园子的第一款AI主题卫衣上架——"HELLO! HOW CAN I ASSIST YOU TODAY
· Docker 太简单,K8s 太复杂?w7panel 让容器管理更轻松!
2021-06-22 Natural Language Processing with Python