Creare una risorsa DTC cluster per un gruppo di disponibilità Always On

Si applica a:SQL Server - Solo Windows

Questo articolo illustra la configurazione completa di una risorsa DTC cluster per un gruppo di disponibilità Always On di SQL Server. Il completamento della configurazione può richiedere fino a un'ora.

La procedura dettagliata crea una risorsa DTC cluster e gruppi di disponibilità di SQL Server per l'allineamento con i requisiti indicati in Inserire il servizio DTC nel cluster per i gruppi di disponibilità Always On.

La procedura dettagliata usa PowerShell e gli script Transact-SQL (T-SQL), molti dei quali richiedono l'abilitazione della modalità SQLCMD . Per altre informazioni sulla Modalità SQLCMD, vedere Modificare script SQLCMD con l'editor di query. Importare il modulo PowerShell FailoverClusters. Per altre informazioni sull'importazione di un modulo di PowerShell, vedere Importazione di un modulo di PowerShell. Questa procedura dettagliata si basa sulle seguenti opzioni di configurazione:

  • Sono stati soddisfatti tutti i requisiti elencati in Prerequisiti, restrizioni e consigli per i gruppi di disponibilità Always On.
  • Il dominio è contoso.lab.
  • L'utente ha l'autorizzazione per la creazione di oggetti computer nell'unità organizzativa in cui verrà creata la risorsa nome di rete DTC.
  • L'utente è un utente di dominio con diritti di amministratore su tutti i nodi del cluster.
  • Una condivisione file denominata sqlbackups è stata creata per i backup.
  • Le istanze predefinite di SQL Server sono denominate SQLNODE1 e SQLNODE2.
  • Lo stesso account di servizio è usato in tutte le istanze di SQL Server.
  • L'utente è un membro del ruolo sysadmin fisso di SQL Server in tutte le istanze di SQL Server.
  • Il risultato predefinito delle transazioni che DTC non riesce a risolvere verrà impostato su presume commit.
  • L'endpoint del mirroring userà la porta 5022.
  • Non esistono altri gruppi di disponibilità o risorse DTC cluster.
  • Dettagli dei cluster (esistente):
    • Nome: Cluster
    • Nome della rete: Cluster Network 1
    • Nodi: SQLNODE1, SQLNODE2
    • Archiviazione condivisa: Cluster Disk 3 (di proprietà di SQLNODE1)
  • Dettagli dei cluster (da creare):
    • Risorsa nome di rete: DTCnet1
    • Risorsa nome di rete DTC: DTC1
    • Risorsa disco fisico DTC: DTCDisk1
    • Risorsa IP e subnet DTC: 192.168.2.54, 255.255.255.0
    • Risorsa IP DTC: DTCIP1

1. Controllare il sistema operativo

Per le transazioni distribuite supportate, i gruppi di disponibilità Always On devono essere in esecuzione in Windows Server 2012 R2 e versioni successive. Per Windows Server 2012 R2, è necessario installare l'aggiornamento in KB3090973. Questo script controlla la versione del sistema operativo e se deve essere installato l'hotfix 3090973. Eseguire il seguente script di PowerShell in SQLNODE1.

# A few OS checks

<#
Script:
    1) is re-runnable
    2) will work on any node in the cluster, and
    3) will execute against every node in the cluster
#>

$nodes = (Get-ClusterNode).Name;
foreach ($node in $nodes) {

    # At least 2012 R2
    $os = (Get-WmiObject -class Win32_OperatingSystem -ComputerName $node).caption;
    if ($os -like "*2012 R2*" -or $os -like "*2016*" -or $os -like "*2019*" -or $os -like "*2022*") {
        Write-Host "$os is supported on $node.";
    }
    else {
        Write-Host "STOP! $os is not supported on $node.";
    }

    # KB 3090973
    if ($os -like "*2012 R2*") {
        $kb = Get-Hotfix -ComputerName $node | Where { $_.HotFixID -eq 'KB3090973' };
        if ($kb) {
            Write-Host "KB3090973 is installed on $node."
        }
        else {
            Write-Host "HotFixID KB3090973 must be applied on $node. See https://support.microsoft.com/help/3090973 for additional information and to download the hotfix.";
        }
    }
    else {
        Write-Host "KB3090973 does not apply to $os on $node."
    }
}

2. Configurare le regole del firewall

