在 Windows 10 Azure VM 上安裝 SQL Server 2017
我將一台 Azure Windows 10 VM 設置為工作站,其中包括:
- 視覺工作室 2017
- 蟒蛇 2.7
- 節點JS
- SQL 伺服器 2017
當一位同事創建一個新的 Windows 10 VM 並去安裝 SQL Server 時,他遇到了一個錯誤。然後我創建了一個新的 Windows 10 VM 並嘗試安裝 SQL Server 並得到了同樣的錯誤。認為它與 VM 配置有關,我選擇了有效的原始配置,再次嘗試,但再次失敗。
這是我們使用的 Windows 10 機器
Standard 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 是否配置為允許遠端連接。(提供者:Named Pipes Provider,錯誤: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,對象 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()`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`
(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 屬性, Boolean isConfiguringTemplateDBs,Boolean 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 timing, Dictionary 2 actionData, PublicConfigurationBase spcbCurrent) (01) 2018-01-05 18:10:05 Slp: at Microsoft.SqlServer.Configuration.SqlConfigBase.SqlFeatureConfigBase.Execute(ConfigActionScenario 場景, ConfigActionTiming 計時、ConfigBaseAction 動作、字典2 actionData、PublicConfigurationBase spcb)`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`
(01) 2018-01-05 18:10:05 Slp: 在 Microsoft.SqlServer.Configuration.SqlConfigBase.PrivateConfigurationBase.Execute(ConfigActionScenario 場景, ConfigActionTiming 計時, ConfigBaseAction action, 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:資訊:`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 credential、對象 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 options, DbConnectionPoolKey poolKey, Object poolGroupProviderInfo, DbConnectionPool pool, 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 retry, DbConnectionOptions userOptions)`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`
(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: Message: (01) 2018-01-05 18:10:05 Slp: 系統找不到指定的文件`1 retry)
(01) 2018-01-05 18:10:05 Slp: at System.Data.SqlClient.SqlConnection.TryOpen(TaskCompletionSource`
(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
原始參數值
…
SQL Server 安裝到一定程度,但它不會啟動。當告訴它開始時,這是在事件日誌中:
FileMgr::StartLogFiles: 作業系統錯誤 2(系統找不到指定的文件。)在創建或打開文件 ’d:\dbs\sh\sprel\0822_164025\cmd\33\obj\x64retail\sql\mkmastr\databases 時發生\mkmastr.proj\modellog.ldf’。診斷並糾正作業系統錯誤,然後重試操作。
對於上述錯誤,雖然我確實有 ad: 驅動器,但它是 Azure VM“臨時儲存”,因此不應在那裡尋找文件。
打開命令,然後啟動 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 auth 也無法連接。現在,停止伺服器,以恢復模式重新啟動,並給 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 並確保Computer\HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL14.SQLEXPRESS\MSSQLServer\LoginMode的值為2。如果您找不到此密鑰,請搜尋LoginMode,因為它可能對您不同。
停止恢復模式伺服器,並啟動正常伺服器
net stop MSSQL$SQLEXPRESS net start MSSQL$SQLEXPRESS
您現在應該可以使用 sa 和您之前設置的密碼登錄