次の方法で共有


Set-SqlAvailabilityGroup

Sets settings on an availability group.

構文

ByPath (既定)

Set-SqlAvailabilityGroup
    [[-Path] <String>]
    [-AutomatedBackupPreference <AvailabilityGroupAutomatedBackupPreference>]
    [-FailureConditionLevel <AvailabilityGroupFailureConditionLevel>]
    [-HealthCheckTimeout <Int32>]
    [-DatabaseHealthTrigger <Boolean>]
    [-RequiredSynchronizedSecondariesToCommit <Int32>]
    [-Script]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

ByObject

Set-SqlAvailabilityGroup
    [-InputObject] <AvailabilityGroup>
    [-AutomatedBackupPreference <AvailabilityGroupAutomatedBackupPreference>]
    [-FailureConditionLevel <AvailabilityGroupFailureConditionLevel>]
    [-HealthCheckTimeout <Int32>]
    [-DatabaseHealthTrigger <Boolean>]
    [-RequiredSynchronizedSecondariesToCommit <Int32>]
    [-Script]
    [-AccessToken <PSObject>]
    [-TrustServerCertificate]
    [-HostNameInCertificate <String>]
    [-Encrypt <String>]
    [-WhatIf]
    [-Confirm]
    [<CommonParameters>]

説明

The Set-SqlAvailabilityGroup cmdlet modifies settings on an existing availability group in Always On Availability Groups. You can modify the automated backup preference, the failure condition level, and the health check timeout. You must run this cmdlet on the server instance that hosts the primary replica.

Example 1: Change the health check timeout period

PS C:\> Set-SqlAvailabilityGroup -Path "SQLSERVER:\Sql\PrimaryServer\InstanceName\AvailabilityGroups\MAinAG" -HealthCheckTimeout 120000

This command changes the health check timeout property on the availability group named MainAG to 120 seconds, or two minutes. If automatic failover is enabled, after this length of time, Always On Availability Groups initiates an automatic failover will be initiated.

Example 2: Change automated backup preference

PS C:\> Set-SqlAvailabilityGroup -Path "SQLSERVER:\Sql\PrimaryServer\InstanceName\AvailabilityGroups\MainAG" -AutomatedBackupPreference SecondaryOnly

This command changes the automated backup preference on the availability group named MainAG to be SecondaryOnly. Automated backups of databases in this availability group do not occur on the primary replica. Instead, automated backups occur on the secondary replica that has the highest backup priority.

Example 3: Change the failure condition level

PS C:\> Set-SqlAvailabilityGroup -Path "SQLSERVER:\Sql\PrimaryServer\InstanceName\AvailabilityGroups\MainAG" -FailureConditionLevel OnServerDown

This command changes the failure condition level on the availability group named MainAG to be OnServerDown. If the server instance that hosts the primary replica goes offline and if automatic failover is enabled, Always On Availability Groups starts an automatic failover.

Example 4: Change the number of `SYNCHRONOUS_COMMIT` secondaries that must be available for transactions to commit on the primary

# Get server and AG
PS C:\> CD 'SQLSERVER:\SQL\some-hostname\Default'
PS SQLSERVER:\SQL\some-hostname\Default> $server = Get-Item $PWD
PS SQLSERVER:\SQL\some-hostname\Default> $ag = $server.AvailabilityGroups[0]
# Alter AG with RequiredCopiesToCommit = 4
PS SQLSERVER:\SQL\some-hostname\Default> $ag | Set-SqlAvailabilityGroup -RequiredSynchronizedSecondariesToCommit 4

Note: an exception will be thrown if the -RequiredSynchronizedSecondariesToCommit parameter is used when
the target server version is SQL Server 2016 or lower.

パラメーター

-AccessToken

The access token used to authenticate to SQL Server, as an alternative to user/password or Windows Authentication.

This can be used, for example, to connect to SQL Azure DB and SQL Azure Managed Instance using a Service Principal or a Managed Identity.

The parameter to use can be either a string representing the token or a PSAccessToken object as returned by running Get-AzAccessToken -ResourceUrl https://database.windows.net.

This parameter is new in v22 of the module.

パラメーターのプロパティ

型:PSObject
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-AutomatedBackupPreference

Specifies the automated backup preference for the availability group. The acceptable values for this parameter are:

  • Primary. Specifies that the backups always occur on the primary replica. This option supports the use of features not available when backup runs on a secondary replica, such as differential backups.
  • SecondaryOnly. Specifies that backups are never performed on primary replicas. If the primary replica is the only replica online, the backup does not occur.
  • Secondary. Specifies that backups occur on secondary replicas, unless the primary replica is the only replica online. Then the backup occurs on the primary replica.
  • None. Specifies that the primary or secondary status is not taken into account when deciding which replica performs backups. Instead, backup priority and online status determine which replica performs backups.

パラメーターのプロパティ

型:AvailabilityGroupAutomatedBackupPreference
規定値:None
指定可能な値:Primary, SecondaryOnly, Secondary, None, Unknown
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Confirm

Prompts you for confirmation before running the cmdlet.

パラメーターのプロパティ