Questo script configura il firewall per consentire il traffico DTC in ogni SQL Server che ospita una replica del gruppo di disponibilità, nonché in qualsiasi altro server impegnato nella transazione distribuita. Lo script configura anche il firewall per consentire le connessioni per l'endpoint del mirroring del database. Eseguire il seguente script di PowerShell in SQLNODE1.

# Configure Firewall

<#
Script:
    1) is re-runnable
    2) will work on any node in the cluster, and
    3) will execute against every node in the cluster
#>

$nodes = (Get-ClusterNode).Name;
foreach ($node in $nodes) {
    Get-NetFirewallRule -CimSession $node -DisplayGroup 'Distributed Transaction Coordinator' -Enabled False -ErrorAction SilentlyContinue | Enable-NetFirewallRule;
    New-NetFirewallRule -CimSession $node -DisplayName 'SQL Server Mirroring' -Description 'Port 5022 for SQL Server Mirroring' -Action Allow -Direction Inbound -Protocol TCP -LocalPort 5022 -RemotePort Any -LocalAddress Any -RemoteAddress Any;
};

3. Configurare in-doubt xact resolution

Questo script configura l'opzione di configurazione del server in-doubt xact resolution per "presupporre il commit" per le transazioni in dubbio.

Eseguire lo script T-SQL seguente in SQL Server Management Studio (SSMS) su SQLNODE1 in modalità SQLCMD.

/*******************************************************************
    Execute script in its entirety on SQLNODE1 in SQLCMD mode
*******************************************************************/
-- Configure in-doubt xact resolution on all SQL Server instances to presume commit
IF (
    SELECT CAST(value_in_use AS BIT)
    FROM sys.configurations WITH (NOLOCK)
    WHERE [name] = N'show advanced options'
) = 0
BEGIN
    EXEC sp_configure 'show advanced options', 1;
    RECONFIGURE;
END

-- Configure the server to presume commit for in-doubt transactions.
IF (
    SELECT CAST(value AS BIT)
    FROM sys.configurations WITH (NOLOCK)
    WHERE [name] = N'in-doubt xact resolution'
) <> 1
BEGIN
    EXEC sp_configure 'in-doubt xact resolution', 1;
    RECONFIGURE;
END
GO

-----------------------------------------------------------------------------
:connect SQLNODE2

IF (
    SELECT CAST(value_in_use AS BIT)
    FROM sys.configurations WITH (NOLOCK)
    WHERE [name] = N'show advanced options'
) = 0
BEGIN
    EXEC sp_configure 'show advanced options', 1;
    RECONFIGURE;
END

-- Configure the server to presume commit for in-doubt transactions.
IF (
    SELECT CAST(value AS BIT)
    FROM sys.configurations WITH (NOLOCK)
    WHERE [name] = N'in-doubt xact resolution'
) <> 1
BEGIN
    EXEC sp_configure 'in-doubt xact resolution', 1;
    RECONFIGURE;
END
GO

4. Creare database di test

Lo script crea un database denominato AG1 in SQLNODE1 e un database denominato dtcDemoAG1 in SQLNODE2. Eseguire lo script T-SQL seguente in SSMS su SQLNODE1 in modalità SQLCMD.

/*******************************************************************
    Execute script in its entirety on SQLNODE1 in SQLCMD mode
*******************************************************************/
-- On SQLNODE1
USE master;
GO

SET NOCOUNT ON;

IF EXISTS (
    SELECT *
    FROM sys.databases
    WHERE name = N'AG1'
)
BEGIN
    DROP DATABASE AG1;
END
GO

CREATE DATABASE AG1;
GO

ALTER DATABASE AG1
SET RECOVERY FULL WITH NO_WAIT;

ALTER AUTHORIZATION ON DATABASE::AG1 TO sa;
GO

USE AG1;

CREATE TABLE [dbo].[Names] (
    [Name] [varchar](64) NULL,
    [EditDate] DATETIME
);

INSERT [dbo].[Names]
VALUES ('AG1', GETDATE());
GO

-- Against SQNODE2
:connect SQLNODE2

USE master;
GO

SET NOCOUNT ON;

IF EXISTS (
    SELECT *
    FROM sys.databases
    WHERE name = N'dtcDemoAG1'
)
BEGIN
    DROP DATABASE dtcDemoAG1;
