在 Windows 10 Azure VM 上安装 SQL Server 2017

在 Windows 10 Azure VM 上安装 SQL Server 2017

我将一台 Azure Windows 10 VM 设置为工作站,其中包括:

  • Visual Studio 2017
  • Python 2.7
  • NodeJS
  • SQL 服务器 2017

当同事创建新的 Windows 10 VM 并安装 SQL Server 时,他收到错误。然后,我创建了一个新的 Windows 10 VM 并尝试安装 SQL Server,但收到相同的错误。我认为这与 VM 配置有关,因此我选择了有效的原始配置,再次尝试,但再次失败。

以下是我们使用过的 Windows 10 机器
标准 D2 v2(2 个 vcpus,7 GB 内存):成功
标准 DS11 v2(2 个 vcpus,14 GB 内存):失败
标准 DS11 v2(2 个 vcpus,14 GB 内存):失败
标准 D2 v2(2 个 vcpus,7 GB 内存):失败

这是来自安装详细文件:
......

(01) 2018-01-05 18:10:04 Slp:当前 SqlServer 连接已关闭...
(01) 2018-01-05 18:10:04 Slp:在计时 ConfigRC 和方案 ConfigRC 期间,功能 SQL_Engine_Core_Inst 的配置操作失败。
(01) 2018-01-05 18:10:04 Slp:与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。 未找到或无法访问服务器。 验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接)
(01) 2018-01-05 18:10:04 Slp:当前异常的配置失败类别为 ConfigurationFailure
(01) 2018-01-05 18:10:05 Slp:在计时 ConfigRC 和方案 ConfigRC 期间,功能 SQL_Engine_Core_Inst 的配置操作失败。
(01) 2018-01-05 18:10:05 Slp:Microsoft.SqlServer.Configuration.Sco.ScoException:与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。 未找到或无法访问服务器。 验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接)---> System.Data.SqlClient.SqlException:建立与 SQL Server 的连接时发生与网络相关或特定于实例的错误。未找到或无法访问服务器。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接) ---> System.ComponentModel.Win32Exception:系统找不到指定的文件
(01) 2018-01-05 18:10:05 Slp:--- 内部异常堆栈跟踪结束 ---
(01) 2018-01-05 18:10:05 Slp:在 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)
(01) 2018-01-05 18:10:05 Slp:在 System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 选项、DbConnectionPoolKey poolKey、Object poolGroupProviderInfo、DbConnectionPool 池、DbConnection owningConnection、DbConnectionOptions userOptions)
(01)2018-01-05 18:10:05 Slp:在 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection、DbConnectionPoolGroup poolGroup、DbConnectionOptions userOptions)
(01)2018-01-05 18:10:05 Slp:位于 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection、TaskCompletionSource 1 次重试、DbConnectionOptions userOptions) (01)2018-01-05 18:10:05 Slp:位于 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 次重试) (01)2018-01-05 18:10:05 Slp:位于 System.Data.SqlClient.SqlConnection.Open() (01)2018-01-05 18:10:05 Slp:位于 Microsoft.SqlServer.Configuration.Sco.SqlScriptExecution.GetConnection() (01) 2018-01-05 18:10:05 Slp:位于 Microsoft.SqlServer.Configuration.Sco.SqlScriptExecution.Connect() (01) 2018-01-05 18:10:05 Slp: --- 内部异常堆栈跟踪结束 --- (01) 2018-01-05 18:10:05 Slp:位于 Microsoft.SqlServer.Configuration.Sco.SqlScriptExecution.Connect() (01) 2018-01-05 18:10:05 Slp:位于 Microsoft.SqlServer.Configuration.SqlEngine.SqlDatabaseServiceConfig.Install(SqlServiceInstallScriptParameters scriptParameters,Boolean fTemplateDB) (01) 2018-01-05 18:10:05 Slp:位于Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.ConfigSQLServerSystemDatabases(EffectiveProperties 属性、布尔 isConfiguringTemplateDBs、布尔 useInstallInputs) (01)2018-01-05 18:10:05 Slp:位于 Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.DoCommonDBStartConfig(ConfigActionTiming 计时) (01)2018-01-05 18:10:05 Slp:位于 Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.Install(ConfigActionTiming 计时、Dictionary 2 actionData、PublicConfigurationBase spcbCurrent) (01)2018-01-05 18:10:05 Slp:位于Microsoft.SqlServer.Configuration.SqlConfigBase.SqlFeatureConfigBase.Execute(ConfigActionScenario 场景、ConfigActionTiming 计时、ConfigBaseAction 动作、Dictionary 2 actionData、PublicConfigurationBase spcb) (01)2018-01-05 18:10:05 Slp:在 Microsoft.SqlServer.Configuration.SqlConfigBase.PrivateConfigurationBase.Execute(ConfigActionScenario 场景、ConfigActionTiming 计时、ConfigBaseAction 动作、Dictionary 2 actionData、PublicConfigurationBase spcbCurrent) (01)2018-01-05 18:10:05 Slp:在 Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.ExecuteAction(String actionId) (01)2018-01-05 18:10:05 Slp:在 Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.Execute(String actionId,TextWriter errorStream) (01)2018-01-05 18:10:05 Slp:内部异常类型:System.Data.SqlClient.SqlException (01)2018-01-05 18:10:05 Slp:消息:1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
(01) 2018-01-05 18:10:05 Slp: at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource

