|
3 | 3 | This will help to understand how to setup certain scenarios with SqlServerDsc
|
4 | 4 | resource module.
|
5 | 5 |
|
6 |
| -## Resource examples |
7 |
| - |
8 |
| -These are the links to the examples for each individual resource. |
9 |
| - |
10 |
| -- [SqlAG](Resources/SqlAG) |
11 |
| -- [SqlAGDatabase](Resources/SqlAGDatabase) |
12 |
| -- [SqlAgentAlert](Resources/SqlAgentAlert) |
13 |
| -- [SqlAgentOperator](Resources/SqlAgentOperator) |
14 |
| -- [SqlAGListener](Resources/SqlAGListener) |
15 |
| -- [SqlAGReplica](Resources/SqlAGReplica) |
16 |
| -- [SqlAlias](Resources/SqlAlias) |
17 |
| -- [SqlAlwaysOnService](Resources/SqlAlwaysOnService) |
18 |
| -- [SqlAudit](Resources/SqlAudit) |
19 |
| -- [SqlDatabase](Resources/SqlDatabase) |
20 |
| -- [SqlDatabaseDefaultLocation](Resources/SqlDatabaseDefaultLocation) |
21 |
| -- [SqlDatabasePermission](Resources/SqlDatabasePermission) |
22 |
| -- [SqlDatabaseRole](Resources/SqlDatabaseRole) |
23 |
| -- [SqlDatabaseUser](Resources/SqlDatabaseUser) |
24 |
| -- [SqlRS](Resources/SqlRS) |
25 |
| -- [SqlRSSetup](Resources/SqlRSSetup) |
26 |
| -- [SqlScript](Resources/SqlScript) |
27 |
| -- [SqlScriptQuery](Resources/SqlScriptQuery) |
28 |
| -- [SqlConfiguration](Resources/SqlConfiguration) |
29 |
| -- [SqlDatabaseMail](Resources/SqlDatabaseMail) |
30 |
| -- [SqlEndpoint](Resources/SqlEndpoint) |
31 |
| -- [SqlEndpointPermission](Resources/SqlEndpointPermission) |
32 |
| -- [SqlLogin](Resources/SqlLogin) |
33 |
| -- [SqlMaxDop](Resources/SqlMaxDop) |
34 |
| -- [SqlMemory](Resources/SqlMemory) |
35 |
| -- [SqlPermission](Resources/SqlPermission) |
36 |
| -- [SqlReplication](Resources/SqlReplication) |
37 |
| -- [SqlRole](Resources/SqlRole) |
38 |
| -- [SqlSecureConnection](Resources/SqlSecureConnection) |
39 |
| -- [SqlServiceAccount](Resources/SqlServiceAccount) |
40 |
| -- [SqlSetup](Resources/SqlSetup) |
41 |
| -- [SqlWaitForAG](Resources/SqlWaitForAG) |
42 |
| -- [SqlWindowsFirewall](Resources/SqlWindowsFirewall) |
43 |
| - |
44 |
| -## Setting up a SQL Server Failover Cluster |
45 |
| - |
46 |
| -This will reference examples that show how to setup high availability SQL Server |
47 |
| -using a Failover Cluster. |
48 |
| -It assumes that a working domain exists with at least one Domain Controller, and |
49 |
| -and both servers that should contain the SQL Server nodes are domain joined. |
50 |
| - |
51 |
| -### Prepare Active Directory |
52 |
| - |
53 |
| -If the user who creates the failover cluster has the **Create Computer Objects** |
54 |
| -permission to the organizational unit (OU) where the servers that will form the |
55 |
| -cluster reside, then there is no need to prestage the Cluster Named Object (CNO) |
56 |
| -computer object. |
57 |
| -However, if the user creating the failover cluster does not have this permission, |
58 |
| -prestaging the Cluster Named Object (CNO) computer object becomes necessary. |
59 |
| -It is also possible to prestage the Virtual Computer Objects (VCO). |
60 |
| - |
61 |
| -Read more about it here |
62 |
| -[Prestage Cluster Computer Objects in Active Directory Domain Services](https://docs.microsoft.com/en-us/previous-versions/windows/it-pro/windows-server-2012-R2-and-2012/dn466519(v=ws.11)). |
63 |
| - |
64 |
| -#### Prestage the Cluster Named Object (CNO) computer object |
65 |
| - |
66 |
| -There could be one Active Directory Organizational Unit (OU) where the Cluster |
67 |
| -Named Object (CNO) computer object resides. This is so that permission can be given |
68 |
| -to the CNO to allow the creation of a Virtual Computer Object (VCO). |
69 |
| -Preferably the CNO should be added to an Active Directory security group and that |
70 |
| -group has the permission to create computer objects inside the OU. This way, more |
71 |
| -than one CNO computer object can use the same OU. |
72 |
| - |
73 |
| -Please note that the prestaged CNO computer object must be disabled before creating |
74 |
| -the failover cluster, and that the security group must be given the permission |
75 |
| -**Create Computer Objects** on the OU where the CNO computer object was created. |
76 |
| -Also the user creating the failover cluster must have the permission **Full Control** |
77 |
| -on the CNO computer object. |
78 |
| - |
79 |
| -The [xADObjectPermissionEntry examples](https://github.com/PowerShell/xActiveDirectory/tree/dev/Examples/Resources/xADObjectPermissionEntry) |
80 |
| -at the resource module [xActiveDirectory](https://github.com/PowerShell/xActiveDirectory) |
81 |
| -can be used to set the correct permissions. |
82 |
| - |
83 |
| -```powershell |
84 |
| -<# |
85 |
| - Creates the Organizational Unit for the CNO. |
86 |
| -#> |
87 |
| -xADOrganizationalUnit 'ClusterComputerObjects' |
88 |
| -{ |
89 |
| - Ensure = 'Present' |
90 |
| - Name = 'Cluster Computer Objects' |
91 |
| - Path = 'DC=companylab,DC=se' |
92 |
| - ProtectedFromAccidentalDeletion = $true |
93 |
| - Description = 'The Cluster Computer Objects (CNO) ' ` |
94 |
| - + 'and Virtual Computer Objects (VCO).' |
95 |
| -
|
96 |
| - # A user with enough permission to create the OU. |
97 |
| - Credential = $DomainAdministratorCredential |
98 |
| -} |
99 |
| -
|
100 |
| -<# |
101 |
| - Creates the Cluster Named Object (CNO) computer object. |
102 |
| -#> |
103 |
| -xADComputer 'TESTCLU01' |
104 |
| -{ |
105 |
| - ComputerName = 'TESTCLU01' |
106 |
| - DnsHostName = 'TESTCLU01.companylab.se' |
107 |
| - Path = 'OU=Cluster Computer Objects,DC=companylab,DC=se' |
108 |
| - Description = 'Cluster Network Object (CNO) ' ` |
109 |
| - + 'for Failover Cluster TESTCLU01.' |
110 |
| -
|
111 |
| - # A user with enough permission to create the computer object. |
112 |
| - DomainAdministratorCredential = $DomainAdministratorCredential |
113 |
| -} |
114 |
| -
|
115 |
| -<# |
116 |
| - Creates the security group and adds the Cluster Named Object (CNO) |
117 |
| - as a member to the group. |
118 |
| -#> |
119 |
| -xADGroup 'ActiveDirectoryCreateClusterVirtualComputerObjects' |
120 |
| -{ |
121 |
| - Ensure = 'Present' |
122 |
| - GroupName = 'Active Directory Create Cluster Virtual Computer Objects' |
123 |
| - GroupScope = 'Global' |
124 |
| - Category = 'Security' |
125 |
| - Description = 'Group that will give permission to a Cluster Name Object ' ` |
126 |
| - + '(CNO) to create one or more Virtual Computer Object (VCO).' |
127 |
| - MembersToInclude = 'TESTCLU01$' |
128 |
| -
|
129 |
| - # A user with enough permission to create the security group. |
130 |
| - Credential = $DomainAdministratorCredential |
131 |
| -} |
132 |
| -``` |
133 |
| - |
134 |
| -#### Create Failover Cluster |
135 |
| - |
136 |
| -The example [Create a Failover Cluster with two nodes](https://github.com/PowerShell/xFailOverCluster/blob/dev/Examples/Resources/xCluster/3-CreateFailoverClusterWithTwoNodes.ps1) |
137 |
| -at the resource module [xFailOverCluster](https://github.com/PowerShell/xFailOverCluster) |
138 |
| -can be used to create the failover cluster. It is an example, and it should be |
139 |
| -changed to match your configuration. Also, please see other resource examples in |
140 |
| -[xFailOverCluster](https://github.com/PowerShell/xFailOverCluster) to see if |
141 |
| -they could improve you configuration, for example the resource xClusterQuorum. |
142 |
| - |
143 |
| -> [!IMPORTANT] |
144 |
| -> Make sure any user accounts you use in the configuration exist in |
145 |
| -> Active Directory and that they have the correct permission. |
146 |
| -
|
147 |
| -#### Install SQL Server Failover Cluster Instance |
148 |
| - |
149 |
| -The example shows how to |
150 |
| -[install the first SQL Server Failover Cluster node for a named instance](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlSetup/4-InstallNamedInstanceInFailoverClusterFirstNode.ps1). |
151 |
| -And this example shows how to |
152 |
| -[install the second SQL Server Failover Cluster node for a named instance](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlSetup/5-InstallNamedInstanceInFailoverClusterSecondNode.ps1). |
153 |
| - |
154 |
| -> [!IMPORTANT] |
155 |
| -> Make sure any user accounts you use in the configuration exist in |
156 |
| -> Active Directory and that they have the correct permission. |
157 |
| -
|
158 |
| -## Setting up a SQL Server AlwaysOn Availability Groups |
159 |
| - |
160 |
| -This will reference examples that show how to setup high availability using |
161 |
| -AlwaysOn Availability Group. |
162 |
| -It assumes that a working domain exists with at least one Domain Controller, |
163 |
| -and both servers that should contain the SQL Server nodes are domain joined. |
164 |
| - |
165 |
| -### Prepare Active Directory |
166 |
| - |
167 |
| -Please see [Prepare Active Directory](#prepare-active-directory). The same applies |
168 |
| -to the failover cluster needed for SQL Server AlwaysOn Availability Groups. |
169 |
| - |
170 |
| -#### Create Failover Cluster |
171 |
| - |
172 |
| -Please see [Create Failover Cluster](#create-failover-cluster). The same applies |
173 |
| -to the failover cluster needed for SQL Server AlwaysOn Availability Groups. |
174 |
| - |
175 |
| -#### Install SQL Server on replicas |
176 |
| - |
177 |
| -> [!NOTE] |
178 |
| -> Make sure any user accounts you use in the configuration exist in |
179 |
| -> Active Directory and that they have the correct permission. |
180 |
| -
|
181 |
| -##### Install SQL Server on the primary node |
182 |
| - |
183 |
| -The example shows how to |
184 |
| -[install a SQL Server named instance on a single server](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1) |
185 |
| -which will be used as the primary replica node in the SQL Server AlwaysOn |
186 |
| -Availability Group. |
187 |
| - |
188 |
| -##### Install SQL Server on the secondary node |
189 |
| - |
190 |
| -The example shows how to |
191 |
| -[install a SQL Server named instance on a single server](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlSetup/2-InstallNamedInstanceSingleServer.ps1) |
192 |
| -which will be used as the secondary replica node in the SQL Server AlwaysOn |
193 |
| -Availability Group. |
194 |
| - |
195 |
| -#### Enable AlwaysOn on both primary and secondary replica |
196 |
| - |
197 |
| -AlwaysOn must be enabled on both the primary and secondary replica, and the example |
198 |
| -[Enable AlwaysOn](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlAlwaysOnService/1-EnableAlwaysOn.ps1) |
199 |
| -shows how to enable it (which requires that a working Failover Cluster is |
200 |
| -present on the node). |
201 |
| - |
202 |
| -#### Configure SQL Server AlwaysOn Availability Group |
203 |
| - |
204 |
| -Once AlwaysOn is enabled we can create the Availability Group. The example [Create Availability Group](https://github.com/PowerShell/SqlServerDsc/blob/dev/Examples/Resources/SqlAGReplica/1-CreateAvailabilityGroupReplica.ps1) |
205 |
| -shows how to create the Availability Group on the primary replica and join the |
206 |
| -Availability Group on the secondary replica. |
207 |
| - |
208 |
| -> [!IMPORTANT] |
209 |
| -> Make sure any user accounts you use in the configuration exist in |
210 |
| -> Active Directory and that they have the correct permission. |
| 6 | +See the [GitHub repository Wiki](https://github.com/dsccommunity/SqlServerDsc/wiki) |
| 7 | +for examples of how to use the resources. Also see the section Usage for |
| 8 | +more examples for certain areas. |
0 commit comments