forked from dsccommunity/SqlServerDsc
-
Notifications
You must be signed in to change notification settings - Fork 2
SqlAGListener
johlju edited this page Jun 19, 2020
·
2 revisions
Parameter | Attribute | DataType | Description | Allowed Values |
---|---|---|---|---|
InstanceName | Key | String | The SQL Server instance name of the primary replica. | |
ServerName | Required | String | The host name or FQDN of the primary replica. | |
Name | Required | String | The name of the availability group listener, max 15 characters. This name will be used as the Virtual Computer Object (VCO). | |
Ensure | Write | String | If the availability group listener should be present or absent. Default value is 'Present'. | Present, Absent |
AvailabilityGroup | Key | String | The name of the availability group to which the availability group listener is or will be connected. | |
IpAddress | Write | StringArray[] | The IP address used for the availability group listener, in the format 192.168.10.45/255.255.252.0. If using DHCP, set to the first IP-address of the DHCP subnet, in the format 192.168.8.1/255.255.252.0. Must be valid in the cluster-allowed IP range. | |
Port | Write | UInt16 | The port used for the availability group listener | |
DHCP | Write | Boolean | If DHCP should be used for the availability group listener instead of static IP address. |
The SqlAGListener
DSC resource is used to configure the listener
for an Always On Availability Group.
- Target machine must be running Windows Server 2012 or later.
- Target machine must be running SQL Server Database Engine 2012 or later.
- Target machine must have access to the SQLPS PowerShell module or the SqlServer PowerShell module.
- Requires that the Cluster name Object (CNO) has been delegated the right Create Computer Object in the organizational unit (OU) in which the Cluster Name Object (CNO) resides.
All issues are not listed here, see here for all open issues.
This example will add an Availability Group listener with the same name as the cluster role VCO.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAGListener 'AvailabilityGroupListenerWithSameNameAsVCO'
{
Ensure = 'Present'
ServerName = 'SQLNODE01.company.local'
InstanceName = 'MSSQLSERVER'
AvailabilityGroup = 'AG-01'
Name = 'AG-01'
IpAddress = '192.168.0.73/255.255.255.0'
Port = 5301
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
This example will add an Availability Group listener with a different than the cluster role VCO.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAGListener 'AvailabilityGroupListenerWithDifferentNameAsVCO'
{
Ensure = 'Present'
ServerName = 'SQLNODE01.company.local'
InstanceName = 'MSSQLSERVER'
AvailabilityGroup = 'AvailabilityGroup-01'
Name = 'AG-01'
IpAddress = '192.168.0.74/255.255.255.0'
Port = 5302
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
This example will remove an Availability Group listener with a different name than cluster role VCO.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAGListener 'RemoveAvailabilityGroupListenerWithDifferentNameAsVCO'
{
Ensure = 'Absent'
ServerName = 'SQLNODE01.company.local'
InstanceName = 'MSSQLSERVER'
AvailabilityGroup = 'AvailabilityGroup-01'
Name = 'AG-01'
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
This example will remove an Availability Group listener with the same name as the cluster role VCO.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAGListener 'RemoveAvailabilityGroupListenerWithSameNameAsVCO'
{
Ensure = 'Absent'
ServerName = 'SQLNODE01.company.local'
InstanceName = 'MSSQLSERVER'
AvailabilityGroup = 'AG-01'
Name = "AG-01"
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
This example will add an Availability Group listener using DHCP on the default server subnet.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAGListener 'AvailabilityGroupListenerWithSameNameAsVCO'
{
Ensure = 'Present'
ServerName = 'SQLNODE01.company.local'
InstanceName = 'MSSQLSERVER'
AvailabilityGroup = 'AG-01'
Name = 'AG-01'
<#
If not specifying parameter DHCP, then the default will be
DHCP with the default server subnet.
#>
DHCP = $true
Port = 5301
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
This example will add an Availability Group listener using DHCP with a specific subnet.
Configuration Example
{
param
(
[Parameter(Mandatory = $true)]
[System.Management.Automation.PSCredential]
$SqlAdministratorCredential
)
Import-DscResource -ModuleName 'SqlServerDsc'
node localhost
{
SqlAGListener 'AvailabilityGroupListenerWithSameNameAsVCO'
{
Ensure = 'Present'
ServerName = 'SQLNODE01.company.local'
InstanceName = 'MSSQLSERVER'
AvailabilityGroup = 'AG-01'
Name = 'AG-01'
DHCP = $true
IpAddress = '192.168.0.1/255.255.252.0'
Port = 5301
PsDscRunAsCredential = $SqlAdministratorCredential
}
}
}
- SqlAG
- SqlAGDatabase
- SqlAgentAlert
- SqlAgentFailsafe
- SqlAgentOperator
- SqlAGListener
- SqlAGReplica
- SqlAlias
- SqlAlwaysOnService
- SqlConfiguration
- SqlDatabase
- SqlDatabaseDefaultLocation
- SqlDatabaseMail
- SqlDatabaseObjectPermission
- SqlDatabaseOwner
- SqlDatabasePermission
- SqlDatabaseRecoveryModel
- SqlDatabaseRole
- SqlDatabaseUser
- SqlEndpoint
- SqlEndpointPermission
- SqlLogin
- SqlMaxDop
- SqlMemory
- SqlPermission
- SqlProtocol
- SqlProtocolTcpIp
- SqlReplication
- SqlRole
- SqlRS
- SqlRSSetup
- SqlScript
- SqlScriptQuery
- SqlSecureConnection
- SqlServerConfiguration
- SqlServerDatabaseMail
- SqlServerEndpoint
- SqlServerEndpointPermission
- SqlServerEndpointState
- SqlServerLogin
- SqlServerMaxDop
- SqlServerMemory
- SqlServerNetwork
- SqlServerPermission
- SqlServerProtocol
- SqlServerProtocolTcpIp
- SqlServerReplication
- SqlServerRole
- SqlServerSecureConnection
- SqlServiceAccount
- SqlSetup
- SqlWaitForAG
- SqlWindowsFirewall