END
GO

CREATE DATABASE dtcDemoAG1;
GO

ALTER DATABASE dtcDemoAG1
SET RECOVERY SIMPLE WITH NO_WAIT;

ALTER AUTHORIZATION ON DATABASE::dtcDemoAG1 TO sa;
GO

USE dtcDemoAG1;
GO

CREATE TABLE [dbo].[Names] (
    [Name] [varchar](64) NULL,
    [EditDate] DATETIME
);
GO

5. Creare gli endpoint

Questo script crea un endpoint denominato AG1_endpoint che è in ascolto sulla porta TCP 5022. Eseguire lo script T-SQL seguente in SSMS su SQLNODE1 in modalità SQLCMD.

/**********************************************
Execute on SQLNODE1 in SQLCMD mode
**********************************************/
-- Create endpoint on the server instance that hosts the primary replica:
IF NOT EXISTS (SELECT * FROM sys.database_mirroring_endpoints)
BEGIN
    CREATE ENDPOINT AG1_endpoint AUTHORIZATION [sa]
        STATE = STARTED
        AS TCP (LISTENER_PORT = 5022)
    FOR DATABASE_MIRRORING(ROLE = ALL);
END
GO

-----------------------------------------------------------------------------
:connect SQLNODE2

IF NOT EXISTS (SELECT *FROM sys.database_mirroring_endpoints)
BEGIN
    CREATE ENDPOINT AG1_endpoint AUTHORIZATION [sa]
        STATE = STARTED
        AS TCP (LISTENER_PORT = 5022)
    FOR DATABASE_MIRRORING(ROLE = ALL);
END
GO

6. Preparare i database per il gruppo di disponibilità

Lo script esegue il backup di AG1 su SQLNODE1 e lo ripristina in SQLNODE2. Eseguire lo script T-SQL seguente in SSMS su SQLNODE1 in modalità SQLCMD.

/*******************************************************************
    Execute script in its entirety on SQLNODE1 in SQLCMD mode
*******************************************************************/
-- Backup database
BACKUP DATABASE AG1 TO DISK = N'\\sqlnode1\sqlbackups\AG1.bak'
WITH FORMAT, STATS = 10;

-- Backup transaction log
BACKUP LOG AG1 TO DISK = N'\\sqlnode1\sqlbackups\AG1_Log.bak'
WITH FORMAT, STATS = 10;
GO

-- Restore database and logs on secondary WITH NORECOVERY
:connect SQLNODE2

USE [master];
GO

RESTORE DATABASE AG1
FROM DISK = N'\\sqlnode1\sqlbackups\AG1.bak'
WITH NORECOVERY, STATS = 10;

RESTORE LOG AG1
FROM DISK = N'\\sqlnode1\sqlbackups\AG1_Log.bak'
WITH NORECOVERY, STATS = 10;
GO

7. Creare il gruppo di disponibilità

I gruppi di disponibilità Always On devono essere creati con il comando CREATE AVAILABILITY GROUP e la clausola WITH DTC_SUPPORT = PER_DB. Non è attualmente possibile modificare un gruppo di disponibilità esistente. La creazione guidata non consente di abilitare il supporto DTC per un nuovo gruppo di disponibilità. Lo script seguente crea il nuovo gruppo di disponibilità e partecipa al database secondario. Eseguire lo script T-SQL seguente in SSMS su SQLNODE1 in modalità SQLCMD.

/*******************************************************************
    Execute the script in its entirety on SQLNODE1 in SQLCMD mode
*******************************************************************/
--  Create availability group on SQLNODE1
USE master;
GO

CREATE AVAILABILITY GROUP DTCAG1
WITH (DTC_SUPPORT = PER_DB)
FOR DATABASE AG1 REPLICA ON
'SQLNODE1' WITH (
    ENDPOINT_URL = 'TCP://SQLNODE1.contoso.lab:5022',
    AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,
    FAILOVER_MODE = MANUAL
),
'SQLNODE2' WITH (
    ENDPOINT_URL = 'TCP://SQLNODE2.contoso.lab:5022',
    AVAILABILITY_MODE = SYNCHRONOUS_COMMIT,
    FAILOVER_MODE = MANUAL
);
GO

-- SQLNODE2
-- Join a secondary replica to the availability group
:connect SQLNODE2

