Ócáid
Mar 31, 11 PM - Apr 2, 11 PM
An ócáid foghlama SQL, Fabric and Power BI is mó. Márta 31 – 2 Aibreán. Bain úsáid as cód FABINSIDER chun $ 400 a shábháil.
Cláraigh inniuNí thacaítear leis an mbrabhsálaí seo a thuilleadh.
Uasghrádú go Microsoft Edge chun leas a bhaint as na gnéithe is déanaí, nuashonruithe slándála, agus tacaíocht theicniúil.
Applies to:
SQL Server
Microsoft PowerShell is a task-based command-line shell and scripting language designed especially for system administration. Always On availability groups provides a set of PowerShell cmdlets in SQL Server that enable you to deploy, manage, and monitor availability groups, availability replicas, and availability databases.
Nóta
A PowerShell cmdlet can complete by successfully initiating an action. This does not indicate that the intended work, such as the fail over of an availability group, has completed. When scripting a sequence of actions, you might have to check the status of actions, and wait for them to complete.
Nóta
For a list of topics in SQL Server Books Online that describe how to use cmdlets to perform Always On availability groups tasks, see the "Related Tasks" section of Overview of Always On Availability Groups (SQL Server).
Cmdlets | Description | Supported on |
---|---|---|
Disable-SqlAlwaysOn | Disables the Always On availability groups feature on a server instance. | The server instance that is specified by the Path, InputObject, or Name parameter. (Must be an edition of SQL Server that supports Always On availability groups.) |
Enable-SqlAlwaysOn | Enables Always On availability groups on an instance of SQL Server that supports the Always On availability groups feature. For information about support for Always On availability groups, see Prerequisites, Restrictions, and Recommendations for Always On Availability Groups (SQL Server). | Any edition of SQL Server that supports Always On availability groups. |
New-SqlHadrEndPoint | Creates a new database mirroring endpoint on a server instance. This endpoint is required for data movement between primary and secondary databases. | Any instance of SQL Server |
Set-SqlHadrEndpoint | Changes the properties of an existing database mirroring endpoint, such as the name, state, or authentication properties. | A server instance that supports Always On availability groups and lacks a database mirroring endpoint |
Cmdlets | Description | Supported on |
---|---|---|
Backup-SqlDatabase | Creates a data or log backup. | Any online database (for Always On availability groups, a database on the server instance that hosts the primary replica) |
Restore-SqlDatabase | Restores a backup. | Any instance of SQL Server (for Always On availability groups, a server instance that hosts a secondary replica) |
Tábhachtach
When preparing a secondary database, you must use the -NoRecovery parameter in every Restore-SqlDatabase command.
For information about using these cmdlets to prepare a secondary database, see Manually Prepare a Secondary Database for an Availability Group (SQL Server).
Cmdlets | Description | Supported on |
---|---|---|
New-SqlAvailabilityGroup | Creates a new availability group. | Server instance to host primary replica |
Remove-SqlAvailabilityGroup | Deletes availability group. | HADR-enabled server instance |
Set-SqlAvailabilityGroup | Sets the properties of an availability group; take an availability group online/offline | Server instance that hosts primary replica |
Switch-SqlAvailabilityGroup | Initiates one of the following forms of failover: A forced failover of an availability group (with possible data loss). A manual failover of an availability group. |
Server instance that hosts target secondary replica |
Cmdlet | Description | Supported on |
---|---|---|
New-SqlAvailabilityGroupListener | Creates a new availability group listener and attaches it to an existing availability group. | Server instance that hosts primary replica |
Set-SqlAvailabilityGroupListener | Modifies the port setting on an existing availability group listener. | Server instance that hosts primary replica |
Add-SqlAvailabilityGroupListenerStaticIp | Adds a static IP address to an existing availability group listener configuration. The IP address can be an IPv4 address with subnet, or an IPv6 address. | Server instance that hosts primary replica |
Cmdlets | Description | Supported on |
---|---|---|
New-SqlAvailabilityReplica | Creates a new availability replica. You can Use the -AsTemplate parameter to create an in-memory availability-replica object for each new availability replica. | Server instance that hosts primary replica |
Join-SqlAvailabilityGroup | Joins a secondary replica to the availability group. | Server instance that hosts secondary replica |
Remove-SqlAvailabilityReplica | Deletes an availability replica. | Server instance that hosts primary replica |
Set-SqlAvailabilityReplica | Sets the properties of an availability replica. | Server instance that hosts primary replica |
Cmdlets | Description | Supported on |
---|---|---|
Add-SqlAvailabilityDatabase | On the primary replica, adds a database to an availability group. On a secondary replica, joins a secondary database to an availability group. |
Any server instance that hosts an availability replica (behavior differs for primary and secondary replicas) |
Remove-SqlAvailabilityDatabase | On the primary replica, removes the database from the availability group. On a secondary replica, removes the local secondary database from the local secondary replica. |
Any server instance that hosts an availability replica (behavior differs for primary and secondary replicas) |
Resume-SqlAvailabilityDatabase | Resumes the data movement for a suspended availability database. | The server instance on which the database was suspended. |
Suspend-SqlAvailabilityDatabase | Suspends the data movement for an availability database. | Any server instance that hosts an availability replica. |
The following SQL Server cmdlets enable you to monitor the health of an availability group and its replicas and databases.
Tábhachtach
You must have CONNECT, VIEW SERVER STATE, and VIEW ANY DEFINITION permissions to execute these cmdlets.
Cmdlet | Description | Supported on |
---|---|---|
Test-SqlAvailabilityGroup | Assesses the health of an availability group by evaluating SQL Server policy based management (PBM) policies. | Any server instance that hosts an availability replica.* |
Test-SqlAvailabilityReplica | Assesses the health of availability replicas by evaluating SQL Server policy based management (PBM) policies. | Any server instance that hosts an availability replica.* |
Test-SqlDatabaseReplicaState | Assesses the health of an availability database on all joined availability replicas by evaluating SQL Server policy based management (PBM) policies. | Any server instance that hosts an availability replica.* |
*To view information about all of the availability replicas in an availability group, use to the server instance that hosts the primary replica.
For more information, see Use Always On Policies to View the Health of an Availability Group (SQL Server).
Overview of Always On Availability Groups (SQL Server)
Get Help SQL Server PowerShell
Ócáid
Mar 31, 11 PM - Apr 2, 11 PM
An ócáid foghlama SQL, Fabric and Power BI is mó. Márta 31 – 2 Aibreán. Bain úsáid as cód FABINSIDER chun $ 400 a shábháil.
Cláraigh inniuOiliúint
Modúl
Deploy highly available solutions by using Azure SQL - Training
In this module, you'll learn how to deploy highly available solutions by using Azure SQL. You'll also look at architectures and how they affect availability.
Deimhniú
Microsoft Certified: Azure Database Administrator Associate - Certifications
Administer an SQL Server database infrastructure for cloud, on-premises and hybrid relational databases using the Microsoft PaaS relational database offerings.
Doiciméadúchán
Create an availability group using PowerShell - SQL Server Always On
Learn how to use PowerShell cmdlets to create and configure an Always On availability group by using PowerShell in SQL Server 2019 (15.x).
Enable or Disable availability group feature - SQL Server Always On
Steps to either enable or disable the Always On availability group feature using Transact-SQL (T-SQL), PowerShell, or SQL Server Management Studio.
View availability group properties - SQL Server Always On
View the properties of an Always On availability group with either SQL Server Management Studio (SSMS), Transact-SQL (T-SQL), or SQL PowerShell.