简体   繁体   English

Python package IBM_DB 连接与 enableAlternateServerListFirstConnect 和alternateserverlist 参数

[英]Python package IBM_DB connection with enableAlternateServerListFirstConnect and alternateserverlist parameters

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. 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:使用 JDBC 驱动程序,您可以轻松地将以下参数添加到连接字符串:

clientRerouteAlternatePortNumber=port#
clientRerouteAlternateServerName=servername
enableSeamlessFailover=1 

Since the IBM_DB package uses a CLI driver, these parameters wouldn't be the same.由于 IBM_DB package 使用 CLI 驱动程序,因此这些参数不会相同。 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 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但是,通过下面链接中如何包含它的说明,似乎只能将它们包含在这个 DB 文件中: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 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.感谢您的任何帮助。

A helpful page to is this one .一个有用的页面是这个

Note the different names of keywords/parameters between jdbc/sqlj and CLI.请注意 jdbc/sqlj 和 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.这个想法是,对于 CLI 驱动程序,如果正确配置了 Db2-LUW 实例,那么 CLI 驱动程序将自动从 Db2-LUW 实例获取 ACR 的详细信息,并且将应用有用的默认值。 So you might not need to add more keywords in the connection string, unless tuning.因此,您可能不需要在连接字符串中添加更多关键字,除非进行调整。

The HA related keyword parameters for CLI are below: CLI 的HA相关关键字参数如下:

acrRetryInterval
alternateserverlist
detectReadonlyTxn
enableAcr
enableAlternateGroupSeamlessACR
enableAlternateServerListFirstConnect
enableSeamlessAcr
maxAcrRetries

More details here .更多细节在这里 Note that if enableACR=true ( the default ) then enableSeamlessAcr=true (also default).请注意,如果enableACR=true (默认值)则enableSeamlessAcr=true (也是默认值)。

Although the docs mention db2dsdriver.cfg most CLI parameter/keywords are also settable in the connection string, unless specifically excluded.尽管文档提到db2dsdriver.cfg ,但大多数 CLI 参数/关键字也可以在连接字符串中设置,除非特别排除。 So do your testing to verify.所以做你的测试来验证。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM