0

I have a requirement to enable a failover/secondary database for a DB2 database hosted on a Linux Server for a python application using the IBM_DB package.

With a JDBC driver, you can easily the following parameters to the connection string:

clientRerouteAlternatePortNumber=port#
clientRerouteAlternateServerName=servername
enableSeamlessFailover=1 

Since the IBM_DB package uses a CLI driver, these parameters wouldn't be the same. I found the following parameters through the IBM documentation, which are: https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.embed.doc/doc/c0060428.html

enableAlternateServerListFirstConnect
alternateserverlist
maxAcrRetries

However, through the instructions of how to include it in the link below, it seems like it is only possible to include them in this DB file: db2dsdriver.cfg

https://www.ibm.com/support/producthub/db2/docs/content/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.cli.doc/doc/c0056196.html

I know a lot of these parameters are configurable in the connection string, and I wanted to know if it was possible to include these particular parameters in the connection string. Is there any documentation/verification that something like this can work:

import ibm_db_dbi

connect = ibm_db_dbi.connect("DATABASE=whatever; \
    HOSTNAME=whatever; \
    PORT=whatever; \
    PROTOCOL=TCPIP; \
    UID=whatever; \
    PWD=whatever; \
    CURRENTSCHEMA=whatever;\
    AUTHENTICATION=SERVER_ENCRYPT;\
    ClientEncAlg=2;\
    enableAlternateServerListFirstConnect=True;\
    alternateserverlist=server1,port1,server2,port2;\
    maxAcrRetries=2", "", "")

Thank you for any help.

1 Answer 1

1

A helpful page to is this one.

Note the different names of keywords/parameters between jdbc/sqlj and CLI.

The idea is that with the CLI driver, if the Db2-LUW instance is properly configured, then the CLI driver will get the details of ACR from the Db2-LUW-instance automatically and useful defaults will apply . So you might not need to add more keywords in the connection string, unless tuning.

The HA related keyword parameters for CLI are below :

acrRetryInterval
alternateserverlist
detectReadonlyTxn
enableAcr
enableAlternateGroupSeamlessACR
enableAlternateServerListFirstConnect
enableSeamlessAcr
maxAcrRetries

More details here. Note that if enableACR=true ( the default ) then enableSeamlessAcr=true (also default).

Although the docs mention db2dsdriver.cfg most CLI parameter/keywords are also settable in the connection string, unless specifically excluded. So do your testing to verify.

Sign up to request clarification or add additional context in comments.

3 Comments

Thanks again for the detailed reply. It seems like the .cfg file takes a list for the alternateserverlist like so: <server name="server1" hostname="db2luwa.luw.ibm.com" port="446"/> Do you know how several parameters can be inputted in the connection string? I have not found any leads on how IBM_DB processes the connection string.
IBM_DB does not process the connection string, only the CLI driver does that. As mentioned, you should not need to specify that list, the CLI driver should get it automatically from the Db2-LUW instance at connection time.
I believe that it is configured as clientRerouteAlternateServerName from the DB instance. Will the CLI driver still be able to get it automatically with these configurations, or would the DB need to have alternateserverlist configured as well? It seems like in the link I sent above, the list is configured on the client side in the .cfg file, so I was under the impression that this should also be done by my application / in the connection string.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.