ALTER AVAILABILITY GROUP DTCag1 JOIN;

-- Join the database to the availability group
ALTER DATABASE AG1
SET HADR AVAILABILITY GROUP = DTCAG1;
GO

A partire da SQL Server 2016 (13.x) Service Pack 2, è possibile modificare un gruppo di disponibilità per le transazioni distribuite. Per le versioni di SQL Server 2016 (13.x) precedenti a Service Pack 2, non è possibile abilitare DTC in un gruppo di disponibilità Always On esistente. SQL Server accetta la sintassi seguente per un gruppo di disponibilità esistente:

USE master;
GO
ALTER AVAILABILITY GROUP <availability_group>
SET (DTC_Support = Per_DB);

Tuttavia, non verrà apportata alcuna modifica alla configurazione. È possibile confermare la configurazione dtc_support con la query T-SQL seguente:

SELECT name, dtc_support FROM sys.availability_groups; 

L'unico modo per abilitare il supporto DTC in un gruppo di disponibilità per le versioni precedenti a SQL Server 2016 (13.x) prima di Service Pack 2 consiste nel creare un gruppo di disponibilità con Transact-SQL.

8. Preparare le risorse cluster

Questo script prepara le risorse dipendenti DTC: IP e disco. L'archiviazione condivisa verrà aggiunta al cluster Windows. Verranno create risorse di rete e quindi verrà creato il DTC e impostato come risorsa al gruppo di disponibilità. Eseguire il seguente script di PowerShell in SQLNODE1. Questo script è basato sull'esempio disponibile in Come configurare correttamente DTC per istanze cluster di SQL Server (rivisto).

# Create a clustered Microsoft Distributed Transaction Coordinator properly in the resource group with SQL Server

<#----------------------------------- Begin User Input -----------------------------------#>
$AGgrp = "DTCag1"; # Name of the WSFC resource group that will contain the DTC resource

$WSFC = (Get-Cluster).Name; # Windows Failover Cluster name
$DTCnetwk = "Cluster Network 1" # WSFC Network to use for the DTC IP address

$ClusterAvailableDisk = "Cluster Disk 3"; # Designated disk that can support failover clustering and is visible to all nodes but not yet part of the set of clustered disks
$DTCdisk = "DTCDisk1"; # Name of the disk to be used with DTC

$DTCipresnm = "DTCIP1"; # WSFC Friendly Name of the DTC's IP resource
$DTCipaddr = "192.168.2.54"; # IP address of the DTC resource
$DTCsubnet = "255.255.255.0"; # Subnet for the DTC IP address
$DTCnetnm = "DTCNet1"; # WSFC Friendly Name of the Network Name resource
$DTCresnm = "DTC1"; # Name of the WSFC DTC Network Name resource; Name must be unique in AD
<#------------------------------------ End User Input ------------------------------------#>

# Make a new disk available for use in a failover cluster.
Get-ClusterAvailableDisk | Where-Object { $_.Name -eq $ClusterAvailableDisk } | Add-ClusterDisk;

# Rename disk
$resource = Get-ClusterResource $ClusterAvailableDisk; $resource.Name = $DTCdisk;

# Create the IP resource
Add-ClusterResource -Name $DTCipresnm -ResourceType "IP Address" -Group $AGgrp;

# Set the network to use, IP address, and subnet
# All three have to be configured at the same time
$DTCIPres = Get-ClusterResource $DTCipresnm;
$ntwk = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $DTCipres, Network, $DTCnetwk;
$ipaddr = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $DTCipres, Address, $DTCipaddr;
$subnet = New-Object Microsoft.FailoverClusters.PowerShell.ClusterParameter $DTCipres, SubnetMask, $dtcsubnet;

$setdtcipparams = $ntwk, $ipaddr, $subnet;
$setdtcipparams | Set-ClusterParameter;

# Create the Network Name resource
Add-ClusterResource $DTCnetnm -ResourceType "Network Name" -Group $AGgrp;

# Set the value for the Network Name resource
Get-ClusterResource $DTCnetnm | Set-ClusterParameter DnsName $DTCresnm;

# Add the IP address as a depenency of the Network Name resource
Add-ClusterResourceDependency $DTCnetnm $DTCipresnm;

# Create the Distributed Transaction Coordinator resource
Add-ClusterResource $DTCresnm -ResourceType "Distributed Transaction Coordinator" -Group $AGgrp;