1 retry)
(01) 2018-01-05 18:10:05 Slp: at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource









2 actionData, PublicConfigurationBase spcb)
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlConfigBase.PrivateConfigurationBase.Execute(ConfigActionScenario scenario, ConfigActionTiming timing, ConfigBaseAction action, Dictionary

2 actionData, PublicConfigurationBase spcbCurrent)
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.ExecuteAction(String actionId)
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlConfigBase.SlpConfigAction.Execute(String actionId, TextWriter errorStream)
(01) 2018-01-05 18:10:05 Slp: The following is an exception stack listing the exceptions in outermost to innermost order
(01) 2018-01-05 18:10:05 Slp: Inner exceptions are being indented
(01) 2018-01-05 18:10:05 Slp:
(01) 2018-01-05 18:10:05 Slp: Exception type: Microsoft.SqlServer.Configuration.Sco.ScoException
(01) 2018-01-05 18:10:05 Slp: Message:
(01) 2018-01-05 18:10:05 Slp: A network-related or instance-specific error occurred while establishing a connection to SQL Server. The server was not found or was not accessible. Verify that the instance name is correct and that SQL Server is configured to allow remote connections. (provider: Named Pipes Provider, error: 40 - Could not open a connection to SQL Server)
(01) 2018-01-05 18:10:05 Slp: HResult : 0x84bb0001
(01) 2018-01-05 18:10:05 Slp: FacilityCode : 1211 (4bb)
(01) 2018-01-05 18:10:05 Slp: ErrorCode : 1 (0001)
(01) 2018-01-05 18:10:05 Slp: Data:
(01) 2018-01-05 18:10:05 Slp: DisableRetry = true
(01) 2018-01-05 18:10:05 Slp: SQL.Setup.FailureCategory = ConfigurationFailure
(01) 2018-01-05 18:10:05 Slp: WatsonConfigActionData = INSTALL@CONFIGRC@SQL_ENGINE_CORE_INST
(01) 2018-01-05 18:10:05 Slp: WatsonExceptionFeatureIdsActionData = System.String[]
(01) 2018-01-05 18:10:05 Slp: Stack:
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.Sco.SqlScriptExecution.Connect()
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlEngine.SqlDatabaseServiceConfig.Install(SqlServiceInstallScriptParameters scriptParameters, Boolean fTemplateDB)
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.ConfigSQLServerSystemDatabases(EffectiveProperties properties, Boolean isConfiguringTemplateDBs, Boolean useInstallInputs)
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.DoCommonDBStartConfig(ConfigActionTiming timing)
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlEngine.SqlEngineDBStartConfig.Install(ConfigActionTiming timing, Dictionary

2 actionData, PublicConfigurationBase spcbCurrent)
(01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlConfigBase.SqlFeatureConfigBase.Execute(ConfigActionScenario scenario, ConfigActionTiming timing, ConfigBaseAction action, Dictionary





(01) 2018-01-05 18:10:05 Slp:与 SQL Server 建立连接时发生与网络相关或特定于实例的错误。未找到或无法访问服务器。验证实例名称是否正确以及 SQL Server 是否配置为允许远程连接。 (提供程序:命名管道提供程序,错误:40 - 无法打开与 SQL Server 的连接)
(01)2018-01-05 18:10:05 Slp:HResult:0x80131904
(01)2018-01-05 18:10:05 Slp:数据:
(01)2018-01-05 18:10:05 Slp:HelpLink.ProdName = Microsoft SQL Server
(01)2018-01-05 18:10:05 Slp:HelpLink.EvtSrc = MSSQLServer
(01)2018-01-05 18:10:05 Slp:HelpLink.EvtID = 2
(01)2018-01-05 18:10:05 Slp:HelpLink.BaseHelpUrl =http://go.microsoft.com/fwlink
(01)2018-01-05 18:10:05 Slp:HelpLink.LinkId = 20476
(01)2018-01-05 18:10:05 Slp:堆栈:
(01)2018-01-05 18:10:05 Slp:位于 System.Data.SqlClient.SqlInternalConnectionTds..ctor(DbConnectionPoolIdentity 身份、SqlConnectionString connectionOptions、SqlCredential 凭证、对象提供程序信息、字符串 newPassword、SecureString newSecurePassword、布尔值 redirectedUserInstance、SqlConnectionString userConnectionOptions、SessionData reconnectSessionData、DbConnectionPool 池、字符串 accessToken、布尔值 applyTransientFaultHandling)
(01)2018-01-05 18:10:05 Slp:位于System.Data.SqlClient.SqlConnectionFactory.CreateConnection(DbConnectionOptions 选项、DbConnectionPoolKey poolKey、Object poolGroupProviderInfo、DbConnectionPool 池、DbConnection owningConnection、DbConnectionOptions 用户选项)
(01)2018-01-05 18:10:05 Slp:在 System.Data.ProviderBase.DbConnectionFactory.CreateNonPooledConnection(DbConnection owningConnection、DbConnectionPoolGroup poolGroup、DbConnectionOptions 用户选项)(
01)2018-01-05 18:10:05 Slp:在 System.Data.ProviderBase.DbConnectionFactory.TryGetConnection(DbConnection owningConnection、TaskCompletionSource 1 重试、DbConnectionOptions 用户选项) (01)2018-01-05 18:10:05 Slp:在 System.Data.SqlClient.SqlConnection.TryOpenInner(TaskCompletionSource 1 重试) (01)2018-01-05 18:10:05 Slp:在 System.Data.SqlClient.SqlConnection.Open() (01)2018-01-05 18:10:05 Slp:在 Microsoft.SqlServer.Configuration.Sco.SqlScriptExecution.GetConnection()(01) 2018-01-05 18:10:05 Slp:在 Microsoft.SqlServer.Configuration.Sco.SqlScriptExecution.Connect() (01)2018-01-05 18:10:05 Slp:内部异常类型:System.ComponentModel.Win32Exception (01) 2018-01-05 18:10:05 Slp:消息: (01)2018-01-05 18:10:05 Slp:系统找不到指定的文件 (01)2018-01-05 18:10:05 Slp:HResult:0x80004005 (01)2018-01-05 18:10:05 Slp:错误:2 (01)2018-01-05 18:10:05 Slp:Watson Bucket 1 原始参数值 1 retry, DbConnectionOptions userOptions, DbConnectionInternal oldConnection, DbConnectionInternal& connection)
(01) 2018-01-05 18:10:05 Slp: at System.Data.ProviderBase.DbConnectionInternal.TryOpenConnectionInternal(DbConnection outerConnection, DbConnectionFactory connectionFactory, TaskCompletionSource

1 retry)
(01) 2018-01-05 18:10:05 Slp: at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource










...

SQL Server 已安装到一定程度,但无法启动。当告诉它启动时,事件日志中显示以下内容:

FileMgr::StartLogFiles: 创建或打开文件 'd:\dbs\sh\sprel\0822_164025\cmd\33\obj\x64retail\sql\mkmastr\databases\mkmastr.proj\modellog.ldf' 时发生操作系统错误 2(系统找不到指定的文件。)。诊断并更正操作系统错误,然后重试操作。

对于上述错误,虽然我确实有广告:驱动器,但它是 Azure VM“临时存储”,因此不应该在那里寻找文件。

答案1

找到答案https://social.technet.microsoft.com/wiki/contents/articles/31786.sql-server-not-starting-after-fresh-installation.aspx

打开命令并启动 SQL Server:

net start MSSQL$SQLEXPRESS /f /t3608

然后打开 SQL 命令提示符:

sqlcmd -S .\SQLEXPRESS

验证 SQL Server 是否指向错误位置的文件。您应该看到哪些数据库和日志文件路径不正确:

1> select name, physical_name, state_desc from sys.master_files order by database_id;
2> go

获取这些文件的正确路径,然后构建并运行此查询:

ALTER DATABASE model MODIFY FILE ( NAME = modeldev, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\model.mdf');
ALTER DATABASE model MODIFY FILE ( NAME = modellog, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\modellog.ldf');
ALTER DATABASE msdb MODIFY FILE ( NAME = MSDBData, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\MSDBData.mdf');
ALTER DATABASE msdb MODIFY FILE ( NAME = MSDBLog, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\MSDBLog.ldf');
ALTER DATABASE tempdb MODIFY FILE ( NAME = tempdev, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\temp.mdf');
ALTER DATABASE tempdb MODIFY FILE ( NAME = templog, FILENAME = 'C:\Program Files\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQL\DATA\temp.ldf');
go

退出、停止,然后启动 SQL Server:

1> exit
net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS

启动 SSMS,尝试连接实例,并注意到即使使用 Windows 身份验证也无法连接。现在,停止服务器,在恢复模式下重新启动,并为 sa 提供密码:

net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS /f /t3608
sqlcmd -S .\SQLEXPRESS

ALTER LOGIN sa WITH PASSWORD = 'newpassword' UNLOCK
go
exit

确保服务器已配置 SQL Server 身份验证。打开 RegEdit 并确保计算机\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL 服务器\MSSQL14.SQLEXPRESS\MSSQLServer\LoginMode2。如果您找不到此密钥,请搜索登录模式因为它对你来说可能会有所不同。

停止恢复模式服务器,并启动常规服务器

net stop MSSQL$SQLEXPRESS
net start MSSQL$SQLEXPRESS

您现在应该能够使用 sa 和之前设置的密码登录

相关内容