Python软件包IBM_DB连接,带有enableAlternateServerListFirstConnect和alternateserverlist参数 [英] Python package IBM_DB connection with enableAlternateServerListFirstConnect and alternateserverlist parameters

查看:106
本文介绍了Python软件包IBM_DB连接,带有enableAlternateServerListFirstConnect和alternateserverlist参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我需要使用IBM_DB软件包为Linux应用程序上的python应用程序启用Linux服务器上托管的DB2数据库的故障转移/辅助数据库.

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.

使用JDBC驱动程序,您可以轻松地在连接字符串中使用以下参数:

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

clientRerouteAlternatePortNumber=port#
clientRerouteAlternateServerName=servername
enableSeamlessFailover=1 

由于IBM_DB软件包使用CLI驱动程序,所以这些参数将不同.我通过IBM文档找到了以下参数,它们是:https://www.ibm.com/support/knowledgecenter/SSEPGG_11.5.0/com.ibm.db2.luw.apdv.embed.doc/doc/c0060428.html

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

但是,通过下面的链接中的说明,似乎只能将它们包括在以下数据库文件中:db2dsdriver.cfg

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", "", "")

谢谢您的帮助.

推荐答案

请注意jdbc/sqlj和CLI之间关键字/参数的不同名称.

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

这个想法是,使用CLI驱动程序,如果正确配置了Db2-LUW实例,则CLI驱动程序将自动从Db2-LUW-instance获取ACR的详细信息,并将应用有用的默认值.因此,除非进行调整,否则可能不需要在连接字符串中添加更多关键字.

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.

HA 相关的关键字参数如下:

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).

尽管文档中提到了 db2dsdriver.cfg ,但除非明确排除,否则大多数CLI参数/关键字也可以在连接字符串中设置.因此,请进行测试以进行验证.

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.

这篇关于Python软件包IBM_DB连接,带有enableAlternateServerListFirstConnect和alternateserverlist参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