我正在尝试在Linux-Debian 8.11 @ Virtualbox上设置MSSQL数据库,但无法通过MSSQL MSSQL Server Management Studio连接到它
服务器可ping通。
Reply from 192.168.56.101: bytes=32 time<1ms TTL=64
Reply from 192.168.56.101: bytes=32 time<1ms TTL=64
Reply from 192.168.56.101: bytes=32 time<1ms TTL=64
VirtualBox中的网络设置:
仅主机网络 VirtualBox仅限主机的以太网适配器
有什么想法吗?
TITLE: Connect to Server
------------------------------
Cannot connect to 192.168.56.101.
------------------------------
ADDITIONAL INFORMATION:
The connection to the server was successfully established, but an error occurred during the login process.
(provider: SSL Provider, error: 0 - The existing connection was sharply closed by the remote host.)
(Microsoft SQL Server, Error: 10054)
For help, click: http://go.microsoft.com/fwlink?ProdName=Microsoft%20SQL%20Server&EvtSrc=MSSQLServer&EvtID=10054&LinkId=20476
------------------------------
Connection Forcibly Closed by Remote Host
------------------------------
BUTTONS:
OK
------------------------------
Server Name: 192.168.56.101
Error Number: 10054
Severity: 20
State: 0
------------------------------
Program Location:
at System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity identity, SqlConnectionString connectionOptions, SqlCredential credential, Object providerInfo, String newPassword, SecureString newSecurePassword, Boolean redirectedUserInstance, SqlConnectionString userConnectionOptions, SessionData reconnectSessionData, DbConnectionPool pool, String accessToken, Boolean applyTransientFaultHandling, SqlAuthenticationProviderManager sqlAuthProviderManager)
at System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, DbConnection owningConnection, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection, DbConnectionPoolGroup poolGroup, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection, TaskCompletionSource`1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.ProviderBase.DbConnectionClosed.TryOpenConnection(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource`1 retry, DbConnectionOptions userOptions)
at System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`1 retry)
at System.Data.SqlClient.SqlConnection.Open()
at Microsoft.SqlServer.Management.SqlStudio.Explorer.ObjectExplorerService.ValidateConnection(UIConnectionInfo ci, IServerType server)
at Microsoft.SqlServer.Management.UI.ConnectionDlg.Connector.ConnectionThreadUser()
错误日志@服务器
2018-07-20 07:10:23.56 Server Microsoft SQL Server 2017 (RTM-CU9) (KB4341265) - 14.0.3030.27 (X64)
Jun 29 2018 18:02:47
Copyright (C) 2017 Microsoft Corporation
Developer Edition (64-bit) on Linux (Debian GNU/Linux 8 (jessie))
2018-07-20 07:10:23.57 Server UTC adjustment: -4:00
2018-07-20 07:10:23.57 Server (c) Microsoft Corporation.
2018-07-20 07:10:23.57 Server All rights reserved.
2018-07-20 07:10:23.57 Server Server process ID is 4120.
2018-07-20 07:10:23.57 Server Logging SQL Server messages in file '/var/opt/mssql/log/errorlog'.
2018-07-20 07:10:23.57 Server Registry startup parameters:
-d /var/opt/mssql/data/master.mdf
-l /var/opt/mssql/data/mastlog.ldf
-e /var/opt/mssql/log/errorlog
2018-07-20 07:10:23.58 Server SQL Server detected 1 sockets with 1 cores per socket and 1 logical processors per socket, 1 total logical processors; using 1 logical processors based on SQL Server licensing. This is an informational message; no user action is required.
2018-07-20 07:10:23.58 Server SQL Server is starting at normal priority base (=7). This is an informational message only. No user action is required.
2018-07-20 07:10:23.58 Server Detected 1810 MB of RAM. This is an informational message; no user action is required.
2018-07-20 07:10:23.58 Server Using conventional memory in the memory manager.
2018-07-20 07:10:23.69 Server Buffer pool extension is already disabled. No action is necessary.
2018-07-20 07:10:23.76 Server InitializeExternalUserGroupSid failed. Implied authentication will be disabled.
2018-07-20 07:10:23.76 Server Implied authentication manager initialization failed. Implied authentication will be disabled.
2018-07-20 07:10:23.77 Server Successfully initialized the TLS configuration. Allowed TLS protocol versions are ['1.0 1.1 1.2']. Allowed TLS ciphers are [....]
2018-07-20 07:10:23.80 Server The maximum number of dedicated administrator connections for this instance is '1'
2018-07-20 07:10:23.80 Server Node configuration: node 0: CPU mask: 0x0000000000000001:0 Active CPU mask: 0x0000000000000001:0. This message provides a description of the NUMA configuration for this computer. This is an informational message only. No user action is required.
2018-07-20 07:10:23.81 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.
2018-07-20 07:10:23.82 Server In-Memory OLTP initialized on lowend machine.
2018-07-20 07:10:23.86 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.
2018-07-20 07:10:23.87 Server Query Store settings initialized with enabled = 1,
2018-07-20 07:10:23.87 spid6s Starting up database 'master'.
2018-07-20 07:10:23.89 Server Software Usage Metrics is disabled.
2018-07-20 07:10:24.22 spid6s Resource governor reconfiguration succeeded.
2018-07-20 07:10:24.23 spid6s SQL Server Audit is starting the audits. This is an informational message. No user action is required.
2018-07-20 07:10:24.23 spid6s SQL Server Audit has started the audits. This is an informational message. No user action is required.
2018-07-20 07:10:24.31 spid6s SQL Trace ID 1 was started by login "sa".
2018-07-20 07:10:24.34 spid6s Server name is 'debian'. This is an informational message only. No user action is required.
2018-07-20 07:10:24.37 spid22s Always On: The availability replica manager is starting. This is an informational message only. No user action is required.
2018-07-20 07:10:24.38 spid9s Starting up database 'mssqlsystemresource'.
2018-07-20 07:10:24.38 spid22s Always On: The availability replica manager is waiting for the instance of SQL Server to allow client connections. This is an informational message only. No user action is required.
2018-07-20 07:10:24.38 spid23s Starting up database 'msdb'.
2018-07-20 07:10:24.38 spid9s The resource database build version is 14.00.3030. This is an informational message only. No user action is required.
2018-07-20 07:10:24.39 spid24s Starting up database 'debianIsAvaliable'.
2018-07-20 07:10:24.43 spid9s Starting up database 'model'.
2018-07-20 07:10:24.83 spid24s Parallel redo is started for database 'debianIsAvaliable' with worker pool size [1].
2018-07-20 07:10:24.94 spid9s Polybase feature disabled.
2018-07-20 07:10:24.94 spid9s Clearing tempdb database.
2018-07-20 07:10:24.98 spid6s Parallel redo is shutdown for database 'debianIsAvaliable' with worker pool size [1].
2018-07-20 07:10:25.29 spid19s A self-generated certificate was successfully loaded for encryption.
2018-07-20 07:10:25.31 spid19s Server is listening on [ 'any' <ipv6> 1433].
2018-07-20 07:10:25.31 spid19s Server is listening on [ 'any' <ipv4> 1433].
2018-07-20 07:10:25.32 Server Server is listening on [ ::1 <ipv6> 1434].
2018-07-20 07:10:25.32 Server Server is listening on [ 127.0.0.1 <ipv4> 1434].
2018-07-20 07:10:25.33 Server Dedicated admin connection support was established for listening locally on port 1434.
2018-07-20 07:10:25.35 spid19s SQL Server is now ready for client connections. This is an informational message; no user action is required.
2018-07-20 07:10:25.50 spid9s Starting up database 'tempdb'.
2018-07-20 07:10:25.76 spid9s The tempdb database has 1 data file(s).
2018-07-20 07:10:25.77 spid22s The Service Broker endpoint is in disabled or stopped state.
2018-07-20 07:10:25.78 spid22s The Database Mirroring endpoint is in disabled or stopped state.
2018-07-20 07:10:25.79 spid22s Service Broker manager has started.
2018-07-20 07:10:25.80 spid6s Recovery is complete. This is an informational message only. No user action is required.
Microsoft (R) SQLServerAgent 14.0.3030.27
Copyright (C) 2017 Microsoft Corporation. All rights reserved.
SQLAgent is disabled
SQLAgent is exiting
● mssql-server.service - Microsoft SQL Server Database Engine
Loaded: loaded (/lib/systemd/system/mssql-server.service; enabled)
Active: active (running) since Fri 2018-07-20 07:10:16 EDT; 9min ago
Docs: https://docs.microsoft.com/en-us/sql/linux
Main PID: 418 (sqlservr)
CGroup: /system.slice/mssql-server.service
├─418 /opt/mssql/bin/sqlservr
└─805 /opt/mssql/bin/sqlservr
答案 0 :(得分:0)
解决方法:
安装docker
为.NET Core应用创建连接字符串
将其输入到appsettings.json
例如"DefaultConnection": "Server=IP; Database=Test; User=sa; Password=Password;"
其中IP =例如172.17.0.5,您可以使用docker inspect name
命令找到它
另外
密码是您在创建该docker时定义的SA密码(docker run命令)。在MS的教程中,<YourStrong!Passw0rd>
您不必创建数据库(例如Test),因为EntityFramework应该这样做。 (我对此不是100%的确定,但这就是我的做法)
在Virtualbox计算机中使用“仅主机”网络设置,使您的应用对主机可见(对于Windows)
另外,您可能还需要添加nginx +创建反向代理,例如http://piotrgankiewicz.com/2017/06/12/asp-net-core-deployment-using-docker-nginx-and-ubuntu-server/#more-3847
祝你好运
其他可能有用的链接:
Docker - Container is not running
https://docs.microsoft.com/en-us/aspnet/core/host-and-deploy/proxy-load-balancer?view=aspnetcore-2.1