简体   繁体   English

DSC配置故障排除

[英]Troubleshooting DSC configuration

I'm looking for an advice on how to troubleshoot DSC configuration. 我正在寻找有关如何对DSC配置进行故障排除的建议。 I'm using Azure DSC Extension and the logs are: 我正在使用Azure DSC扩展,日志为:

VERBOSE: [2017-09-08 02:56:48Z] [VERBOSE] [sql-sql-0]:                         
   [[xSqlServer]ConfigureSqlServerWithAlwaysOn] The file "MSDBLog" has been 
modified in the system catalog. The new path will be used the next time the 
database is started.
VERBOSE: [2017-09-08 02:56:50Z] [ERROR] Exception setting "StartupParameters": 
"STARTUPPARAMETERS: unknown property."
VERBOSE: [2017-09-08 02:56:50Z] [VERBOSE] [sql-sql-0]:                         
   [[xSqlServer]ConfigureSqlServerWithAlwaysOn] Stopping SQL server instance 
'MSSQLSERVER' ...
VERBOSE: [2017-09-08 02:57:07Z] [VERBOSE] [sql-sql-0]:                         
   [[xSqlServer]ConfigureSqlServerWithAlwaysOn] Starting SQL server instance 
'MSSQLSERVER' ...

From there it just freezes then times out. 从那里开始冻结,然后超时。 This is the only part of my DSC configuration that uses xSQLServer: 这是我的DSC配置中唯一使用xSQLServer的部分:

xSqlServer ConfigureSqlServerWithAlwaysOn
{
    InstanceName = $env:COMPUTERNAME
    SqlAdministratorCredential = $Admincreds
    ServiceCredential = $SQLCreds
    MaxDegreeOfParallelism = 1
    FilePath = "F:\DATA"
    LogPath = "G:\LOG"
    DomainAdministratorCredential = $DomainFQDNCreds
    DependsOn = "[xSqlLogin]AddSqlServerServiceAccountToSysadminServerRole"
}

This is the part of MicrosoftAzure_xSqlServer.psm1 that contains mentions of "startup": 这是MicrosoftAzure_xSqlServer.psm1的一部分,其中包含“启动”的提及:

function Alter-SystemDatabaseLocation([string]$FilePath, [string]$LogPath,[PSCredential]$ServiceCredential )
{
    $permissionString = $ServiceCredential.UserName+":(OI)(CI)(F)"
    icacls $FilePath /grant $permissionString
    icacls $LogPath /grant $permissionString

    Invoke-Sqlcmd "Use master"
    Invoke-sqlCmd "ALTER DATABASE tempdb MODIFY FILE (NAME = tempdev, FILENAME = '$FilePath\tempdb.mdf');"
    Invoke-sqlCmd "ALTER DATABASE tempdb MODIFY FILE (NAME = templog, FILENAME = '$LogPath\templog.ldf');"

    Invoke-sqlCmd "ALTER DATABASE model MODIFY FILE (NAME = modeldev, FILENAME = '$FilePath\model.mdf');"
    Invoke-sqlCmd "ALTER DATABASE model MODIFY FILE (NAME = modellog, FILENAME = '$LogPath\modellog.ldf');"

    Invoke-sqlCmd "ALTER DATABASE msdb MODIFY FILE (NAME = MSDBData, FILENAME = '$FilePath\msdbdata.mdf');"
    Invoke-sqlCmd "ALTER DATABASE msdb MODIFY FILE (NAME = MSDBLog, FILENAME = '$LogPath\msdblog.ldf');"

    [System.Reflection.Assembly]::LoadWithPartialName('Microsoft.SqlServer.SqlWmiManagement')| Out-Null
    $smowmi = New-Object Microsoft.SqlServer.Management.Smo.Wmi.ManagedComputer 
    $sqlsvc = $smowmi.Services | Where-Object {$_.Name -like 'MSSQL*'} 
    $OldStartupParameters = $sqlsvc.StartupParameters
    $params = '-d'+$FilePath+'\master.mdf;-e'+$LogPath+'\ERRORLOG;-l'+$LogPath+'\mastlog.ldf'
    $sqlsvc[1].StartupParameters = $params
    $sqlsvc[1].Alter()
}

What should be my next steps to understand the problem? 我接下来应该如何理解该问题? If it makes any difference, I'm trying to create SQL Server Always On Availability group on Windows Server 2016 and SQL Server 2016 SP1, by using templates and DSC code that work with Windows Server 2012 R2 and SQL Server 2014. 如果有什么不同,我试图通过使用与Windows Server 2012 R2和SQL Server 2014一起使用的模板和DSC代码在Windows Server 2016和SQL Server 2016 SP1上创建SQL Server Always On可用性组。

my advice is to use existing working code ;) I don't think it makes sense to copy paste the blog post . 我的建议是使用现有的工作代码;)我认为复制粘贴博客文章没有任何意义。 But I'll leave links to relevant files here. 但是,我将在此处保留指向相关文件的链接。

Links: 链接:
1. DSC modules 1. DSC模块
2. ARM Template . 2. ARM模板 Note: Arm template that deploys sql needs to have vnet and domain already in place. 注意:部署sql的Arm模板必须已具有vnet和域。 Also, you will get a hard time trying to deploy this template outside of that framework, so probably just copy out dsc extension\\dsc scripts and use in your deployments. 另外,尝试在该框架之外部署该模板将很困难,因此可能只需复制dsc扩展名\\ dsc脚本并在部署中使用即可。
3. Parameters file example 3. 参数文件示例

The xSqlServer (the new one) is not capable of moving sql to another disk, so you are stuck with custom script or this old xSql module. xSqlServer(新的xSqlServer)无法将sql移动到另一张磁盘,因此您陷入了自定义脚本或这个旧的xSql模块的困境。 Also, please note, DSC modules inside packages are modified. 另外,请注意,软件包内的DSC模块已修改。 These DSC configurations won't work with not modified versions of modules ( xSqlCreateVirtualDataDisk , xDatabase , xSQLServerAlwaysOnAvailabilityGroupListener maybe some other modules, I can't recall at this point). 这些DSC配置不适用于未经修改的模块版本xSqlCreateVirtualDataDiskxDatabasexSQLServerAlwaysOnAvailabilityGroupListener也许还有其他一些模块,我目前无法回忆起)。

PS. PS。 working that configuration out and patching relevant parts wasn't exactly a pleasant journey... PPS. 进行配置并修补相关零件并不是一件令人愉快的旅程... PPS。 that repo also contains dsc configuration for ADDS that can also run in parallel (compared to official example). 该存储库还包含ADDS的dsc配置,该配置也可以并行运行(与官方示例相比)。

try this. 尝试这个。

$sqlsvc = $smowmi.Services | Where-Object {$_.Name -eq 'MSSQLSERVER'}  
$OldStartupParameters = $sqlsvc.StartupParameters
$params = '-d'+$FilePath+'\master.mdf;-e'+$LogPath+'\ERRORLOG;-l'+$LogPath+'\mastlog.ldf'
$sqlsvc[0].StartupParameters = $params
$sqlsvc[0].Alter()

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM