sql-server – 在RHEL7上安装SQL Server并收到 – Sqlcmd:错误:用于SQL Server的Microsoft ODBC驱动程序13:TCP提供程序:错误代码0x2AF9

我在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

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.

我无法登录

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

没有防火墙规则

# 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         

连接工作正常

# 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

还有其他名称,不起作用

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

进程正在运行

# 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

这里的日志

# 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 Trace ID 1 was started by login "sa".
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.50 spid5s      Server name is 'xxx-sqlser'. This is an informational message only. No user action is required.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.51 spid5s      Starting up database 'msdb'.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.51 spid6s      Starting up database 'mssqlsystemresource'.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.52 spid6s      The resource database build version is 14.00.100. This is an informational message only. No user action is required.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.54 spid6s      Starting up database 'model'.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.69 spid17s     A self-generated certificate was successfully loaded for encryption.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.69 spid6s      Polybase feature disabled.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.69 spid6s      Clearing tempdb database.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.70 spid17s     Server is listening on [ 0.0.0.0 <ipv4> 1433].
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.70 Server      Server is listening on [ 127.0.0.1 <ipv4> 1434].
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.70 Server      Dedicated admin connection support was established for listening locally on port 1434.
Jan 13 08:36:03 localhost sqlservr: 2017-01-13 13:36:03.70 spid17s     SQL Server is now ready for client connections. This is an informational message; no user action is required.
Jan 13 08:36:04 localhost sqlservr: 2017-01-13 13:36:04.01 spid6s      Starting up database 'tempdb'.
Jan 13 08:36:04 localhost sqlservr: 2017-01-13 13:36:04.25 spid6s      The tempdb database has 1 data file(s).
Jan 13 08:36:04 localhost sqlservr: 2017-01-13 13:36:04.25 spid20s     The Service Broker endpoint is in disabled or stopped state.
Jan 13 08:36:04 localhost sqlservr: 2017-01-13 13:36:04.25 spid20s     The Database Mirroring endpoint is in disabled or stopped state.
Jan 13 08:36:04 localhost sqlservr: 2017-01-13 13:36:04.26 spid20s     Service Broker manager has started.
Jan 13 08:36:04 localhost sqlservr: 2017-01-13 13:36:04.28 spid5s      Recovery is complete. This is an informational message only. No user action is required.

在第一次评论后编辑

# sqlcmd -S xxx-sqlser -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..

# netstat -tupan | grep 1433
tcp        0      0 0.0.0.0:1433            0.0.0.0:*               LISTEN      8950/sqlservr       
tcp        0      0 127.0.0.1:43245         127.0.0.1:1433          ESTABLISHED 8950/sqlservr       
tcp        0      0 127.0.0.1:1433          127.0.0.1:43245         ESTABLISHED 8950/sqlservr 

新错误

# sqlcmd -S tcp:127.0.0.1,1434
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : SSPI Provider: No Kerberos credentials available.
Sqlcmd: Error: Microsoft ODBC Driver 13 for SQL Server : Cannot generate SSPI context.

无法运行简单的SQL语句.为什么这里的登录工作?

# sqlcmd -S tcp:127.0.0.1,1434 -U SA
Password: 
1> Select @@version;
2> SELECT SERVERPROPERTY('productversion'), SERVERPROPERTY ('productlevel'),
3> SERVERPROPERTY ('edition');
4> 

-A选项不存在.我的VM上没有安装Firewall-CMD(最小安装),我按照故障排除指南进行操作.

# sqlcmd -A -S tcp:127.0.0.1,1434 -U SA 
Sqlcmd: 'A': Unknown Option. Enter '-?' for help.

# sqlcmd -?
Microsoft (R) SQL Server Command Line Tool
Version 13.0.0001.0 Linux
Copyright (c) 2012 Microsoft. All rights reserved.

usage: sqlcmd            [-U login id]          [-P password]
  [-S server or Dsn if -D is provided] 
  [-H hostname]          [-E trusted connection]
  [-N Encrypt Connection][-C Trust Server Certificate]
  [-d use database name] [-l login timeout]     [-t query timeout]
  [-h headers]           [-s colseparator]      [-w screen width]
  [-a packetsize]        [-e echo input]        [-I Enable Quoted Identifiers]
  [-c cmdend]
  [-q "cmdline query"]   [-Q "cmdline query" and exit]
  [-m errorlevel]        [-V severitylevel]     [-W remove trailing spaces]
  [-u unicode output]    [-r[0|1] msgs to stderr]
  [-i inputfile]         [-o outputfile]
  [-k[1|2] remove[replace] control characters]
  [-y variable length type display width]
  [-Y fixed length type display width]
  [-p[1] print statistics[colon format]]
  [-R use client regional setting]
  [-K application intent]
  [-M multisubnet failover]
  [-b On error batch abort]
  [-D Dsn flag, indicate -S is Dsn] 
  [-X[1] disable commands, startup script, environment variables [and exit]]
  [-x disable variable substitution]
  [-? show syntax summary]

here错误日志.没有coredumps和SQL转储.

# sqlcmd -S tcp:127.0.0.1,1434 -U SA
Password:
1> PRINT "Length: 5"" 7'";
2> GO
Length: 5" 7'
1> Select @@version;
2> GO

------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------------
Microsoft SQL Server vNext (CTP1.1) - 14.0.100.187 (X64)
        Dec 10 2016 02:51:11
        Copyright (C) 2016 Microsoft Corporation. All rights reserved.
        on Linux (Red Hat Enterprise Linux Server 7.0 (Maipo))

(1 rows affected)
最佳答案
我相信这是PORT问题,

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

使用下面的命令打开配置

sudo system-config-firewall-tui

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

enter image description here

enter image description here

enter image description here

enter image description here

enter image description here

要么

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

$sudo iptables -I INPUT -p tcp -m tcp --dport 80 -j ACCEPT
$sudo service iptables save

这应该使它工作

转载注明原文:sql-server – 在RHEL7上安装SQL Server并收到 – Sqlcmd:错误:用于SQL Server的Microsoft ODBC驱动程序13:TCP提供程序:错误代码0x2AF9 - 代码日志