【问题标题】:FreeTDS - Unable to connect: Adaptive Server is unavailable or does not existFreeTDS - 无法连接:Adaptive Server 不可用或不存在
【发布时间】:2014-05-24 08:51:26
【问题描述】:

CENTOS 6.5 x86_64 WHM 11.42.1 unixODBC 2.2.14

freetds v0.91

我正在尝试连接到远程 MSSQL 服务器但没有成功 - 还尝试连接不同的 tds 版本(4.2、7.0、7.1、8.0),但都给出了相同的结果。

使用相同的服务器名称、端口、用户名和密码,我可以使用 Win7 和 SQL Server Management Studio 通过我的桌面进行连接。

Telnet 也失败了。

详情如下。如果您需要更多,请告诉我。感谢所有帮助/建议。

========

tsql -C

Compile-time settings (established with the "configure" script)
                            Version: freetds v0.91
             freetds.conf directory: /etc
     MS db-lib source compatibility: yes
        Sybase binary compatibility: yes
                      Thread safety: yes
                      iconv library: yes
                        TDS version: 4.2
                              iODBC: no
                           unixodbc: yes
              SSPI "trusted" logins: no
                           Kerberos: yes

========

tsql -H testDSN -pXXXX -U 'testuser' -P 'testpass'

locale is "en_US.UTF-8"
locale charset is "UTF-8"
using default charset "UTF8"
20Error 20009 (severity 9):
        Unable to connect: Adaptive Server is unavailable or does not exist
        OS error 110, "Connection timed out"
There was a problem connecting to the server

=======

isql -v testDSN 'testuser' 'testpass'

[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[08S01][unixODBC][FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist
[ISQL]ERROR: Could not SQLConnect

======== osql -S testDSN -U 'testuser' -P 'testpass' ...

Configuration looks OK.  Connection details:

                   DSN: testDSN
              odbc.ini: /etc/odbc.ini
                Driver: /usr/lib64/libtdsodbc.so
       Server hostname: winsrv106.pleskdns.co.uk
               Address: x.x.x.x

Attempting connection as testuser ...
+ isql testDSN testuser 'testpass' -v
[S1000][unixODBC][FreeTDS][SQL Server]Unable to connect to data source
[08S01][unixODBC][FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist
[ISQL]ERROR: Could not SQLConnect
net.c:205:FAILED Connecting to x.x.x.x port XXXX (TDS version 7.1)

========

更多 freetds.log

log.c:196:Starting log file for FreeTDS 0.91
        on 2014-04-10 15:33:03 with debug flags 0x4fff.
iconv.c:330:tds_iconv_open(0x7233e0, UTF8)
iconv.c:187:local name for ISO-8859-1 is ISO-8859-1
iconv.c:187:local name for UTF-8 is UTF-8
iconv.c:187:local name for UCS-2LE is UCS-2LE
iconv.c:187:local name for UCS-2BE is UCS-2BE
iconv.c:349:setting up conversions for client charset "UTF8"
iconv.c:351:preparing iconv for "UTF8" <-> "UCS-2LE" conversion
iconv.c:391:preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion
iconv.c:394:tds_iconv_open: done
net.c:205:Connecting to x.x.x.x port XXXX (TDS version 7.1)
net.c:270:tds_open_socket: connect(2) returned "Operation now in progress"
net.c:306:getsockopt(2) reported: Connection timed out
net.c:316:tds_open_socket() failed
util.c:331:tdserror(0x723140, 0x7233e0, 20009, 110)
util.c:361:tdserror: client library returned TDS_INT_CANCEL(2)
util.c:384:tdserror: returning TDS_INT_CANCEL(2)
mem.c:615:tds_free_all_results()

========

telnet x.x.x.x

Trying x.x.x.x... 
telnet: connect to address x.x.x.x: 
Connection timed out

【问题讨论】:

  • 有人知道“Adaptive Server 不可用或不存在”是什么意思吗?
  • 当我通过 SQL Server Management Studio 连接时,远程服务器凭据必须没问题...并且 osql 在本地服务器上声明“配置看起来没问题”。唯一的线索是在 freetds.log 中指出“tds_open_socket() failed”。有谁知道是什么原因造成的?
  • 刚刚发现:"Unable to open socket" 是 src/tds/net.c::tds_open_socket() 产生的 TDSECONN。这是 inet_addr(3) 或(更有可能)socket(3) 失败的结果。虽然您确实无法连接,但更准确地说,您被本地阻止尝试连接。要连接你需要一个本地资源——一个套接字——而你无法创建一个。我希望日志显示“套接字创建错误”和操作系统的错误消息。如果 EACCES 是问题所在,我不会感到惊讶。 (在这种情况下 telnet(1) 也会失败。)lists.ibiblio.org/pipermail/freetds/2009q3/025094.html
  • 在本地服务器上的所需端口打开入站和出站后解决
  • 嗨,我们遇到了同样的错误。你能告诉我你是如何具体解决这个问题的吗?我花了将近 2 天的时间来解决这个错误。谢谢

标签: centos freetds unixodbc


【解决方案1】:

我第一次使用 Pymssql 时看到了这个错误。我必须打开 TCP/IP 作为我本地安装 SQL Server 的网络协议之一。

【讨论】:

    【解决方案2】:

    我遇到了同样的问题,并通过使用自定义端口解决了它: 端口 = XXXX 在 freetds.conf 中 此端口应在 SQL Server 配置管理中配置

    SQL Server 网络配置 -> TCP/IP(启用)-> IP 地址 -> IPAll -> TCP 动态端口

    https://msdn.microsoft.com/en-us/library/ms177440.aspx

    【讨论】:

    • 我还必须在 freetds.conf 中添加 tds version = 8.0
    【解决方案3】:

    我在 Cygwin 64 安装上的类似解决方案,将 FreeTDS 连接到本地计算机上的 SQL Server 2008 数据库。必须为 MSSQLServer 服务启用 TCP/IP 协议并重新启动服务才能解决。

    freetds.log 跟踪激活导致我找到了解决方案(日志示例如下):

    11:16:13.960012 10688 (log.c:167):Starting log file for FreeTDS 0.95.69
        on 2015-11-26 11:16:13 with debug flags 0xffff.<br>
    11:16:13.960012 10688 (iconv.c:328):tds_iconv_open(0x60004b500, UTF-8)<br>
    11:16:13.960012 10688 (iconv.c:187):local name for ISO-8859-1 is ISO-8859-1<br>
    11:16:13.960012 10688 (iconv.c:187):local name for UTF-8 is UTF-8<br>
    11:16:13.960012 10688 (iconv.c:187):local name for UCS-2LE is UCS-2LE<br>
    11:16:13.960012 10688 (iconv.c:187):local name for UCS-2BE is UCS-2BE<br>
    11:16:13.960012 10688 (iconv.c:346):setting up conversions for client charset "UTF-8"<br>
    11:16:13.960012 10688 (iconv.c:348):preparing iconv for "UTF-8" <-> "UCS-2LE" conversion<br>
    11:16:13.960012 10688 (iconv.c:395):preparing iconv for "ISO-8859-1" <-> "UCS-2LE" conversion<br>
    11:16:13.960012 10688 (iconv.c:400):tds_iconv_open: done<br>
    11:16:13.960012 10688 (net.c:202):Connecting to ?.?.?.? port 1433 (TDS version 7.3)<br><br>
    11:16:13.963012 10688 (net.c:274):tds_open_socket: connect(2) returned "Operation now in progress"<br>
    11:16:14.963069 10688 (net.c:309):getsockopt(2) reported: Connection refused<br>
    11:16:14.963069 10688 (net.c:319):tds_open_socket() failed<br>
    11:16:14.963069 10688 (util.c:322):tdserror(0x600049ad0, 0x60004b500, 20009, 111)<br>
    11:16:14.963069 10688 (odbc.c:2343):msgno 20009 20003<br>
    11:16:14.963069 10688 (util.c:352):tdserror: client library returned TDS_INT_CANCEL(2)<br>
    11:16:14.963069 10688 (util.c:375):tdserror: returning TDS_INT_CANCEL(2)<br>
    11:16:14.963069 10688 (mem.c:648):tds_free_all_results()<br>
    11:16:14.964069 10688 (error.c:414):odbc_errs_add: "Unable to connect to data source"<br>
    11:16:14.964069 10688 (error_export.h:23):SQLError(0x0, 0x600049b70, 0x0, 0x22ba50, 0x22ba4c, 0x22c540, 513, 0x22ba46)<br>
    11:16:14.964069 10688 (error.c:565):SQLGetDiagRec: "[FreeTDS][SQL Server]Unable to connect: Adaptive Server is unavailable or does not exist"<br>
    11:16:14.964069 10688 (error_export.h:23):SQLError(0x0, 0x600049b70, 0x0, 0x22ba50, 0x22ba4c, 0x22c540, 513, 0x22ba46)<br>
    11:16:14.964069 10688 (error.c:565):SQLGetDiagRec: "[FreeTDS][SQL Server]Unable to connect to data source"<br>
    

    【讨论】:

      【解决方案4】:

      我在 VirtualBox 中运行 MS Windows。

      所以我必须从我的 mac 主机访问 MS SQLServer:

      • 在 VirtualBox > 设备 > 网络 > 网络中添加端口转发条目 设置 > 高级

      • 在 MS 控制面板 > Windows 防火墙 > 高级中打开端口 1444 设置 > 入站规则

      • 在 SQL Server 配置管理器中启动 SQL Server Browser > SQL 服务器服务

      • 在 SQL Server 配置管理器 > 协议中启用 TCP

      • 在 SQL Server 配置管理器 > 协议 > TCP/IP > 属性中将 TCPAll 的 TCP 端口设置为 1444...

      请注意,MS SQL Server 配置为侦听端口 1444。

      【讨论】:

      • 非常感谢。你的解决方案解决了我的问题。
      猜你喜欢
      • 1970-01-01
      • 2019-08-23
      • 2015-10-27
      • 1970-01-01
      • 1970-01-01
      • 2019-12-30
      • 2019-02-09
      • 2022-12-24
      • 1970-01-01
      相关资源
      最近更新 更多