在 RHEL7 上安装 SQL Server 并收到 - Sqlcmd:错误:Microsoft ODBC Driver 13 for SQL Server:TCP 提供程序:错误代码 0x2AF9

Jos*_*ine 5 sql-server linux unixodbc sqlcmd timeout

我在 RHEL7 VM 上安装了 SQL Server

msodbcsql-13.1.1.0-1.x86_64
mssql-server-14.0.100.187-1.x86_64
mssql-tools-14.0.2.0-1.x86_64

# ls -al /opt/
total 4
drwxr-xr-x.  5 root root   52 Jan 13 08:31 .
drwxr-xr-x. 17 root root 4096 Jan 13 07:55 ..
drwxr-xr-x.  3 root root   22 Jan 13 08:31 microsoft
drwxr-xr-x.  4 root root   26 Jan 13 08:14 mssql
drwxr-xr-x.  4 root root   28 Jan 13 08:31 mssql-tools
Run Code Online (Sandbox Code Playgroud)

systemctl 表示 SQL 服务器已启动并正在运行 / 绿色

# systemctl status mssql-server
mssql-server.service - Microsoft(R) SQL Server(R) Database Engine
   Loaded: loaded (/usr/lib/systemd/system/mssql-server.service; enabled)
   Active: active (running) since Fri 2017-01-13 08:16:52 EST; 18min ago
 Main PID: 8413 (sqlservr)
   CGroup: /system.slice/mssql-server.service
           ??8413 /opt/mssql/bin/sqlservr
           ??8423 /opt/mssql/bin/sqlservr

Jan 13 08:16:55 example.novalocal sqlservr[8413]: 2017-01-13 13:16:55.33 spid17s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
Jan 13 08:16:55 example.novalocal sqlservr[8413]: 2017-01-13 13:16:55.54 spid6s      Starting up database 'tempdb'.
Jan 13 08:16:55 example.novalocal sqlservr[8413]: 2017-01-13 13:16:55.65 spid6s      The tempdb database has 1 data file(s).
Jan 13 08:16:55 example.novalocal sqlservr[8413]: 2017-01-13 13:16:55.65 spid20s     The Service Broker endpoint is in disabled or stopped state.
Jan 13 08:16:55 example.novalocal sqlservr[8413]: 2017-01-13 13:16:55.66 spid20s     The Database Mirroring endpoint is in disabled or stopped state.
Jan 13 08:16:55 example.novalocal sqlservr[8413]: 2017-01-13 13:16:55.67 spid20s     Service Broker manager has started.
Jan 13 08:16:55 example.novalocal sqlservr[8413]: 2017-01-13 13:16:55.67 spid5s      Recovery is complete. This is an informational message only. No user action is required.
Jan 13 08:21:58 example.novalocal sqlservr[8413]: 2017-01-13 13:21:58.06 spid51      Using 'dbghelp.dll' version '4.0.5'
Jan 13 08:22:02 example.novalocal sqlservr[8413]: 2017-01-13 13:22:02.41 spid51      Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required.
Jan 13 08:22:02 example.novalocal sqlservr[8413]: 2017-01-13 13:22:02.44 spid51      Using 'xplog70.dll' version '2016.140.100' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
Run Code Online (Sandbox Code Playgroud)

我无法登录

# sqlcmd -S localhost -U SA 
Password: 
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2AF9.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Run Code Online (Sandbox Code Playgroud)

没有防火墙规则

# iptables -L
Chain INPUT (policy ACCEPT)
target     prot opt source               destination         

Chain FORWARD (policy ACCEPT)
target     prot opt source               destination         

Chain OUTPUT (policy ACCEPT)
target     prot opt source               destination         
Run Code Online (Sandbox Code Playgroud)

连接工作正常

# ping 8.8.8.8
PING 8.8.8.8 (8.8.8.8) 56(84) bytes of data.
64 bytes from 8.8.8.8: icmp_seq=1 ttl=51 time=9.80 ms
64 bytes from 8.8.8.8: icmp_seq=2 ttl=51 time=9.94 ms
64 bytes from 8.8.8.8: icmp_seq=3 ttl=51 time=9.63 ms
^C
--- 8.8.8.8 ping statistics ---
3 packets transmitted, 3 received, 0% packet loss, time 2002ms
rtt min/avg/max/mdev = 9.633/9.793/9.941/0.126 ms
Run Code Online (Sandbox Code Playgroud)

也有其他名称,不起作用

# sqlcmd -S tcp:example,1433 -U SA 
Password: 
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Login timeout expired.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : TCP Provider: Error code 0x2AF9.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : A network-related or instance-specific error has occurred while establishing a connection to SQL Server. Server is not found or not accessible. Check if instance name is correct and if SQL Server is configured to allow remote connections. For more information see SQL Server Books Online..
Run Code Online (Sandbox Code Playgroud)

正在运行的进程

# ps -ef | grep sql
mssql     8416     1  0 08:16 ?        00:00:00 /opt/mssql/bin/sqlservr-telemetry /var/opt/mssql/.system
mssql     8948     1  0 08:35 ?        00:00:00 /opt/mssql/bin/sqlservr
mssql     8950  8948  3 08:36 ?        00:00:06 /opt/mssql/bin/sqlservr
root      9103  1217  0 08:39 pts/0    00:00:00 grep --color=auto sql
Run Code Online (Sandbox Code Playgroud)

这里的日志

# grep sqlservr messages 
Jan 13 08:16:52 localhost sqlservr: This is an evaluation version.  There are [151] days left in the evaluation period.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.39 Server      Microsoft SQL Server vNext (CTP1.1) - 14.0.100.187 (X64)
Jan 13 08:16:54 localhost sqlservr: Dec 10 2016 02:51:11
Jan 13 08:16:54 localhost sqlservr: Copyright (C) 2016 Microsoft Corporation. All rights reserved.
Jan 13 08:16:54 localhost sqlservr: on Linux (Red Hat Enterprise Linux Server 7.0 (Maipo))
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.39 Server      UTC adjustment: 0:00
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.39 Server      (c) Microsoft Corporation.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.39 Server      All rights reserved.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.39 Server      Server process ID is 4116.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.39 Server      Logging SQL Server messages in file 'C:\var\opt\mssql\log\errorlog'.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.40 Server      Registry startup parameters:
Jan 13 08:16:54 localhost sqlservr: -d C:\var\opt\mssql\data\master.mdf
Jan 13 08:16:54 localhost sqlservr: -l C:\var\opt\mssql\data\mastlog.ldf
Jan 13 08:16:54 localhost sqlservr: -e C:\var\opt\mssql\log\errorlog
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.41 Server      SQL Server detected 1 sockets with 4 cores per socket and 4 logical processors per socket, 4 total logical processors; using 4 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.41 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.41 Server      Detected 6260 MB of RAM. This is an informational message; no user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.42 Server      Using conventional memory in the memory manager.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.49 Server      Default collation: SQL_Latin1_General_CP1_CI_AS (us_english 1033)
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.59 Server      Buffer pool extension is already disabled. No action is necessary.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.69 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.69 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.74 Server      The maximum number of dedicated administrator connections for this instance is '1'
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.74 Server      Node configuration: node 0: CPU mask: 0x000000000000000f:0 Active CPU mask: 0x000000000000000f:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.75 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.75 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.76 Server      Query Store settings initialized with enabled = 1,
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.77 spid5s      Starting up database 'master'.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.78 Server      In-Memory OLTP initialized on lowend machine.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.81 Server      Software Usage Metrics is disabled.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.87 spid5s      8 transactions rolled forward in database 'master' (1:0). This is an informational message only. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.87 spid5s      0 transactions rolled back in database 'master' (1:0). This is an informational message only. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.88 spid5s      Recovery is writing a checkpoint in database 'master' (1). This is an informational message only. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.92 spid5s      Buffer pool extension is already disabled. No action is necessary.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.92 spid5s      Resource governor reconfiguration succeeded.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.92 spid5s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.92 spid5s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.96 spid5s      SQL Trace ID 1 was started by login "sa".
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.96 spid5s      Server name is 'xxx-sqlser'. This is an informational message only. No user action is required.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.97 spid17s     Password policy update was successful.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.98 spid5s      Starting up database 'msdb'.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.98 spid6s      Starting up database 'mssqlsystemresource'.
Jan 13 08:16:54 localhost sqlservr: 2017-01-13 13:16:54.99 spid6s      The resource database build version is 14.00.100. This is an informational message only. No user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.01 spid6s      Starting up database 'model'.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.08 spid5s      7 transactions rolled forward in database 'msdb' (4:0). This is an informational message only. No user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.09 spid5s      0 transactions rolled back in database 'msdb' (4:0). This is an informational message only. No user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.09 spid5s      Recovery is writing a checkpoint in database 'msdb' (4). This is an informational message only. No user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.11 spid6s      7 transactions rolled forward in database 'model' (3:0). This is an informational message only. No user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.11 spid6s      0 transactions rolled back in database 'model' (3:0). This is an informational message only. No user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.12 spid6s      Recovery is writing a checkpoint in database 'model' (3). This is an informational message only. No user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.22 spid6s      Polybase feature disabled.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.22 spid6s      Clearing tempdb database.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.31 spid17s     A self-generated certificate was successfully loaded for encryption.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.32 spid17s     Server is listening on [ 0.0.0.0 <ipv4> 1433].
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.32 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.33 Server      Dedicated admin connection support was established for listening locally on port 1434.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.33 spid17s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.54 spid6s      Starting up database 'tempdb'.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.65 spid6s      The tempdb database has 1 data file(s).
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.65 spid20s     The Service Broker endpoint is in disabled or stopped state.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.66 spid20s     The Database Mirroring endpoint is in disabled or stopped state.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.67 spid20s     Service Broker manager has started.
Jan 13 08:16:55 localhost sqlservr: 2017-01-13 13:16:55.67 spid5s      Recovery is complete. This is an informational message only. No user action is required.
Jan 13 08:21:58 localhost sqlservr: 2017-01-13 13:21:58.06 spid51      Using 'dbghelp.dll' version '4.0.5'
Jan 13 08:22:02 localhost sqlservr: 2017-01-13 13:22:02.41 spid51      Attempting to load library 'xplog70.dll' into memory. This is an informational message only. No user action is required.
Jan 13 08:22:02 localhost sqlservr: 2017-01-13 13:22:02.44 spid51      Using 'xplog70.dll' version '2016.140.100' to execute extended stored procedure 'xp_msver'. This is an informational message only; no user action is required.
Jan 13 08:35:59 localhost sqlservr: 2017-01-13 13:35:59.43 spid5s      SQL Server is terminating in response to a 'stop' request from Service Control Manager. This is an informational message only. No user action is required.
Jan 13 08:36:00 localhost sqlservr: 2017-01-13 13:36:00.15 spid20s     Service Broker manager has shut down.
Jan 13 08:36:00 localhost sqlservr: 2017-01-13 13:36:00.24 spid5s      SQL Server shutdown has been initiated
Jan 13 08:36:00 localhost sqlservr: 2017-01-13 13:36:00.24 spid5s      SQL Trace was stopped due to server shutdown. Trace ID = '1'. This is an informational message only; no user action is required.
Jan 13 08:36:00 localhost sqlservr: This is an evaluation version.  There are [151] days left in the evaluation period.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.78 Server      Microsoft SQL Server vNext (CTP1.1) - 14.0.100.187 (X64)
Jan 13 08:36:02 localhost sqlservr: Dec 10 2016 02:51:11
Jan 13 08:36:02 localhost sqlservr: Copyright (C) 2016 Microsoft Corporation. All rights reserved.
Jan 13 08:36:02 localhost sqlservr: on Linux (Red Hat Enterprise Linux Server 7.0 (Maipo))
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.78 Server      UTC adjustment: 0:00
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.79 Server      (c) Microsoft Corporation.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.79 Server      All rights reserved.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.79 Server      Server process ID is 4116.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.79 Server      Logging SQL Server messages in file 'C:\var\opt\mssql\log\errorlog'.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.79 Server      Registry startup parameters:
Jan 13 08:36:02 localhost sqlservr: -d C:\var\opt\mssql\data\master.mdf
Jan 13 08:36:02 localhost sqlservr: -l C:\var\opt\mssql\data\mastlog.ldf
Jan 13 08:36:02 localhost sqlservr: -e C:\var\opt\mssql\log\errorlog
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.81 Server      SQL Server detected 1 sockets with 4 cores per socket and 4 logical processors per socket, 4 total logical processors; using 4 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.81 Server      SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.81 Server      Detected 6260 MB of RAM. This is an informational message; no user action is required.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.81 Server      Using conventional memory in the memory manager.
Jan 13 08:36:02 localhost sqlservr: 2017-01-13 13:36:02.89 Server      Default collation: SQL_Latin1_General_CP1_CI_AS (us_english 1033)
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:02.99 Server      Buffer pool extension is already disabled. No action is necessary.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.09 Server      InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.09 Server      Implied authentication manager initialization failed. Implied authentication will be disabled.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.14 Server      The maximum number of dedicated administrator connections for this instance is '1'
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.14 Server      Node configuration: node 0: CPU mask: 0x000000000000000f:0 Active CPU mask: 0x000000000000000f:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.15 Server      Using dynamic lock allocation.  Initial allocation of 2500 Lock blocks and 5000 Lock Owner blocks per node.  This is an informational message only.  No user action is required.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.15 Server      Database Instant File Initialization: enabled. For security and performance considerations see the topic 'Database Instant File Initialization' in SQL Server Books Online. This is an informational message only. No user action is required.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.16 Server      Query Store settings initialized with enabled = 1,
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.17 spid5s      Starting up database 'master'.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.17 Server      In-Memory OLTP initialized on lowend machine.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.21 Server      Software Usage Metrics is disabled.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.41 spid5s      Buffer pool extension is already disabled. No action is necessary.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.41 spid5s      Resource governor reconfiguration succeeded.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.41 spid5s      SQL Server Audit is starting the audits. This is an informational message. No user action is required.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.42 spid5s      SQL Server Audit has started the audits. This is an informational message. No user action is required.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.47 spid5s      SQL T

Mar*_*miK 1

我相信这是 PORT 问题,

请在防火墙例外中添加为 SQL 配置的端口 (1433/1434)。

使用下面的命令打开配置

sudo system-config-firewall-tui
Run Code Online (Sandbox Code Playgroud)

以上将为 RHEL6 或更高版本打开“终端用户界面 (TUI) 防火墙客户端”

在此输入图像描述

在此输入图像描述

在此输入图像描述

在此输入图像描述

在此输入图像描述

或者

使用 iptables 命令在防火墙中打开新的 TCP/UDP 端口。要永久保存更新的规则,您需要第二个命令。

$ sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
$ sudo service iptables save
Run Code Online (Sandbox Code Playgroud)

这应该可以让它发挥作用