在创建集成服务目录时或创建后启用对“始终在线”的支持时出现问题

问题描述 投票:0回答:0

到目前为止,我通过此 PowerShell 脚本取得的成就是成功创建目录 SSISDB 和数据库 SSISDB,并将其添加到可用性组。我还想要的是 Enable Support For Always on(我们在 SSMS 中右键单击 Integration service 时得到的选项)。 到目前为止我使用的 PowerShell 脚本:

Write-Host "SSIS DB deployment" 
try
{
    # Load the IntegrationServices Assembly  
    [Reflection.Assembly]::LoadWithPartialName("Microsoft.SqlServer.Management.IntegrationServices")  
    # Store the IntegrationServices Assembly namespace to avoid typing it every time  
    $ISNamespace = "Microsoft.SqlServer.Management.IntegrationServices"   
    # Create a connection to the server  
    $sqlConnectionString = "Data Source=$reportAOAGListenerName;Initial Catalog=master;Integrated Security=SSPI;"  
    $sqlConnection = New-Object System.Data.SqlClient.SqlConnection $sqlConnectionString  
    # Create the Integration Services object  
    $integrationServices = New-Object $ISNamespace".IntegrationServices" $sqlConnection  

    $sql=" exec sp_configure 'show advance options', 1;
        GO
        RECONFIGURE;
        GO
        exec sp_configure 'clr enabled',1;
        GO
        RECONFIGURE;
        GO"
    invoke-sqlcmd -Query $sql -ServerInstance $reportServerInstance -ErrorAction SilentlyContinue
    invoke-sqlcmd -Query $sql -ServerInstance $reportSecondaryNodeInstance -ErrorAction SilentlyContinue

    if ($integrationServices.Catalogs.Count -eq 0) 
    {
        Write-Host "SSIS Not exist."
        $catalog = New-Object $ISNamespace".Catalog" ($integrationServices, $ssisDBName, $ssisCatalogPassword)  
        $catalog.Create()
    }
    else
    {
        Write-Host "SSIS exists."
    }

    $sqlRecoverySettingChange = "USE [master] 
                                    GO 
                                    ALTER DATABASE [$ssisDBName] SET RECOVERY FULL   
                                    GO
                                    "
    invoke-sqlcmd -Query $sqlRecoverySettingChange -ServerInstance $reportServerInstance
  
     $sql="select  
                case 
                 when
                  hdrs.is_primary_replica IS NULL then  0
                 else
                    1
                 end
                 as  InAG
                 from sys.databases as sd
                 left outer join sys.dm_hadr_database_replica_states  as hdrs on hdrs.database_id = sd.database_id
                 WHERE sd.name ='$ssisDBName'"
    $inAG= invoke-sqlcmd -Query $sql -ServerInstance $reportServerInstance 
    if( $inAG.InAG -eq 0)
    {
        Write-Host "AOAG Addition started"
        $AOAGSQLPrimary="ALTER AVAILABILITY GROUP [$reportAOAGGroupName] ADD DATABASE [$ssisDBName]  
                         GO"
        invoke-sqlcmd -Query $AOAGSQLPrimary -ServerInstance $reportServerInstance
        Write-Host "AOAG Addition done in group: $($reportAOAGGroupName)"
    }
}
catch
{
        Write-Host "LoadException";
        #$Error | format-list -force
        Write-Host $_;
}

到目前为止我尝试过的是:

  1. $catalog = New-Object $ISNamespace".Catalog" ($integrationServices, $ssisDBName, $ssisCatalogPassword, $true)
    我发现这个附加参数有助于启用但出现异常:New-Object:找不到“目录”和参数计数的重载:“4”.
  2. $createDBIfNotExists = $true; $catalogMode = "AlwaysOn"; $catalog = New-Object $ISNamespace".Catalog" ($integrationServices, $ssisDBName, $ssisCatalogPassword, $createDBIfNotExists, $catalogMode, $reportServerInstance, $reportAOAGGroupName); 
    异常:新对象:找不到“目录”的重载和参数计数:“7”.
if ($catalog -ne $null) 
{
    # Set AlwaysOnEnabled property to true
    if ($catalog.Properties.Contains("AlwaysOnEnabled")) 
    {
        $catalog.Properties["AlwaysOnEnabled"].SetValue($catalog, $true, $null)
        $catalog.Alter()
        Write-Host "AlwaysOnEnabled property set to true."
    }
    else 
    {
        Write-Host "AlwaysOnEnabled property not found in catalog properties."
    }
}

输出:在目录属性中找不到 AlwaysOnEnabled 属性。 4.

$catalog = $integrationServices.Catalogs[$ssisDBName]
if (!$catalog) 
{
    Write-Host "SSIS Not exist."
    # Provision a new SSIS Catalog  
    $catalog = $integrationServices.CreateCatalog($ssisDBName, $ssisCatalogPassword, $true)
}
else
{
    Write-Host "SSIS exists."
}

异常:找不到函数或方法 CreateCatalog 5.

$catalog = $integrationServices.Catalogs["SSISDB"]

# Set AlwaysOnEnabled property to true
$catalog.AlwaysOnEnabled = $true
$catalog.Alter()

异常:找不到属性“AlwaysOnEnabled”

集成服务版本为15.0.0.0

我通过使用以下脚本在主服务器上运行查询找到的属性列表是:

SELECT TOP (1000) [property_name],[property_value] FROM [SSISDB].[catalog].[catalog_properties]
默认执行模式 加密演算法 MAX_PROJECT_VERSIONS 个版本 OPERATION_CLEANUP_ENABLED 保留窗口 SCHEMA_BUILD SCHEMA_VERSION SERVER_CUSTOMIZED_LOGGING_LEVEL SERVER_LOGGING_LEVEL SERVER_OPERATION_ENCRYPTION_LEVEL VERSION_CLEANUP_ENABLED

我找到了一个名为 **InitialSupportForAlwaysOnPrimary ** 和 InitialSupportForAlwaysOnSecondary 的属性。 我不知道如何在我的 PowerShell 脚本中使用它。我尝试将其作为 $catalog.InitialSupportForAlwaysOnPrimary() 但没有任何反应。 在创建目录并添加到可用性组后,通过右键单击集成服务目录手动启用对始终开启的支持,SSIS 服务器维护作业和 SSIS 故障转移监视器作业将在主服务器和辅助服务器上自动创建

sql-server ssis high-availability sql-agent-job sql-agent
© www.soinside.com 2019 - 2024. All rights reserved.