# Add the Network Name as a dependency of the DTC resource
Add-ClusterResourceDependency $DTCresnm $DTCnetnm;

# Move the disk into the resource group with SQL Server
Move-ClusterResource -Name $DTCdisk -Group $AGgrp;

# Add the disk as a dependency of the DTC resource
Add-ClusterResourceDependency $DTCresnm $DTCdisk;

# Bring the IP resource online
Start-ClusterResource $DTCipresnm;

# Bring the Network Name resource online
Start-ClusterResource $DTCnetnm;

# Bring the DTC resource online
Start-ClusterResource $DTCresnm;

9. Abilitare l'accesso DTC di rete

Lo script seguente abilita l'accesso di rete DTC per consentire l'integrazione dei computer remoti nelle transazioni distribuite attraverso la rete per il servizio DTC cluster. Eseguire il seguente script di PowerShell in SQLNODE1.

# Enable Network DTC access for the clustered DTC service

<#
Script:
    1) is re-runnable
    2) will work on any node in the cluster, and
    3) will execute against every node in the cluster
#>

# Enter the Name of DTC resource

$DtcName = "DTC1";
<# ------- End of User Input ------- #>

[bool]$restart = 0;
$node = (Get-ClusterResource -Name $DtcName).OwnerNode.Name;
$DtcSettings = Get-DtcNetworkSetting -DtcName $DtcName;

if ($DtcSettings.InboundTransactionsEnabled -eq $false) {
    Set-DtcNetworkSetting -CimSession $node -DtcName $DtcName -AuthenticationLevel "Mutual" -InboundTransactionsEnabled $true -Confirm:$false;
    $restart = 1;
}

if ($DtcSettings.OutboundTransactionsEnabled -eq $false) {
    Set-DtcNetworkSetting -CimSession $node -DtcName $DtcName -AuthenticationLevel "Mutual" -OutboundTransactionsEnabled $true -Confirm:$false;
    $restart = 1;
}

if ($restart -eq 1) {
    Stop-Dtc -CimSession $node -DtcName $DTCname -Confirm:$false;
    Start-Dtc -CimSession $node -DtcName $DTCname;
}

10. Disabilitare e arrestare il servizio DTC locale in ogni nodo

Disabilitare il DTC locale su entrambi i nodi per garantire che le transazioni distribuite usino la risorsa DTC cluster. Lo script seguente disabilita e arresta il servizio DTC locale in ogni nodo. Eseguire il seguente script di PowerShell in SQLNODE1.

# Disable local DTC service

<#
Script:
    1) is re-runnable
    2) will work on any node in the cluster, and
    3) will execute against every node in the cluster
#>

$DTCname = 'Local';
$nodes = (Get-ClusterNode).Name;

foreach ($node in $nodes) {

    $service = Get-WmiObject -class Win32_Service -computername $node -Filter "Name='MSDTC'";
    if ($service.StartMode -ne 'Disabled') {
        $service.ChangeStartMode('Disabled');
    }

    if ($service.State -ne 'Stopped') {
        $service.StopService();
    }
}

11. Arrestare e riavviare il servizio SQL Server per ogni istanza

Dopo aver completato la configurazione del servizio DTC cluster, è necessario arrestare e riavviare ogni istanza di SQL Server nel gruppo di disponibilità per assicurarsi che SQL Server sia registrato per l'uso del servizio DTC.

La prima volta in cui il servizio SQL Server richiede una transazione distribuita. Si registra con un servizio DTC. Il servizio SQL Server continuerà a usare quel servizio DTC fino a quando non viene riavviato. Se è disponibile un servizio DTC cluster, SQL Server verrà registrato per il servizio DTC cluster. Se non è disponibile un servizio DTC cluster, SQL Server verrà registrato per il servizio DTC locale. Per verificare che SQL Server venga registrato per il servizio DTC cluster, arrestare e riavviare ogni istanza di SQL Server.

Seguire i passaggi contenuti nello script T-SQL seguente:

/*
Gracefully cycle the SQL Server service and failover the availability group
    a.    On SQLNODE2, cycle the SQL Server service from SQL Server Configuration Manager

    b.    On SQLNODE2 failover, the availability group to SQLNODE2
        Execute the T-SQL script below on SQLNODE2 (Use Results to Text)

    c.    On SQLNODE1, cycle the SQL Server service from SQL Server Configuration Manager

    d.    On SQLNODE1, failover the availability group to SQLNODE1 once the databases are back in sync.
        Execute the T-SQL script below on SQLNODE1 (Use Results to Text)
*/
SET NOCOUNT ON;

-- Ensure replica is secondary
IF (
    SELECT rs.is_primary_replica
    FROM sys.availability_groups ag
    INNER JOIN sys.dm_hadr_database_replica_states rs
        ON ag.group_id = rs.group_id
    WHERE ag.name = N'DTCag1' AND rs.is_local = 1
) = 0
BEGIN
    -- Wait for SYNCHRONIZED state
    DECLARE @ctr TINYINT = 0;
    DECLARE @msg VARCHAR(128);

    WHILE (
        SELECT synchronization_state
        FROM sys.availability_groups ag
        INNER JOIN sys.dm_hadr_database_replica_states rs
            ON ag.group_id = rs.group_id
        WHERE ag.name = N'DTCag1'
            AND rs.is_primary_replica = 0
            AND rs.is_local = 1
    ) <> 2
    BEGIN
        WAITFOR DELAY '00:00:01';

        SET @ctr += 1;
        SET @msg = 'Waiting for databases to become synchronized. Duration in seconds: ' + cast(@ctr AS VARCHAR(3));

        RAISERROR (@msg, 0, 1) WITH NOWAIT;
    END;

    ALTER AVAILABILITY GROUP DTCAG1 FAILOVER;
    SELECT 'Failover complete' AS [Sucess];
END;
ELSE
BEGIN
    SELECT 'This instance is the primary replica. Connect to the secondary replica and try again.' AS [Error];
END;

12. Testare la configurazione

Questo test usa un server collegato da SQLNODE1 a SQLNODE2 per creare un transazione distribuita. Verificare che la replica primaria del gruppo di disponibilità sia in SQLNODE1. Per testare la configurazione, occorrerà:

  • Creare server collegati
  • Eseguire una transazione distribuita

Creare server collegati

Lo script seguente crea due server collegati in SQLNODE1. Eseguire lo script T-SQL seguente in SSMS su SQLNODE1.

-- SQLNODE1
IF NOT EXISTS (SELECT * FROM sys.servers WHERE name = N'SQLNODE1')
BEGIN
    EXEC master.dbo.sp_addlinkedserver @server = N'SQLNODE1';
END

IF NOT EXISTS (SELECT * FROM sys.servers WHERE name = N'SQLNODE2')
BEGIN
    EXEC master.dbo.sp_addlinkedserver @server = N'SQLNODE2';
END

Eseguire una transazione distribuita

Questo script restituirà prima le statistiche delle transazioni DTC correnti, quindi eseguirà una transazione distribuita usando database su SQLNODE1 e SQLNODE2. Infine, lo script restituirà nuovamente le statistiche delle transazioni DTC, che ora dovrebbero mostrare un conteggio superiore. Connettersi fisicamente a SQLNODE1 ed eseguire lo script T-SQL seguente in SSMS su SQLNODE1 in modalità SQLCMD.

/*******************************************************************
    Execute the script in its entirety on SQLNODE1 in SQLCMD mode
    Must be physically connected to SQLNODE1
*******************************************************************/
USE AG1;
GO
SET NOCOUNT ON;

-- Get Baseline
!! Powershell; $DtcNameC = Get-DtcClusterDefault; Get-DtcTransactionsStatistics -DtcName $DtcNameC;

SET XACT_ABORT ON
BEGIN DISTRIBUTED TRANSACTION
    INSERT INTO SQLNODE1.[AG1].[dbo].[Names] VALUES ('TestValue1', GETDATE());
    INSERT INTO SQLNODE2.[dtcDemoAG1].[dbo].[Names] VALUES ('TestValue2', GETDATE());
COMMIT TRAN
GO

-- Review DTC Transaction Statistics
!! Powershell; $DtcNameC = Get-DtcClusterDefault; Get-DtcTransactionsStatistics -DtcName $DtcNameC;

Importante

L'istruzione USE AG1 deve essere eseguita per verificare che il contesto del database sia impostato su AG1. In caso contrario, si riceverà il messaggio di errore seguente: "Il contesto della transazione è in uso in un'altra sessione".