型:SwitchParameter
規定値:False
ワイルドカードのサポート:False
DontShow:False
Aliases:cf

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-DatabaseHealthTrigger

Specifies whether to trigger an automatic failover of the availability group if any user database replica within an availability group encounters a database failure condition.

パラメーターのプロパティ

型:Boolean
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Encrypt

The encryption type to use when connecting to SQL Server.

This value maps to the Encrypt property SqlConnectionEncryptOption on the SqlConnection object of the Microsoft.Data.SqlClient driver.

In v22 of the module, the default is Optional (for compatibility with v21). In v23+ of the module, the default value will be 'Mandatory', which may create a breaking change for existing scripts.

This parameter is new in v22 of the module.

パラメーターのプロパティ

型:String
規定値:None
指定可能な値:Mandatory, Optional, Strict
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-FailureConditionLevel

Specifies the automatic failover behavior of the availability group. The acceptable values for this parameter are:

  • OnServerDown. Failover or restart if the SQL Server service stops.
  • OnServerUnresponsive. Failover or restart if any condition of lower value is satisfied, plus when the SQL Server service is connected to the cluster and the HealthCheckTimeout threshold is exceeded, or if the availability replica currently in primary role is in a failed state.
  • OnCriticalServerError. Failover or restart if any condition of lower value is satisfied, plus when an internal critical server error occurs, which include out of memory condition, serious write-access violation, or too much dumping.
  • OnModerateServerError. Failover or restart if any condition of lower value is satisfied, plus if a moderate Server error occurs, wich includes persistent out of memory condition.
  • OnAnyQualifiedFailureConditions. Failover or restart if any condition of lower value is satisfied, plus if a qualifying failure condition occurs, which includes engine worker thread exhaustion and unsolvable deadlock detected.

パラメーターのプロパティ

型:AvailabilityGroupFailureConditionLevel
規定値:None
指定可能な値:OnServerDown, OnServerUnresponsive, OnCriticalServerErrors, OnModerateServerErrors, OnAnyQualifiedFailureCondition, Unknown
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-HealthCheckTimeout

Specifies the length of time, in milliseconds, after which Always On Availability Groups declares an unresponsive server to be unhealthy.

パラメーターのプロパティ

型:Int32
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-HostNameInCertificate

The host name to be used in validating the SQL Server TLS/SSL certificate. You must pass this parameter if your SQL Server instance is enabled for Force Encryption and you want to connect to an instance using hostname/shortname. If this parameter is omitted then passing the Fully Qualified Domain Name (FQDN) to -ServerInstance is necessary to connect to a SQL Server instance enabled for Force Encryption.

This parameter is new in v22 of the module.

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-InputObject

Specifies the availability group, as an AvailabilityGroup object, that this cmdlet modifies.

パラメーターのプロパティ

型:AvailabilityGroup
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByObject
配置:1
必須:True
パイプラインからの値:True
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Path

Specifies the path of the availability database that cmdlet modifies. If you do not specify this parameter, this cmdlet uses current working location.

パラメーターのプロパティ

型:String
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

ByPath
配置:1
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-RequiredSynchronizedSecondariesToCommit

The number of synchronous commit secondaries that must be available to be able to commit on the primary.

If a SYNCHRONOUS_COMMIT secondary is disconnected from the primary for some time, the primary demotes it to ASYNCHRONOUS_COMMIT to avoid blocking commits. If the primary then becomes unavailable and the user wishes to fail over to one of these secondaries, they may incur data loss. By setting RequiredSynchronizedSecondariesToCommit to some number, the user can prevent the data loss since the primary will start blocking commits if too many secondaries are demoted to ASYNCHRONOUS_COMMIT.

The default value of this setting is 0, which means the primary will never block commits. This is identical to the behavior before SQL Server 2017.

パラメーターのプロパティ

型:Int32
規定値:0
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-Script

Indicates that this cmdlet returns a Transact-SQL script that performs the task that this cmdlet performs.

パラメーターのプロパティ

型:SwitchParameter
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-TrustServerCertificate

Indicates whether the channel will be encrypted while bypassing walking the certificate chain to validate trust.

In v22 of the module, the default is $true (for compatibility with v21). In v23+ of the module, the default value will be '$false', which may create a breaking change for existing scripts.

This parameter is new in v22 of the module.

パラメーターのプロパティ

型:SwitchParameter
規定値:None
ワイルドカードのサポート:False
DontShow:False

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

-WhatIf

Shows what would happen if the cmdlet runs. The cmdlet is not run.

パラメーターのプロパティ

型:SwitchParameter
規定値:False
ワイルドカードのサポート:False
DontShow:False
Aliases:wi

パラメーター セット

(All)
配置:Named
必須:False
パイプラインからの値:False
プロパティ名別のパイプラインからの値:False
残りの引数からの値:False

CommonParameters

This cmdlet supports the common parameters: -Debug, -ErrorAction, -ErrorVariable, -InformationAction, -InformationVariable, -OutBuffer, -OutVariable, -PipelineVariable, -ProgressAction, -Verbose, -WarningAction, and -WarningVariable. For more information, see about_CommonParameters.

入力

Microsoft.SqlServer.Management.Smo.AvailabilityGroup