为什么一个 ODBC 连接工作而第二个不工作?
Why does one ODBC connection work and the second doesn't?
我在 Ubuntu 14.04 上使用 ODBC 和 FreeTDS。我们现在有三台服务器,它们在任何时候都可能是 运行 数据库(一次只有一台)。
我尝试将第二台服务器添加到我的 freetds.conf 和 odbc.ini 文件中,但它永远无法连接,即使指定相同的 IP 地址进行测试也是如此。
ODBC.ini 文件
[Default]
Driver=NewFreeTDS
[MKMSDef]
Driver=NewFreeTDS
serverName=MKMSDefault
[MKMSSecond]
Driver=NewFreeTDS
serverName=MKMSSecond
[VP]
Driver=NewFreeTDS
ServerName=VirtualPrinter
freetds.conf 文件
[global]
tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
dump file = /tmp/freetds.log
debug flags = 0xffff
# Command and connection timeouts
timeout = 10
connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
[MKMSSecond]
host = 10.1.10.71
database = MKMSDefault
port = 2638
[MKMSDefault]
host = 10.1.10.71
database = MKMSDefault
port = 2638
[VirtualPrinter]
host = 10.1.10.22
database = VP
port = 2638
command isql MKMSDef 用户密码连接成功
命令 isql MKMSSecond 用户传递失败
我认为这两者之间没有什么不同。
Edit
After some further testing. It does not appear that it is reading all of the information to know what to connect to. Whatever is specified as "ServerName" in odbc.ini has to be the database name. It also needs to be defined in freetds.conf, but only the IP and Port are required there.
If I connect to a machine that only has one database running, the servername does not matter.
This does not seem like the correct behavior.
您已经部分了解到,如果您的命名保持一致、简单且顺序相同,就会容易得多。这是一个例子:
freetds.conf
[bob]
host = bob.myserver.com
port = 1433
tds version = 7.2
[fred]
host = fred.myserver.com
port = 1433
tds version = 7.2
[joe]
host = joe.myserver.com
port = 1433
tds version = 7.2
odbc.ini
[bob]
Driver = FreeTDS
Server =bob.myserver.com
Port = 1433
TDS_Version = 7.2
[fred]
Driver = FreeTDS
Server = fred.myserver.com
Port = 1433
TDS_Version = 7.2
[joe]
Driver = FreeTDS
Server = joe.myserver.com
Port = 1433
TDS_Version = 7.2
如果您已清理但仍有问题,请提供 isql -v
中的详细信息,以便我们了解产生了什么错误。
对于这个特定项目,问题是因为它是一个 ASA 数据库。
指定 ASA database = MKMSDefault instead of just database = MKMSDefault
解决了我的问题。在阅读文档时,我以某种方式错过了差异化。
我知道这是旧问题,我前段时间解决了这个问题,但认为它可以帮助其他人。
来自 FreeTDS.conf 用户指南:(http://www.freetds.org/userguide/freetdsconf.htm)
ASA database - Specifies the name of the default database when connecting to an ASA server. A TDS 5.0 login packet has a field called lservname. For most TDS servers, lservname is a user-defined string with no inherent meaning. ASA servers, however, requires that lservname contain a valid database name, and sets that as the default database for the connection. FreeTDS normally fills lservname with the [section] text.. This entry instead sets the database name independently of the [section] name.
我在 Ubuntu 14.04 上使用 ODBC 和 FreeTDS。我们现在有三台服务器,它们在任何时候都可能是 运行 数据库(一次只有一台)。
我尝试将第二台服务器添加到我的 freetds.conf 和 odbc.ini 文件中,但它永远无法连接,即使指定相同的 IP 地址进行测试也是如此。
ODBC.ini 文件
[Default]
Driver=NewFreeTDS
[MKMSDef]
Driver=NewFreeTDS
serverName=MKMSDefault
[MKMSSecond]
Driver=NewFreeTDS
serverName=MKMSSecond
[VP]
Driver=NewFreeTDS
ServerName=VirtualPrinter
freetds.conf 文件
[global]
tds version = 4.2
# Whether to write a TDSDUMP file for diagnostic purposes
# (setting this to /tmp is insecure on a multi-user system)
dump file = /tmp/freetds.log
debug flags = 0xffff
# Command and connection timeouts
timeout = 10
connect timeout = 10
# If you get out-of-memory errors, it may mean that your client
# is trying to allocate a huge buffer for a TEXT field.
# Try setting 'text size' to a more reasonable limit
text size = 64512
[MKMSSecond]
host = 10.1.10.71
database = MKMSDefault
port = 2638
[MKMSDefault]
host = 10.1.10.71
database = MKMSDefault
port = 2638
[VirtualPrinter]
host = 10.1.10.22
database = VP
port = 2638
command isql MKMSDef 用户密码连接成功 命令 isql MKMSSecond 用户传递失败
我认为这两者之间没有什么不同。
Edit After some further testing. It does not appear that it is reading all of the information to know what to connect to. Whatever is specified as "ServerName" in odbc.ini has to be the database name. It also needs to be defined in freetds.conf, but only the IP and Port are required there.
If I connect to a machine that only has one database running, the servername does not matter.
This does not seem like the correct behavior.
您已经部分了解到,如果您的命名保持一致、简单且顺序相同,就会容易得多。这是一个例子:
freetds.conf
[bob]
host = bob.myserver.com
port = 1433
tds version = 7.2
[fred]
host = fred.myserver.com
port = 1433
tds version = 7.2
[joe]
host = joe.myserver.com
port = 1433
tds version = 7.2
odbc.ini
[bob]
Driver = FreeTDS
Server =bob.myserver.com
Port = 1433
TDS_Version = 7.2
[fred]
Driver = FreeTDS
Server = fred.myserver.com
Port = 1433
TDS_Version = 7.2
[joe]
Driver = FreeTDS
Server = joe.myserver.com
Port = 1433
TDS_Version = 7.2
如果您已清理但仍有问题,请提供 isql -v
中的详细信息,以便我们了解产生了什么错误。
对于这个特定项目,问题是因为它是一个 ASA 数据库。
指定 ASA database = MKMSDefault instead of just database = MKMSDefault
解决了我的问题。在阅读文档时,我以某种方式错过了差异化。
我知道这是旧问题,我前段时间解决了这个问题,但认为它可以帮助其他人。
来自 FreeTDS.conf 用户指南:(http://www.freetds.org/userguide/freetdsconf.htm)
ASA database - Specifies the name of the default database when connecting to an ASA server. A TDS 5.0 login packet has a field called lservname. For most TDS servers, lservname is a user-defined string with no inherent meaning. ASA servers, however, requires that lservname contain a valid database name, and sets that as the default database for the connection. FreeTDS normally fills lservname with the [section] text.. This entry instead sets the database name independently of the [section] name.